An environmentally-conscious game

By Marc Scott. Posted

Save the Shark is a fun new project from the Raspberry Pi Foundation that introduces learners to gaming while also teaching them about the environment

Save the Shark is a digital game in an exciting new Raspberry Pi Foundation series of projects. The series aims to show learners how they can protect the environment using the power of technology, and draws on several of the United Nations’ 17 Sustainable Development Goals (SDGs), with Save the Shark engaging with two of the goals in particular: Life Below Water and Responsible Consumption and Production.

In this activity, learners create a game in Scratch in which they have to save the shark by eating fish and avoiding rubbish. The project explores relevant environmental themes such as sharks’ food sources and the negative impact of plastic in the ocean.

Although it has a serious theme, Save the Shark is a fun project that introduces learners to game building while also educating them about the environment. Using step-by-step instructions, learners are introduced to key computing concepts such as selection, variables, and random numbers.

Age range: 7–10 years

Year group: Years 4–6

Lesson type: Visual/block-based coding


  • A computer or tablet capable of running Scratch

  • Scratch 3 (either online or offline)


  • How to use random numbers to change costumes

  • How to generate and delete clones

  • How to use random numbers to alter the behaviour of clones

Activity 1: Move the shark 

15 minutes

In this step you will learn how to use code to control the motion of a shark on the screen using the mouse. If you are working online, open the starter project in Scratch. If you are working offline, open the project starter file in the Scratch offline editor.  

In the starter project, you should see a shark sprite against an underwater background. When the green flag is clicked, the shark should start at the bottom of the screen.

To make this project mobile-friendly, you’re going to use the location of the cursor when the left mouse button is pressed, or when a finger touches the screen, to control the movement of the shark.

Add a forever loop to your script so that your program can constantly detect when the left mouse button is clicked, then use an if... then block to detect if mouse down — see figure 1.

Figure 1

When the mouse is clicked, if the mouse x position of the cursor is less than the x position of the sprite, then the sprite should change x by -10, so that it moves left. Add the following blocks, as shown in figure 2.

Figure 2

Click on the green flag to run the program and test that the shark does move to the left.

If the mouse x position of the cursor is greater than the x position of the sprite, then the sprite should change x by 10, so that it moves to the right. Add the following blocks, as shown in figure 3.

Figure 3

Click on the green flag to run the program and test that the shark does move to the right.

Activity 2: Plastic waste

15-20 minutes

You should see a sprite that looks like a plastic bottle in your sprites pane beneath the stage. This sprite has four costumes: a bottle, a wrapper, a bag, and a can holder. 

When the flag is clicked, this sprite needs to move to the top of the screen and then hide itself. Add the code as shown in figure 4. 

Figure 4

The plastic sprite should now randomly generate clones of itself. See figure 5.

Figure 5

When a clone is created, it should show itself, pick a random costume, and then move to a random x position. Add the code shown in figure 6 as a new script.

Figure 6

You want the speed at which the plastic moves towards the bottom of the screen to be random, so create a new variable called speed.

Set the speed to be a random number, and then move the clone down the stage using the speed variable. See figure 7.

Figure 7

Run your game, and you should see plastic waste falling from random positions and at random speeds from the top of the screen. The problem is that the waste accumulates at the bottom of the screen, and stays there. Add blocks to detect when the plastic sprite touches the bottom of the screen, and then deletes itself. See figure 8.

Figure 8

Activity 3: Shark Health

15-20 minutes

In this step, you are going to include health points using a variable. The health of the shark will reduce if it accidentally eats plastic waste.

Create a new variable called health.

On the shark sprite, when the game starts, the shark’s health should be set to 20, and then when the health gets below 0, the game should end. See figure 9.

Figure 9

Back on the plastic sprite, add some code to reduce the shark’s health if it accidentally eats any of the plastic. See figure 10.

Figure 10

Run the program again to test that the health of the shark reduces if it eats plastic.

Activity 4: Feed the shark

15-20 minutes

Now, when you play the game, the shark needs to avoid the plastic, or the game will end because the shark’s health has decreased. In this step, you’ll add fish that the shark can eat in order to increase its health.

Add the fish sprite to your project. The code for the fish sprite is almost identical to the code for the plastic sprite. Drag and drop the three scripts from the plastic sprite onto the fish sprite in the sprites pane.

Fish sprite

Now you can edit the code that reduces the shark’s health, so that it increases the health instead. See figure 11.

Figure 11

Run the program again to test that the health of the shark increases if it eats fish.


More advanced coders could add different fish that give the shark increased health, and adjust which plastics hurt the shark the most. Less advanced coders could be provided with a more complete starter project with a few blocks missing.

For further information and more projects visit



If you’re a UK-based teacher, volunteer, librarian or something in between, we'll send each issue free to your door.



Just want to read the free PDF? Get each new issue delivered straight to your inbox. No fuss and no spam.


From £6

If you are UK-based but not involved in education, you can get hard copies by buying back issues or subscribing via our partner service.