Student Subscription site screenshot Subscribe now

Subscribe to our Student Site to access all of our Games Coding Lessons for just £8 per month


Scratch game making lesson 133

Scanners

In this lesson you will create a game in which the player must get past rotating scanners to get to the objective. There are 5 Alert levels for the player to get through and each level has more scanners!

 

NOTE: You must use Scratch 3 or higher.

 

Complete these steps ..

 

1. Open Scratch, OR use File > New to create a new game ..

 

 

2. Download, save and then open this game file ..

 

 

3. Select the stage and add this code ..

 

The player will have 2 minutes to reach level 6. We need a variable for the timer and for the levels.

Create these variables ..

 

You can arrange their displays at the top of the stage like this ..

 

Now add this Timer code to the stage ..

Notice how the player will lose if the timer reaches 0.

Press the B key on your keyboard to test your code.

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

 

It would be great to have an alert sounds that gets louder as the Alert level increases.

Add this code to the stage ..

You cannot test this code yet.

 

 

4. This game uses 7 sprites ..

 

Select the Messages sprite.

This sprite has 3 costumes ..

 

Add the code to set its properties before the game begins, and to show the how to play costume ..

 

Now add the code to begin the game when the player clicks on it ..

Press the B key on your keyboard to test your code.

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

 

Now add the code to show the correct costumes when the player either fails to reach level 6 before the timer expires, or succeeds ..

You cannot test this code yet.

 

 

5. Select the Objective sprite.

The player must reach this sprite to level up, and find their way through the maze again with more scanners to get past.

Add the code to set its properties before the game begins ..

 

Now add some code to make it change its colour ..

Press the B key on your keyboard to test your code.

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

 

 

6. Select the Start sprite.

The player will got to this sprite at the beginning of each Alert level, or if the player touches a scanner sprite.

Add the code to set its properties before the game begins ..

Press the B key on your keyboard to test your code.

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

 

 

7. Select the Player sprite.

The player will control this sprite and try to get it to the objective without touching the scanner sprites. Each time the objective is reached the Alert level will increase.

Add the code to set its properties before the game begins ..

 

Add the code to hide the Alert level variable display before the game begins ..

 

Now add the code to set the Alert level variable to 0, and show it, when the game begins ..

 

Now add the code to run each time the level up broadcast is sent.

Note: You will need to colour sample the red end, yellow end, and orange middle of a Scanner to complete the touching colour code blocks ..

Press the B key on your keyboard to test your code.

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

 

Finally add the code to hide the Alert level variable display when the game ends ..

You cannot test this code yet.

 

 

8. Select the A Scanner 1 sprite.

There are three types of scanner. The A scanner 1 sprite has a single scanning ray.

Add the code to set its properties before the game begins ..

 

On the stage, you can drag and place this sprite on any green wall. We placed it here ..

 

Now add the code to show it when the Alert level is 1 or more, and to slowly turn it ..

Note: We prefer that the number of scanners increases as the player levels up, but if you like, you can make this Scanner only appear on Alert level 1 by changing if Alert level > 0 then to if Alert level = 1 then.

Press the B key on your keyboard to test your code.

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

 

 

9. Right-click the A scanner 1 thumbnail under the stage to duplicate it ..

 

Now, move the duplicate sprite (A scanner 2) to a new location on the stage and change the if Alert level > 0 then code block to if Alert level > 1 then.

This second scanner will now appear when the Alert level is 2 or more.

Press the B key on your keyboard to test your code.

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

 

 

10. Repeat the processes described in step 9 for the B scanner and C scanner sprites. You can experiment with ..

 

 

11. Use File > Save to your computer to save your game. Name it Scanners v1.sb3

 

 

12. Well done, you have completed this lesson. Can you add your own ideas to this game?