Scratch game making tutorial 130

Snowball rider

In this tutorial you will make a game in which the cat rides a snowball up a mountain to collect treasure whilst avoiding falling enemies.


Complete these steps ..


1. Create a new game then select the stage.

Download, save and import these four stage backgrounds ..


* Notice how each background has a higher path ..

Also notice how each path has a grey top. You will need to sample this later.



2. Select the Stage Scripts tab and add these scripts to both begin and end the game and switch the background paths ..

*Notice how we are using "when I receive" broadcasts (path1, path2 etc.) to switch the backgrounds. We'll learn when and where those broadcasts come from later.



3. Download, save and then add the following sprites to your game ..




4. Create the following variables ..

The "cat direction" variable will be used to let the snowball know which way to roll when the cat is riding it. You can switch it off for now.



5. Use "File>Save as" to save your game. Name it "Snowball rider".



6. Select the Snowball sprite and add the first script to set its starting (initialise) properties ..



7. Now add the script that makes it roll in the correct direction when the cat touches it ..

*Notice how we are using the "Cat direction" variable to determine the roll direction.



8. We need to stop the snowball from rolling off the stage. Add this script ..



9. Finally, we need to ensure the snowball rolls up the path.

Add this script and sample any path top for the "touching color" script block ..



10. Re-save your game.



11. Select the Cat and re-name it "Cat" or another name of your choice, then click the only-face-left-right button ..



12. Add the first script to the Cat to set it's size and starting position on the stage ..



13. Add the following script to the cat to allow the player to move it left and right ..

*Notice how the "Cat direction" variable gets set to either "left" or "right".



14. We need the cat to be able to ride the snowball. Add this script ..

*IMPORTANT! You need to sample two different shades of grey colour and one white for the three "touching colour" scripts ..

  1. inner snowball (grey)
  2. path top (grey - any path will do)
  3. beneath the path top (white)

Turn on the "Cat direction" variable display so you can see it working. Make sure "path1" is the selected background, and then press "B" to test your snowball and Cat. You should be able to ride the snowball up the first path.



15. Press "E" to end your game, then turn the "Cat direction" display off if everything is working well.

Re-save your game.



16. Select the "Treasure" sprite and look at it's costumes.

We are only going to use two costumes for this game, "closed" and "open".


The treasure will first appear at the top of path1. When the snowball has reached it, it will fade out and reappear at the top of path2.

Select the scripts tab and add the first script to set the treasure to the top of path1 ..

*Notice how the Treasure sprite will broadcasting the path changes to the stage. As you will see below, it will also receive them itself.



17. Add these scripts to the Treasure sprite to re-locate it every time the snowball touches it and to change the path background ..



18. We need one final "when I receive" script. Add this..



19. Finally, the we need to add a script to change the Treasures variable by 1 each time the snowball reaches it. Add this ..



20. Press "B" to end your game. If everything so far is working well, Press "E" and re-save your game.



21. The game is too easy. Let's make it tougher by making Enemy sprites fall from the sky. If any Enemy hits the Cat the game will end.

Select the "Enemy 1" sprite and add these scripts ..

*IMPORTANT! You must sample a path top in the "touch color" script block.



22. Test your game and if the Enemy sprite is working correctly duplicate it until you have 5 enemies.

Re-save your game.



23. Select the "Game lost" sprite and add these scripts ..



24. Select the "Game won" sprite and add these scripts ..



25. Re-save your game. Well done, you're finished. Can you add your own features or improve the game?