Shark Fishing Game

Code helper imageStep 7 – Keeping score

We'll need a way to keep score - don't worry, we'll give the Shark more Fish to catch in a bit!

  1. Set up a Variable called score – click Make a variable in the dark orange Variables section

    Make sure that you call your variable something obvious like score

Variables are simply named areas of computer memory where we can store a value.

In this case, we want to store the score – how many fish our shark has caught.

We need to add some blocks in to deal with the score as the shark catches the fish.

  1. Add code to change the score variable by 1 when the fish is eaten – this goes below the Hide block inside the IF – THEN

    Code helper imageMake sure you change to your score variable using the drop down

  2. You’ll also need to set the score variable to 0 at the start of the game – so add an orange set variable to 0 block right at the top of the Fish code.

    Change myvariable to score again

  3. Code helper imageIMPORTANT: add an orange Wait 1 second block underneath the Set score to 0 block.
    Sometimes the Fish will appear under the Shark which will catch them straight away – which means the score will never get as high as it should do...

This is all quite tricky. Just make sure you use the score variable each time, not the myvariable one that already exists.

Check that the game works. Makes sure that the score goes back to 0 when you start the game again.