Shark Attack

This guide has been design to help you create a simple game. Follow these step-by-step instructions to create an interactive game complete with scoring system. Complete the extension tasks to increase the difficulty.

Stage 1 - Making the Background

Select the stage ...

... click on the "Backgrounds" tab then "import" ...

From the backgrounds choose "Nature" ...

... and then find the image called "underwater" Press "OK".

This is what you should se. You can delete the white background if you wish.

Stage 2 - Adding the shark

Click back in the cat (its a "sprite" a graphic that can be given instructions). Change the cat into a shark by clicking on "Costumes" and then "Import" ...

... then from the "animals" folder ...

... choose "shark 1-a"

Press "OK" and the cat will become a shark.

You can now delete the cat constumes that are not needed.

Now add another costume to the shark, "shark 1-b".

Your shark will have two costumes and when the script switches between them the shark will be opening and closing its mouth.

Stage 3 - Writing the script for the shark

Now we need to give the shark its script, the instructions that will make it do things.

By the way, there is a little button highighted in the picture below. Click this to make the shark only face left and right; this will stop the shark from flipping onto its back. Quite a few people have missed this step out, please don't be one of them.

Click on "Control" to see the list of control options and then drag the "When green flag clicked" instruction into the script area.

Now make this script.

When the green flag is clicked a "forever loop" will start.

Inside the loop are a series of instructions.

  • point towards the mouse pointer
  • move 10 steps

These two lines make the shark move towards to position of the mouse pointer 10 steps at a time.

  • next costume
  • wait 0.1 secs

These two lines make the shark change between the mouth open and mouth closed costumes every tenth of a second..

Stage 4 - Adding fish for the shark to eat.

Add a new sprite from the folders.

Choose one of the fish.

Right click on the fish and resize it to make it smaller.

Now add this script for the fish.

This is a repeat until loop that makes the fish move 4 steps at a time. If the fish touches the shark it is hidden.

Change the settings so that the fish can only move from side to side and no longer swims on its back.

Stage 5 - Counting the number of fish that the shark has eaten.

From the variables scripts choose "Make a variable"

Give the variable the name "Eaten".

It needs to be valid for all sprites.

Press "OK".

Now change the script for the fish so that every time it is eaten by the shark the number of fish eaten goes up by 1.

To make life more difficult for the player we need the fish to appear at a random spot and not in the same place every time. Use the "pick random" script. I have shown Y but you need to write X as well.

Notice that I have added the random value for x here.

Now make the fish reappear 2 seconds after it has been eaten by putting the completed script inside a forever loop (to make it repeat) and add a wait of 2 seconds at the end.

Right click on the sprite and select "duplicate" to make more fish. You may wish to make the different sizes.

Stage 6 - Adding the octopus

To make the game more difficult add an octopus that will set the score to 0 if the shark eats it by mistake. The octopus has two costumes to import.

Here is the script for the octopus.

Now you can play the game.

Stage 7 - Making the game more difficult

You can make it more difficult by adding a different fish that travels vertically, scores 10 and can only appear once.

How might you get the game to decide when the player has won, say by eating 20 fish?

You can add another fish that makes a prey fish vanish so the shark has less to eat.

How might you set a time limit on the game?

Use project 2 to make the shark change colour as it moves about.

Don't forget to save your project as "Shark Attack" when it is complete.

Recent Posts

July 24

Repairing a hyperspace window

Phasellus quam turpis, feugiat sit amet ornare in, hendrerit in lectus semper mod quisturpis nisi consequat etiam lorem. Phasellus quam turpis, feugiat et sit amet ornare in, hendrerit in lectus semper mod quis eget mi dolore.

July 18

Adventuring with a knee injury

Phasellus quam turpis, feugiat sit amet ornare in, hendrerit in lectus semper mod quisturpis nisi consequat etiam lorem. Phasellus quam turpis, feugiat et sit amet ornare in, hendrerit in lectus semper mod quis eget mi dolore.

July 14

Preparing for Y2K38

Phasellus quam turpis, feugiat sit amet ornare in, hendrerit in lectus semper mod quisturpis nisi consequat etiam lorem. Phasellus quam turpis, feugiat et sit amet ornare in, hendrerit in lectus semper mod quis eget mi dolore.

Spotlight

Neural Implants

The pros and cons. Mostly cons.

Phasellus quam turpis, feugiat sit amet ornare in, hendrerit in lectus semper mod quisturpis nisi consequat ornare in, hendrerit in lectus semper mod quis eget mi quat etiam lorem. Phasellus quam turpis, feugiat sed et lorem ipsum dolor consequat dolor feugiat sed et tempus consequat etiam.

Lorem ipsum dolor quam turpis, feugiat sit amet ornare in, hendrerit in lectus semper mod quisturpis nisi consequat etiam lorem sed amet quam turpis.