Move () Steps - Scratch Wiki (original) (raw)

Assuming the black grid shows individual pixel positions, moving 1 step gets the Scratch Cat to the red circle, its final position along the circle depending on its direction. Moving 2 steps gets to orange, and moving 3 steps gets to green.

The move () steps block is a stack block and a Motion block. Unlike the Change X by () or the Change Y by (), this block moves its sprite forward the specified amount of "steps" in the direction it is facing. A step is equal to a one-pixel length. The Default Value is 10 and can be replaced by any number. The block uses trigonometry to move in the proper direction, as this is how a computer handles it.

Prior to Scratch 22Dec04, this block was known as "forward ()".

Like all other motion blocks, this block is not accessible from the stage and will not work if imported from a sprite.

Example Uses

Instead of using complicated scripts with the Change X by () block and the Change Y by () block, this block can be easily used to move a sprite in its direction.

Some common uses for the Move () Steps block are:

when gf clicked set rotation style [left-right v] forever move (10) steps if on edge, bounce

repeat (10) move (10) steps end

forever point towards (mouse-pointer v) move (10) steps end

forever point towards (other sprite v) move (10) steps end

Workaround

Main article: List of Block Workarounds

This block can be replicated with the following code:

go to x: ((x position) + (([sin v] of (direction)) * (number))) y: ((y position) + (([cos v] of (direction)) * (number))

or:

change x by ((steps) * ([sin v] of (direction))) change y by ((steps) * ([cos v] of (direction)))

See Also

vdeMotion Blocks
Move () Steps Turn Right () Degrees Turn Left () Degrees Go to () Go to X: () Y: () Glide () Secs to () Glide () Secs to X: () Y: () Point in Direction () Point Towards () Change X by () Set X to () Change Y by () Set Y to () If on Edge, Bounce Set Rotation Style () X Position Y Position DirectionMore blocks...

Cookies help us deliver our services. By using our services, you agree to our use of cookies.

The Wiki is working on a dark theme, and you're seeing it! Got feedback? Post on the Wiki Forum Topic.