Discuss Scratch

Groundzerostudios
Scratcher
6 posts

Need help with a moving script.

Recently i have added more code to my tank game, however i cannot figure out a solution for the moving script for the player and enemies.
You see, the enemies run on a script that will make them move towards the player a random about of steps depending on the type of tank. However they will always point towards the player while doing this, so i wanted to know if there was some way i could incorperate a ¨AI¨ that will have the enemies move up/down/left/right/diagonal towards the player, basically path finding.
As for the player the script allows you to move diagonally but its not smooth, is there a way to make the tank go diagonal depending on the keys pressed? (And face diagonally as well)
For example if W and D are pressed the tank will move diagonally to the right. (And face that direction as well!)
when green flag clicked
forever
if <key [ w] pressed?> then
point in direction ( 0)
move (2) steps
end
This is the script for moving the tank, repeated 4 times for WASD and adjusted to face the direction and move that way.
This is the same script featured in that Exploring Mars Rover project for scratch by NASA.

Powered by DjangoBB