Raspberry_Pi_Education_Manual

Notes:

Positioning your sprite

Ok, we’ve told a joke. But this play is looking a bit static, so let’s make our characters move. The first job is to move our two characters to their start points. In my play, the cat will come in from the left and the boy from the right.

You may have come across x and y axes when creating graphs.

the Y coordinate

the x coordinate

The coordinates of any point on the stage are shown at its bottom-right-hand corner. Move your mouse around the screen and watch the numbers change.

Task: Use your mouse to find the centre of the screen. Move the mouse pointer until it’s exactly over the point x: 0 y: 0. Now let’s position our sprites.

Tip...

Use your mouse pointer to find the coordinates of a position on the stage and make a note of those coordinates on a piece of paper.

1.  Select the cat sprite then, in the Blocks Palette, click on the Motion block labelled “go to x: [0] y: [0]”. 2.  Change the values in the block to x: -240 y: -80. This will take the cat to the far left of the stage. 3.  Next place a “wait [1] secs” block into your script. This will give you time to see your cat before it moves. 4.  Now add a second “go to x: [0] y: [0]” block. Use your mouse to work out the x coordinate just left of centre on the stage, to which we want to move the cat. Repeat this process for your other sprite, positioning it slightly to the right of centre stage. Ideally, the two sprites should move from the edges of the screen to stand face to face, separated by a small gap. Now you need to make the sprites tell a joke. Remember to leave a short delay after each sprite speaks, otherwise they’ll talk over each other. Have a look at the screenshots to see our code (and our fantastic joke).

This is what our code for the boy sprite looks like.

And here’s our code for the cat sprite. Does your looks the same?

A beginner’s guide to Scratch

17

Made with FlippingBook flipbook maker