SCRATCH GOLD II
SCRATCH GOLD I
2 of 3

1.02 Create a colour sequence

Open a new Scratch project.

Online: open a new online Scratch project at scratch-new.

Choose a character sprite and a backdrop. You could use the ballerina, but your character doesn’t have to be a person, they only need to be able to show different colours.

screenshot
  • Your game should use a different number to represent each colour:
    • 1 = red
    • 2 = blue
    • 3 = green
    • 4 = yellow

Give your character four costumes that have different colours, one costumes for each of the four colours shown above. Make sure that your coloured costumes are in the same order as the list above.

screenshot

If you want, you can use the color a shape tool to fill parts of the costume with a different colour.

color-a-shape

Next, add a list for storing the random sequence of colours that the player has to remember.

Create a list called sequence. Only the character sprite needs to see this list, so you can select For this sprite only when you create the list.

  • Click on Make a List under Variables.
Make a list
  • Type in the name of your list. You can choose whether you would like your list to be available to all sprites, or to only a specific sprite. Click OK.
List name
  • Once you have created the list, it will be displayed on the stage, or you can untick the list in the Scripts tab to hide it.
List show/hide
  • Click the + at the bottom of the list to add items, and click the cross next to an item to delete it.
List show/hide
  • New blocks will appear and allow you to use your new list in your project.
List blocks

You should now see lots of new code blocks for using lists. The empty list should be visible in the top left-hand corner of the Stage.

screenshot

Each colour has a different number, so you can choose a random colour by randomly choosing a number and adding it to the list.

Add this code to the character sprite to choose a random number and add it to sequence:

ballerina

Test your code. Check that, each time you click the flag, a random number between 1 and 4 gets added to the list.

Can you add code to your program to generate five random numbers at once?

Each time a number gets added to the list, the character should change its costume so the costume’s colour matches the number. Put these blocks into your code immediately below where a random number is added to sequence:

ballerina
×
×

Cart