Understanding the Stage in Scratch on the Raspberry Pi

By Richard Wentk

With Scratch on your Raspberry Pi, you don’t have to type anything to code. You get a big (virtual) box of blocks and a stage where things happen.

The stage doesn’t understand up, down, left, or right.

Instead, it uses a system with two magic numbers, so you can just tell a sprite to move to the right by some distance. The numbers have special names: x and y. The x number sets the left/right position. The y number sets the up/down position.

x and y are sometimes called coordinates, which is a big, complicated mathy word for “this is how we use two numbers to work out where something is.”

When x and y are both 0, the sprite is dead center of the stage. To move a sprite right, set x to more than 0. To move it left, set x to less than 0.

The size of x tells you how far away the sprite is from the middle of the stage. The sign (minus or nothing) tells you whether it’s left or right of the middle.

So when x is 100, the sprite is in the right half of the stage. When it’s x is –100, it’s in the left half of the stage.

Up and down work the same way. When y is 100, the sprite is in the top half. When y is –100, it’s in the bottom half.

x and y are completely separate. They’re independent, so you can move the sprite left or right without changing how far up/down it is. And you can move it up and down without changing its left/right position.

To move it up and down and left and right, you have to change x and y together.

Here’s a cheat sheet for moving on the stage with x and y.

How Big Are x and y? Where Is the Sprite?
x doesn’t have a minus sign (100) Right half of the stage
x has a minus sign (–100) Left half of the stage
y doesn’t have a minus sign (75) Top half of the stage
x has a minus sign (–75) Bottom half of the stage
x is zero (0) Dead center left/right only
y is zero (0) Dead center up/down only
x and y are zero (0) Dead center left/right and up/down

Why does Scratch work like this? Wouldn’t it be easier to say left, right, up, and down? It might be, but this x y idea is how it’s done in math and in grown-up game and app programming, so Scratch copies how they work.