Scratch game making tutorial 96

Orange squash

In this tutorial you will create a platform scrolling game in which the background (terrain) moves past you. You will have to avoid obstacles and collect health to survive as long as you can.

 

Complete these steps ..

 

1. Create a new game (From the top menu choose File>New).

 

2. Delete the cat sprite.

 

3. Select the stage, click the "backgrounds" tab and edit/paint the stage sky blue.

 

4. Now click the "scripts" tab and add these scripts ..

 

5. Create these 3 variables ..

The value in the scroll x variable will be controlled with the right and left arrow keys and will be used to move the terrains. We don't need to see this variable on the stage so you can hide it if you like.

 

Drag the Lives and Time displays to the top corners of the stage like this ..

 

6. Complete the scripts on the stage with a time/clock script ..

This script will allow the player to see how long they have managed to survive before the game ends.

 

7. Download, save and then add ("choose sprite from file" button) these 10 sprites to your game ..

 

8. Save your game. Name it "Orange squash".

 

9. Next we will make the terrain sprites scroll.

Add these scripts to "terrain 0". This terrain will not move but provide a static background to cover any gaps or glitching as the other terrains scroll across the stage ..

Note that the terrain is positioned near the bottom of the stage at y:-170.

 

10. Select "terrain 1" and add these scripts ..

Look at this script carefully and note the following ..

 

11. Copy the scripts form 'terrain 1" to "terrain 2" and change the "set x to" multiplier from * 1 to * 2 ..

 

12. Do the same for the remaining terrain sprites, ensuring each time that you match the terrain number to its "set x to" multiplier, so for example, 'terrain 5" will have a multiplier of 480 * 5.

 

13. Re-save your game using File>Save.

 

14. Select the "orange" sprite and add these scripts ..

Note that ..

Press the "b" key and then use the left, right and up arrow keys to test them.

 

15. End/stop your game ("E") and add the re-start and lives script to the orange ..

 

16. Re-save your game using File>Save.

 

17. Add these scripts to the eagle sprite ..

These scripts make the eagle dive and swoop randomly. If the eagle touches the orange (see orange scripts), the orange loses a life.

 

18. The heart sprites give lives. When collected they disappear and then reappear later. Add these scripts to "heart 1" ..

 

19. Re-save your game using File>Save.

 

20. Copy the "heart 1" scripts to "heart 2" and edit the "go to y:" script block to place it at the correct height. Also change the multiplier to * 2, like this ..

 

21. Do the same for "heart 3" so it's scripts are ..

 

22. Re-save your game using File>Save. You've finished, well done!

Press the "B" key, or click the green flag, to start your game, and then use the right, left and up arrow keys to control the orange.

How long can you survive for?

 

23. Now add some more terrains of your own design. What else can you add to the game?