Coding Ireland STEM Report 2024 Have Your Say
Scratch Game
Beginner
60 mins
195 points
What you need:
  • Computer/laptop

Shark Swim

In this game you need to reach the end of the course before the shark catches you.

1 - Create a new Scratch project

Create a new Scratch project and delete the cat sprite.

2 - Create the backdrop

In the game a diver will swim through a course to try and reach the end without touching the edges or getting caught by the shark.

Paint a new backdrop with the following:

  1. A blue background.
  2. A course with lanes for the diver to swim. In our example we use red lines.
  3. A finish line. In our example we use a green line.


3 - Add the Diver1 sprite

Add the Diver1 sprite from the sprite library and then drag it to the start of your swim course.

Once you've positioned it at the start, add the following code to set it up for the start of the game.

when green flag clicked set size to (40) % go to x (-173) y (-138) // the x and y should be the start of your course



4 - Make the diver swim

To control the diver we are going to point her in the direction of your mouse pointer and then make her continually move 2 steps forward. Doing this will make the diver keep on moving towards wherever you put your mouse.

Add the following code to the Diver1 sprite, underneath the go to x: 0 y: 0 block.

when green flag clicked set size to (40) % go to x (-173) y (-138) // add new code under here forever point towards (mouse-pointer v) move (2) steps end



5 - Add the Shark 2 sprite

We are going to make the shark appear in a random position and then animate it to make it bite. It will keep repeating this over and over, move to a random position and then bite.

Add the Shark 2 sprite from the sprite library and give it the following code.

when green flag clicked set size to (40) % hide


Join our club 😃

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

Copyright Notice
This lesson is copyright of Coding Ireland. 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