Scratch game making tutorial 156b

Cog wars advanced

In this tutorial you will create a game in which the player must avoid spinning cogs to avoid losing points and earn new points.

 

 

Complete these steps ..

 

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

 

 

2. Right-click on the cat sprite thumbnail under the stage and delete it ..

 

 

3. Select the stage Backgrounds tab and paint the stage black ..

 

 

4. Add these script to the stage ..

 

 

5. Create the following variables ("for all sprites") ..

 

Keep Countdown and Points visible and locate their displays on the stage like this ..

 

 

6. The speed variable will allow you to set the speed of all the cogs easily. Add this script to the stage to set its value ..

You can experiment with the speed later.

 

 

7. When the cogs collide with one another they will change direction. The collision direction variable is used to determine the direction for all the sprites. Add this script to the stage to set it ..

 

You can experiment with the range of collision direction later as well.

 

 

8. The player must earn as many points as possible before a countdown ends. Points are earned automatically every 10 seconds, but are lost if the players Co1g hits another cog. Add this script to the stage ..

 

 

9. Finally, we need a countdown script. Add this to the stage ..

 

 

10. Use "File>Save as" to name and save your game. Name it "Cog wars advanced" ..

 

 

11. Next, download, save and then use the "choose new sprite from file" button under the stage to import these 8 sprites ..

Cog1.sprite

Cog2.sprite

Cog3.sprite

Cog4.sprite

Cog5.sprite

Cog6.sprite

Cog7.sprite

Game over.sprite

 

 

12. Select the Cog1 sprite. Add the first script ..

 

 

13. The player will control the direction of the Cog1 sprite with the mouse-pointer.

Cog1, and all the other cog sprites, will draw their own path behind them on the stage using pen scripts.

Add the main script to control the movement of Cog1 with the mouse pointer, and determine what will happen when it hits other cogs.

Make sure you sample the cogs main colour (red) and yellow teeth colour ..

 

Press the "B" key on your keyboard to test your game. Move the mouse-pointer around the stage.

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

 

 

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

 

 

15. Select the Cog2 sprite. This sprite will move automatically. Every time Cog1 touches it a point will be lost.

Add the first script ..

 

 

16. Now add the second script. Make sure you sample the cogs main colour and yellow teeth colour ..

Press the "B" key on your keyboard to test your game. The sprite should move around the stage drawing its path behind it.

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

 

 

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

 

 

18. Duplicate (copy) the 2 Cog2 scripts to the remaining cog sprites.

Now on all of the cogs, you must click on the colour square in the "set pen color to" script and then click on the main colour part of the cog sprite to set the correct colour for their paths.

Press the "B" key on your keyboard to test your game.

Check the following ..

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

 

 

19. Select the Game over sprite and add its scripts ..

 

 

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

 

 

21. Well done, you've finished the game. How any points can you earn before the time runs out?