Coordinates and Movement in Scratch
Every point on the stage is given by two numbers, the x and y coordinates. We learn to send a sprite to a given point and move it smoothly.
All topics (7 of 11)
Chapter 1. Algorithm Basics
Chapter 2. Programming in Scratch
Chapter 3. Project Work
The Scratch stage is a coordinate plane: the horizontal axis is x and the vertical axis is y. The centre of the stage is the point (0; 0). The value of x grows to the right (up to 240 at the edge) and falls to the left (down to −240). The value of y grows upward (up to 180) and falls downward (down to −180).
A sprite’s current coordinates are shown in the Motion category as the x and y values. To send it to an exact spot, use the “go to x: 100 y: 50” block. The “glide 1 secs to x: 100 y: 50” block moves the sprite to the same point smoothly, right before our eyes.
A sprite can also be moved relative to where it is now: “change x by 10” shifts it to the right, and “change y by −10” shifts it down. Direction is set by the “turn ... degrees” and “point in direction ...” blocks: 90 is right, 0 is up, 180 is down and −90 is left.
An example is a script that takes a sprite round the corners of the stage in turn. After the “when green flag clicked” block, attach “glide 1 secs to x: −150 y: 100”, “glide 1 secs to x: 150 y: 100”, “glide 1 secs to x: 150 y: −100” and “glide 1 secs to x: −150 y: −100”. With the Pen extension you can draw a rectangle as well.
Key takeaways
- The stage is a coordinate plane with its centre at (0; 0).
- x is the horizontal coordinate and y is the vertical one.
- “Go to” moves the sprite instantly, while “glide” moves it smoothly.
- Direction is given in degrees: 90 is right and 0 is up.
Practice tasks
- Send a sprite to the top-left corner of the stage: which x and y values will you use?
- Build a script that uses “glide” blocks to take a sprite round all four corners of the stage.
- With the Pen extension, draw a diagonal line from x: −100 y: −100 to x: 100 y: 100.
Review questions
Test yourself: think first, then reveal the answer.
1What are the coordinates of the centre of the Scratch stage?Show answerHide answer
x = 0, y = 0.2How do the “go to” and “glide” blocks differ?Show answerHide answer
“Go to” moves the sprite to the point instantly, while “glide” moves it smoothly over the given time.
0 of 11 topics completed
Sign in to mark