Scratch game making tutorial 118

Milk drinker - advanced

In this tutorial you will create a game in which the Cat must avoid enemies and drink milk to gain health. The enemies take lives! The cat can draw fences to stop the enemies.

 

Complete these steps ..

 

1. Create a new game, select the stage and then click the background tab. Click "edit" and fill the stage with a bright green colour.

 

 

2. Create these variables ("for all sprites") ..

Un-tick the "Pen timer", we do not need to see it on the stage.

Position the "Cat lives" variable at the edge of the stage ..

 

 

3. Add these scripts to the stage ..

 

 

4. Select the cat sprite. Re-name the sprite "Cat" and then, click the direction button to make sure the Cat can only face left-right ..

 

Now add the first script ..

 

 

6. Add the next cat script. This script makes the cat move automatically and allows the player to steer the cat with the arrow keys ..

 

 

7. Add the next cat script. This script allows the cat to draw a yellow line, which the enemies cannot cross, when you press the space-bar ..

Press the "B" key to test your game. Use the arrow keys to steer the cat and press the space-bar to draw a yellow line. Press "E" to end when you are done.

 

 

8. Use "File>Save as" to save your game. Name it "Milk defender".

 

 

9. Add the next cat script. This script clears the yellow lines the cat has drawn every 20 seconds ..

 

 

10. Add the final cat script. This script stops the game when the cat loses all its lives ..

 

 

11. We need to import an enemy sprite. Download and save this sprite ..

Now use the "Choose new sprite from file" button under the stage to load it ..

 

 

12. Select the Enemy 1 sprite, then click the direction button to make sure it can only face left-right.

Now add the first script ..

 

 

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

 

 

14. Add the second Enemy 1 script. This script makes the sprite chase the cat, but stops it when it touches a yellow line ..

 

 

15. Add the third and final Enemy 1 script ..

Press the "B" key to test your game. Press "E" to end when you are done.

 

 

16. One enemy is not enough. Right-click the Enemy 1 thumbnail picture under the stage and duplicate it twice so you have 3 enemies ..

Re-name the duplicates "Enemy 2" and "Enemy 3".

 

 

17. Select Enemy 2 and change it's move script step from "1" to "1.2" ..

 

 

18. Select Enemy 3 and change it's move script step from "1" to "1.3" ..

Press the "B" key to test your game. Press "E" to end when you are done.

 

 

19. Use "File>Save" to re-save your game.

 

 

20. We need to import a milk bottle sprite. Download and save this sprite ..

Now use the "Choose new sprite from file" button under the stage to load it ..

 

 

21. When the cat touches the milk bottle it will gain a life. The Milk bottle will appear at random times and locations on the stage.

Select the Milk bottle sprite and add the first script ..

 

 

22. Now add the second Milk bottle script ..

 

Press the "B" key to test your game. Press "E" to end when you are done.

 

 

23. Use "File>Save" to re-save your game.

 

 

24. Well done. You've finished. What new ideas can you add to this game?