Mathematics Scratch Game
Expert
90 mins
290 points
What you need:

Space Shooter

In this lesson we will control a spaceship with your mouse and shoot down balloons that randomly appear on the screen. We'll use variables to keep track of your score and how many lives you have left.

1 - Create a new Scratch project

Create a new Scratch project and delete the cat sprite.

https://scratch.mit.edu

2 - Add the Stars backdrop

Open the backdrop library and add the Stars backdrop to your project.


3 - Create 'score' and 'lives' variables

Each time you shoot a balloon you'll get a point and each time a balloon touches your rocketship you'll lose a life. To keep track of these we need to create two new variables, one called 'score' and one called 'lives'.

In the Data palette, create two new variables by clicking the 'Make a Variable' button.

  1. 'score' this will store your score
  2. 'lives' this will store your lives

When you create your first variable you will notice that new blocks for variables become available to use in the Data palette.

4 - Setup the variables

At the start of the game we should have 0 points and 3 lives. Add the following code to the stage to setup your variables for the start of the game.

when green flag clicked set [score v] to (0) set [lives v] to (3)

5 - Add the Rocketship sprite

Open the sprite library and add the Rocketship sprite to your project.

Once you've added the Rocketship sprite we need to edit which way it is pointing to make it point to the right. Click on the 'Costumes' tab to open the sprite editor and follow these steps:

  1. Click on the Select tool (the arrow button).
  2. Hold down the left mouse button and draw a box over all the rocketship. This selects it and a box appears around it.
  3. Drag the small arrows at the bottom of the box around so that the rocketship points to the right.
  4. Click on the 'Scripts' tab to go back to your code. 


Join our club 😃

To view the remaining 10 steps and access hundreds of other coding projects please login or create an account.

Copyright Notice
This lesson is copyright of . Unauthorised use, copying or distribution is not allowed.

Scratch is developed by the Lifelong Kindergarten Group at the MIT Media Lab. It is available for free at https://scratch.mit.edu
🍪 Our website uses cookies to make your browsing experience better. By using our website you agree to our use of cookies. Learn more