LEARN · PRACTISE · DISCOVER
Moving Sprites with Motion and Coordinates
Moving sprites around the stage is the heart of most games and animations. Scratch gives you two ways to move: moving by steps and turns, and moving to an exact spot using coordinates. In this lesson you will learn both.
Steps and turns
move (10) stepsmoves a sprite forward in the direction it is facing.turn right (15) degreesandturn left (15) degreesrotate it. In the editor these blocks show a clockwise arrow (↻) for right and an anticlockwise arrow (↺) for left.point in direction (90)makes a sprite face a direction.
Directions in Scratch
| Direction | Sprite faces |
|---|---|
| 90 | right |
| -90 | left |
| 0 | up |
| 180 | down |
The stage is a grid
The stage is like a big map with an invisible grid. Every spot on the stage has two numbers called coordinates.
- x tells you how far left or right. It goes from -240 on the far left to 240 on the far right.
- y tells you how far up or down. It goes from -180 at the bottom to 180 at the top.
- The very centre of the stage is x: 0, y: 0.
When you move a sprite with your mouse, look under the stage: its x and y numbers change.
Coordinate blocks
| Block | What it does |
|---|---|
go to x: (0) y: (0) | jumps straight to a spot |
glide (1) secs to x: (100) y: (50) | slides smoothly to a spot |
change x by (10) | moves right (use a negative number to move left) |
change y by (10) | moves up (use a negative number to move down) |
go to (random position) | jumps to a surprise spot |
Making a sprite glide around
This script makes a sprite start in the centre and glide to three corners:
when green flag clicked
go to x: (0) y: (0)
glide (1) secs to x: (-200) y: (140)
glide (1) secs to x: (200) y: (140)
glide (1) secs to x: (200) y: (-140)Starting positions
Always set a sprite’s starting spot with go to x: () y: () at the top of your script. Then the project starts the same way every time you click the green flag.
Example
Priya made a rocket launch. Her rocket started at x: 0, y: -150 near the bottom. Then she used glide (2) secs to x: (0) y: (170) to fly it up to the top. When she clicked the green flag, the rocket blasted off!
Bouncing off the edge
If a sprite keeps moving, it may disappear off the side. Add if on edge, bounce after your move block, and the sprite will turn around when it touches the edge. You will use this with loops in Lesson 5.
Key takeaways
- Use steps and turns to move in the direction a sprite faces.
- The stage uses x for left and right and y for up and down.
- The centre of the stage is x: 0, y: 0.
- Set a starting position at the top of every script.
Practice
Make a bird sprite start at the left side of the stage, at x: -200, y: 0, then glide to the right side in 3 seconds, then say “I made it!”.
Answer: when green flag clicked, go to x: (-200) y: (0), glide (3) secs to x: (200) y: (0), say (I made it!) for (2) seconds.