Discuss Scratch

shivankvirdi
Scratcher
44 posts

For New Scratchers: Most efficient way to make a sprite move using arrow keys.

Many New Scratchers will use this script to move a sprite.

when [up v] key pressed
point in direction (0 v)
move (10) steps

This isn't a very efficient way to move a sprite. The sprite will move but not smoothly. It will have little “bumps” while it is moving.

This is a very efficient way to move the sprite since it moves very smoothly. There are no bumps in the movement of the sprite.

when [up v] key pressed
repeat until <not <key [up arrow v] pressed?>>
point in direction (0 v)
move (10) steps
end

When you are coding a sprite to move with arrow keys, make sure you change the direction it faces. For example, if you want to code the sprite to move right when the right arrow key is pressed, you have to change the
 point in direction ( v) 
to 90 degrees. Also, the higher the number of steps is in the
move () steps
, the faster the sprite will move.

You're Welcome
If you want you can view my profile and see my projects. My pong game has a cpu script in it which you can copy and use.

Last edited by shivankvirdi (April 24, 2020 06:57:51)

Daring_Sailor
Scratcher
1000+ posts

For New Scratchers: Most efficient way to make a sprite move using arrow keys.

Hey there!

This forum is for New Scratchers to introduce themselves. If you'd like to help them with scripts, then the Help with Scripts forum is a great place for that. Alternatively, you could follow joshuaho's advice:

joshuaho wrote:

You could put all those tips into a project and then tell others about it in the Show and Tell forum.

Thank you for your enthusiasm to help New Scratchers!

Powered by DjangoBB