Getting started If you haven t used Scratch before we suggest you first take a look at our project Coding with Scratch First Steps Page 1 Popping Balloons In this game the cat will move around the screen chasing party balloons and when it touches a balloon it goes pop and the balloon disappears! The player controls the cat by moving the computer mouse (or track pad). When you make this game you will: Add a new sprite Use if.. then loops Duplicate sprites and their code Add sounds Control a sprite using your computer mouse or trackpad Make the cat move Start a new Scratch project. From the yellow Control blocks click on the forever block and drag it into the scripts area. From the blue Motion blocks drag a points towards block and drop it into the forever block. From the Events blocks drag a when green flag clicked block and join it to the top of the forever block.
Your code should look like this: Page 2 Try running the code by clicking on the green flag at the top of the stage to start the program. As you move the computer mouse around the stage the cat will keep turning to face it. Now drag a blue move 10 steps block from the Motion blocks and drag it into the jaws of the forever block. The forever block will automatically expand to make room for the new block. Your code will now look like this. Click the Green Flag to start the program running and when you move your computer mouse the cat will follow it around the stage. This type of code is often used to let a player control a sprite when playing a game. For this particular game we want the cat to move more slowly, so click on the number 10 in the move 10 steps block and type in 3. We also want the cat to be smaller, so drag a block from the Looks blocks and drop it between the when green flag clicked block and the forever block. Then change the 100 to 50.
And finally you may have found that when the cat was following the mouse-pointer some of the time he was upside-down. For this game we only want the cat to be facing either left or right so drag a set rotation style block from the Motion group and click on the drop down menu and select leftright Page 3 Then insert the block below the block so that your code now looks like this: That finishes the code for the cat sprite. Add a new sprite the balloon Click on the pixie icon to Choose sprite from library When the library appears browse through it until you find the Balloon1 click on it to add the sprite to the game. and then double
Writing the code for the balloon Next we are going to write the code for the part of the game where, if the cat touches the balloon then the balloon pops and disappears. This is an example of Collision Detection which is a key feature of video games (whether it be a spacecraft hitting a meteorite or Pac Man colliding with a ghost!) but it is also widely used in robotics. Page 4 In our case the collision we need to detect is the cat colliding with the balloon. And the action we want to happen when it does is to make a pop sound and disappear. Scratch has a yellow Control block, the If, Then block, for exactly this situation: So drag out an if then control block and insert a light blue Sensing block into the space. Then click on the drop down menu in the sensing block and select Sprite 1 which is the cat so that the combined blocks look like this: Now insert a play sound pop block from the Sound blocks and a hide block from the Looks blocks into the jaws of the if then block so the code looks like this: The hide block is used to make the balloon disappear.
We want the program to keep checking if the balloon is touching sprite 1 (the cat) so we put a forever loop around our code. Drag the forever block from the Control group and its jaws will automatically open to fit in place. Page 5 Now we add the following three blocks to our code: And that finishes the code for the balloon. Play the game Click the Green Flag to start the game and the as you move your computer mouse (or trackpad) the cat will follow and you can guide him to touch the balloon so that it pops.
Add more balloons We can make the game a lot more fun by adding more balloons. This is quite easy. In the sprites section click on the balloon sprite to select it. Then right click and from the menu that appears select duplicate and a second balloon appears on the stage which has the same code as the original balloon. Page 6 You can repeat this as many times as you like so you have lots of balloons for the cat to chase! New Backdrop Finally we can add a new backdrop to make the game more attractive. Firstly click to Select Backdrop from the library. Then look though the backdrops and choose one you like. Here we have chosen Room 3. Double click it and it will be added to your stage.
So the final game looks like this. Page 7