GoalTurn each event of an outline plan into a small script and check that every event has one.
New words
subprogram · a small script that is part of a larger program; it carries out one event’s outcomehat block · the block at the top of a script; it names the event that starts the scriptscript · a stack of blocks that start with a hat blockcheck · to look again to see that nothing is missing or wrong
Explanation
Each event in the plan becomes a subprogram: a small script that starts with a hat block for that event. The green flag becomes ‘when green flag clicked’. A click on a sprite becomes ‘when this sprite clicked’. A key press becomes ‘when space key pressed’, and a message becomes ‘when I receive’. A change of backdrop becomes ‘when backdrop switches to’. The blocks under the hat are the outcome. A script belongs to one sprite, so select the right sprite before building it. When all scripts are built, tick each row of the plan, and test each event one at a time.
Event in the plan
Hat block
the green flag is clicked
when green flag clicked
a sprite is clicked
when this sprite clicked
a key is pressed
when [space] key pressed
a message arrives
when I receive [message1]
the backdrop changes
when backdrop switches to [backdrop1]
Worked examples
The Rocket needs two scripts, one for the green flag and one for its own click.
The Astronaut needs three scripts: one for the green flag, one for the backdrop and one for its own click. It starts hidden. Then it shows when the backdrop switches to Moon.
A script must be on the right sprite. If the ‘when this sprite clicked’ script for the Rocket is put on the Astronaut by mistake, nothing happens when the Rocket is clicked. Always select the sprite first, then build its scripts.
Class activity
Script cards (3 or 4 players). Cut the plan table into strips. Make a hat-block card for each kind of event. Match every strip to a hat-block card and to a sprite. Then act out the program. One player is the stage manager who reads out the events in order: green flag, Rocket clicked, and so on. The other players are the Rocket and the Astronaut and say or do the outcomes. Swap two strips. Which scripts no longer work? If you have a computer or tablet, build the rocket program in Scratch.
Practice
1
Choose the hat block for each event: (a) the green flag is clicked, (b) the player clicks the sprite, (c) the space key is pressed, (d) the backdrop changes to Moon.
Event
Hat block
a
?
b
?
c
?
d
?
(a) when green flag clicked. (b) when this sprite clicked. (c) when [space] key pressed. (d) when backdrop switches to [Moon].
2
Which sprite should have the script ‘when backdrop switches to Moon: show, say We made it!’? Why?
The Astronaut. It is the Astronaut who must appear and speak, and a script runs on the sprite that it belongs to.
3
Complete the algorithm for the Astronaut’s click.
Step
Instruction
1
?
2
?
3
?
1 Start program when this sprite is clicked. 2 Start sound Pop. 3 Hide.
4
In the lesson’s rocket program, the player clicks the flag, then the Rocket, then the Astronaut. What do you see at the end?
The backdrop is Moon, the Rocket is at the top of the stage, and the Astronaut has hidden after the pop sound.