Scratch exercise 134a

Force field - simple

In this exercise you will create a game in which a force field can be activated to protect the Cat from damage caused by moving balls.

 

Complete these steps ..

 

1. Open Scratch, OR create a new game (from the top menu choose "File>New").

 

 

2. Select the stage by clicking on the Stage thumbnail under the stage.

Add these scripts to the stage ..

 

 

3. Now select the background tab and click the "Edit" button ..

 

Use the paint bucket tool to fill the stage with black and then click "OK' when you are done ..

 

 

4. Click the cat sprite thumbnail under the stage to select the Cat (sprite1) ..

 

 

5. Click in the naming box to re-name "sprite 1" "Cat".

Now click the middle of the 3 vertical buttons to make sure the Cat cannot turn upside down. When you hover the mouse over the button you will see it is called "only face left right".

 

 

6. Now add the following script to the Cat ..

Press "B" on your keyboard and you will see the cat shrink and move to the centre of the stage.

 

 

7. Now add the next script to the cat to make it follow the mouse pointer ..

 

When you are done, test your game. Press the "b" key on your keyboard to begin your game, and then move the mouse-pointer around the stage. The Cat should follow it. Press "e" for end when you are ready to continue making your game.

 

 

8. Use "File>Save as" to save your game. Call it "Force field"..

 

 

9. Click the "Paint new sprite" button under the stage ..

 

Select the paint brush tool, then the largest brush size and then a red colour and click once to paint a single ball ..

 

Click "OK" when you are done.

 

 

13. Re-name the ball "Ball 1", and then add these scripts to re-size it and make it automatically move around the stage ..

 

 

14. Press the "B" key to test your game. The ball should bounce around the stage. Control the Cat to avoid the ball.

When you are ready press "E" to end your game and continue working on it.

 

 

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

 

 

17. Let's make the Cat react when the ball hits it. Add this script ..

 

 

18. Press "B" to test your game. The Cat should react when the ball touches it.

When you are ready press "E" to end your game and continue working on it.

 

 

19. Let's create a force field for the Cat. Click the Paint new sprite button under the stage, choose a new colour, and use the largest brush size again to paint a force field image like this ..

 

 

20. Click "OK", and re-name the sprite "Force field", then add these scripts ..

 

 

21. Press "B" to test your game. Press the space bar on your keyboard to activate the force field.

When you are ready press "E" to end your game and continue working on it.

 

 

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

 

 

23. We need to add a script to the ball to make it bounce off the force field. Add this script ..

Press "B" to test your game. Make sure the ball bounces off the force field.

When you are ready press "E" to end your game and continue working on it.

 

 

24. One ball is not enough. Lets have 5. Right-click the "Ball 1" thumbnail under the stage to duplicate it 4 times ..

 

Press "B" to test your game. The game should be harder now.

When you are ready press "E" to end your game and continue working on it.

 

 

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

You've finished this tutorial. Well done! Now, try to make a complete game from this exercise.