Scratch game making tutorial 89

Minesweeper

In this tutorial you will make a game in which a minesweeper ship must destroy as many mines as possible before it is sunk.

Complete these steps ..

 

1. Create a new game (From the top menu choose File>New).

 

2. Right-click and delete the cat sprite.

 

3. Save the following sprites (images) to your computer and then import them into your game using the "Choose new sprite from file" button under the stage ..

 

4. Save the following 2 background images to your computer and then import them onto the stage using the "Import" button in Stage>Backgrounds ..

 

5. Create the following variable ("for all sprites") and hide all but "ship health" and "mines destroyed" (un-tick) ..

 

5. Save your game using File>Save as. Call it "Minesweeper".

 

6. Now add these scripts to the stage ..

 

7. Add these scripts to the "Instructions" sprite ..

 

8. Add these scripts to the ship ..

NOTE: You will need to complete the touching script block when you have scripted and duplicated "Mine 1".

Also, notice how the ship points and moves towards the mouse to allow the player to control it, and also that the variable "ship direction" always holds the direction that the ship is pointing.

 

9. Save your game again this time time using File>Save.

 

10. We want the gun Turret to rotate relative to the ships position. Add these scripts to it ..

Notice how the we have used the right and left arrow keys to rotate the turret, and a variable named "turret direction" to record the direction value/angle. The "point in direction" script block combines the "ship direction" value with the "turret direction" value to set the rotational angle of the turret, thereby ensuring it always retains its rotational position relative to the ship.

 

11. Now add the standard firing scripts for the Shell using the same point in direction block that the turret uses ..

 

12. Save your game again this time time using File>Save.

 

13. Finally, add these scripts to "Mine 1" ..

Notice how "mine speed" increases by 0.2 steps whenever it re-spawns.

 

14. Duplicate "Mine 1" and name it "Mine 2". Go back and complete the touching script block on the Ship.

 

15. You're done! Save your game again then press "B" or click the Green Flag to start your game and test it. Use the mouse to direct your ship and avoid the mines, the left and right arrow keys to point your turret and the space-bar to fire at the mines.

 

16. Can you improve the game? How about adding more mines?