SCRATCH GOLD II
SCRATCH GOLD I
2 of 3

1.05 Multiple levels

So far, the player only has to remember a sequence of five colours. Improve your game by adding a score, and adding code so that as the player scores points, the game moves to the next level and the colour sequence to remember becomes longer.

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

Based on the score, the game will decide on the length of the colour sequence. Start with a score (and a sequence length) of 3.

Add a block at the start of your character’s when flag clicked code to set the scoreto 3.

Instead of always creating a sequence of five colours, you now want the score to determine the sequence length.

Change the character’s repeat loop (for creating the colour sequence) to repeat score times:

sprite

If the player repeats the correct sequence, you should add 1 to score, and doing so increases the length of the next sequence. Add the following block to the character’s code at the point you know the sequence is correct:

sprite

Finally, add a forever loop around the code that generates the sequence, so that the game creates a new colour sequence for each level. This is how your character’s code might look:

ballerina

Get your friends to test out your game. Remember to hide the sequence list before they play it!

×
×

Cart