Scratch game making tutorial 112

Party poppers

In this tutorial you will make a game in which the Cat must pop falling balloons with a party popper. The Cat will lose lives if a balloon touches him or the ground. You can multi-pop the green balloons. How many balloons can the Cat pop before he runs out of lives?

 

1. Create a new game and then use the "Choose new sprite from file" button under the stage to load these sprites ..

 

2. Select the stage, switch to the "Backgrounds" tab and then import this background image ..

Now delete the blank white background.

 

3. Now create these variables ("for all sprites") ..

Hide all of them except "balloons popped" and "cat lives". Right-click them and choose "large readout" and then arrange them in the top corners of the stage like this ..

 

 

4. Add these scripts to the stage ..

 

The Cat will only be able to run around the stage when it is NOT firing a streamer from the popper. The Cat's move script needs to know if it is firing. When the game starts it is not firing.

Also, the "balloons popped" display will let us know how many balloons we have popped. We will set the number to 0 when the game starts. Add this script ..

 

To make the game harder as it progresses, we are going to increase the speed that the balloons fall at by 0.1 of a step every 10 seconds. Add this script ..

Notice how we are using "-1" and "-0.1". This is because the y position of the balloons reduces to minus numbers as they fall.

 

5. Use "File>Save as" to save your game. Name it "Party poppers".

 

6. Select the Cat sprite. Re-name it "Cat" and set it to face left-right only ..

 

It's too big for our game so let's reduce it. Add this script ..

 

Now, let's get the Cat moving. We want the Cat to follow the mouse-pointer, but only move when it is NOT firing the popper and only when it is further than 30 pixels from the mouse-pointer. Add this script ..

Notice how the speed depends on how far from the mouse-pointer the Cat is.

Press the "B" key and then move your mouse-pointer on the stage to test your script. Press "E" to end when you are done.

 

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

 

8. Select the "popper" sprite. The Cat will hold this in his paw. The streamer will fire from it. Add these scripts to it ..

Press the "B" key and to test your script. The Cat should run towards the mouse-pointer holding the popper. Press "E" to end when you are done.

 

9. Select the red "balloon 1a" sprite. This sprite has four costumes ..

 

The balloons appear and float down at random times (i.e. spawn). Add this first script ..

 

We need a sound for when the balloon is popped by the streamer. Click on it's "sounds" tab and import this sound file ..

 

Now we need to create the complex script for the balloons. Go slowly and ensure you complete it without errors. You can duplicate the four script blocks that make up the reset script to save time.

Notice how the "reset" script hides and sends the balloon back to the top, ready to float down again, whenever it has been popped, or when it reaches the ground.

 

10. We need 2 red balloons. Simply duplicate "balloon 1a" and re-name it "balloon 1b".

Press the "B" key to test your scripts. The balloons will spawn and float down but you cannot pop them yet. Press "E" to end when you are done.

 

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

 

12. It's time to script the streamer which fires from the popper and pops the balloons. Select the "streamer" sprite and add this script ..

 

Now add the firing script ..

Notice how you fire using the mouse button and that the streamer keeps going until it pops a red balloon.

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

 

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

 

14. Two red balloons isn't enough to make the game challenging and fun. Select "balloon 1a" and copy (drag to duplicate) it's scripts onto the green "balloon 2a".

Now right-click green "balloon 2a" under the stage to duplicate it twice. You now have three green balloons. Ensure they are named ..

 

If you go back and check the "streamer" scripts you will see that only the red balloons. stop the "streamer". This means you can pop multiple green balloons one after another.

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

 

15. The Cat will lose a life when it touches any balloon. Select the Cat sprite and add this script to it ..

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

 

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

 

17. Select the "game over" sprite and add the final scripts ..

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

 

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

 

19. Well done. You've finished. Can you think of any mods?