Scratch game making tutorial 121

Child minder

In this tutorial you will create a game in which you must protect children from goats! Sometimes the children will listen to and follow you, and sometimes they run away and chat!

 

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. Select the stage and then create these variables ("for all sprites") ..

Hide the "follow timer" variable. We will use this to set a time limit for how long the children will follow the child minder.

 

 

3. Add these scripts to the stage ..

 

 

4. Right-click the cat sprite to delete it.

Now download, save and then add these sprites to your game using the "choose new sprite from file" button under the stage ..

 

Right-click on the "Goat 1" sprite and duplicate it. Re-name it "Goat 2".

 

 

5. Click on the "paint new sprite" button under the stage and use the smallest paint brush size to paint a single green dot, the same colour as your stage.

Name it "meet point". We will use the "meet point" sprite to make the children gather when they run away from the child minder.

 

You should now have these sprites ..

 

 

6. Use "File>Save as" to save your game. Name it "Child minder".

 

 

7. Select the "instructions" sprite and add these scripts ..

 

 

8. Select the "meet point" sprite and add these scripts ..

When "children meet" is broadcast, this sprite will go somewhere random on the stage and then the children will meet there.

 

 

9. Let's script the "Childminder" sprite. The child minder must keep the children safe from the goats! The children will follow the child minder for 10 seconds when she calls them. After that they will ignore her for between 1 and 10 seconds.

Select the "childminder" sprite and add these scripts (the comments explain the scripts, you do not have to add them) ..

Press the "B" key to test your game. You should be able to control the child minder with the mouse but not much else yet. Press "E" to end when you are done.

 

 

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

 

 

11. Select the "Child 1" sprite. The children will follow the child minder for 10 seconds when she calls them. After that they will ignore her and run away and meet for between 1 and 10 seconds.

Add these scripts (the comments explain the scripts, you do not have to add them) ..

Press the "B" key to test your game. Use the spacebar to call "Child 1" to follow you. Move the child minder with the mouse. "Child 1" should follow you sometimes but not always. Press "E" to end when you are done.

If the "Child 1" scripts are working, duplicate (copy) all of them to "Child 2" and to "Child 3".

 

 

12. There are 3 small changes to make to the scripts you have just copied. This is to ensure the children follow each other and face each other when they meet.

Select the "Child 2" sprite.

  1. Find the "move 6 steps" script block and change it from 6 to 5 steps.
  2. Find the "point in direction" script block and change it from "0" to "120".
  3. Find the "if distance to child minder > 40" script block and change it from 40 to 60

 

 

13. Select "Child 3". Once again you must make 3 small changes ..

  1. Find the "move 5 steps" script block and change it from 5 to 4 steps.
  2. Find the "point in direction" script block and change it from "0" to "240".
  3. Find the "if distance to child minder > 40" script block and change it from 60 to 80

 

Press the "B" key to test your game. Use the spacebar to call the children to follow you. Move the child minder with the mouse. The children will follow you sometimes but not always. Sometimes they will run away and meet. Press "E" to end when you are done.

 

 

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

 

 

15. Select "Goat 1" and add these scripts to make it wander across the screen in a random direction and at a random time ..

 

Press the "B" key to test your game. The goat should wander from the top of the stage to the bottom every now and then. Press "E" to end when you are done.

If the "Goat 1" scripts are working, duplicate them to "Goat 2".

 

 

16. Add these scripts to the "Game over" sprite ..

 

 

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

 

 

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