Scratch game making tutorial 147a

X and Y - simple

In this tutorial you will create a game in which the player must help the Cat to reach a red spinning square by entering the correct X and Y co-ordinates of the square.

 

We position sprites on the Scratch stage using X and Y co-ordinates. The simplest way is to use the "go to X: Y:" motion script block.

For example ..

 

Here are some example X and Y co-ordinates ..

 

The Scratch stage is 480 pixels/steps wide and 360 pixels/steps high.

Width (X) = -240 to 240 = 480

Hight (Y) = -180 to 180 = 360

 

Let's create a game that will test a players understanding of X and Y co-ordinates on the Scratch stage.

Complete these steps ..

 

1. Open Scratch, OR create a new game (from the top menu choose "File>New").

 

 

2. Select the cat sprite, re-name it, and then click the "only face left-right" button ..

 

 

3. Add this script to the Cat so you can stop your game by pressing the "E" key on your keyboard ..

 

 

4. Now add this script to the Cat to set it's size and to tell the player what to do when the game begins ..

 

 

5. Let's make the Cat start from the bottom left corner of the stage and always point towards the Red square.

Add this script ..

NOTE: You will need to come back and select "Red square" in the "pint towards" script block after you have completed step 7 below.

 

Press the "B" key on your keyboard to test your script. If you click the Cat nothing will happen, we haven't added the script yet.

 

 

6. Use "File>Save as" to name and save your game. Name it "X and Y" ..

 

 

7. Click the "paint new sprite" button under the stage ..

 

Now select the colour red and the rectangle tool, hold down the shift key and drag to create a red square ..

 

Click "OK" when you are done and then name the new sprite "Red square" ..

 

 

8. On the stage look at your red square. It should not be too big. Something like this is good ..

 

If the Red square is too big or too small add a script to re-set its size like this ..

 

 

9. You need the Red square sprite to go to a random position on the stage when the games begins. The stage is 480 pixels wide and 360 tall.

Add this script ..

 

 

10. Once the Red square has moved to a random position on the stage it doesn't do anything fun. Let's make it spin. Add this script ..

 

 

11. You need one more script on the Red square sprite.

When the Cat reaches it, it will say "You found me!" and then move to another random position on the stage.

Add this script ..

 

Go full screen and then press the "B" key on your keyboard to test your game.

When you are ready exit full-screen, and then press the "E" key to end your game, and then use "File>Save" to re-save it ..

 

 

12. Next, select the Cat sprite again. We have some more scripts to add to it.

When the player clicks the Cat, it will ask the player to enter X and Y positions and then move the Cat to these positions. The player must try to move the Cat to touch the Red square.

Add this script ..

 

Go full screen and then press the "B" key on your keyboard to test your game.

When you are ready exit full-screen, and then press the "E" key to end your game.

 

 

13. Use "File>Save" to re-save the game ..

 

 

14. Well done, you've finished making the game! Can you improve it with your own ideas? How about these ..