SCRATCH GOLD II
SCRATCH GOLD I
2 of 3

8.06 Adding a score

Let’s make things more interesting by keeping score.

To keep the player’s score, you need a place to put it. Create a new variable called score.

  • Click on Variables in the Code tab, then click on Make a Variable.Variable blocks
  • Type in the name of your variable. You can choose whether you would like your variable to be available to all sprites, or to only this sprite. Press OK.
  • Create variable
  • Once you have created the variable, it will be displayed on the Stage, or you can untick the variable in the Scripts tab to hide it.Variable on the stage

When a new game is started (by clicking the flag), you should set the player’s score to 0. Add this code to the top of the balloon’s when flag clicked code:

balloon sprite

Whenever a balloon is popped, you need to add 1 to the score:

balloon sprite

Run your program again and click the balloon. Does your score change?

×
×

Cart