GoalWrite an outline plan for a program by listing its purpose, its events and the expected outcome of each event.
New words
purpose · what a program is forevent · something that happens and starts a script, such as a click or a key pressoutcome · the result of an event; what the program doesoutline plan · a short plan that gives the purpose, the events and their outcomes
Explanation
Before we write blocks, we write an outline plan. It has three parts. The first part is the purpose of the program: what it is for. The second part is the list of events. An event is something that happens and starts a script, such as the green flag being clicked, a sprite being clicked, a key being pressed or a backdrop changing. The third part is the expected outcome of each event, which tells what the sprites do. A plan helps us to see the whole program before we start. It also gives us a list to check when we test the finished program.
purpose→events→outcomes
Worked examples
Here is a story program with a Rocket and an Astronaut and two backdrops, Sky and Moon. Its purpose is to tell a short story in which a rocket reaches the moon. There are four events: the green flag, a click on the Rocket, the backdrop switching to Moon, and a click on the Astronaut.
Event
Sprite
Expected outcome
1 green flag clicked
Rocket
backdrop is Sky; says ‘Ready for launch!’ for 2 seconds
1 green flag clicked
Astronaut
hides
2 Rocket clicked
Rocket
glides for 2 seconds to the top; backdrop changes to Moon
3 backdrop switches to Moon
Astronaut
shows; says ‘We made it!’ for 2 seconds
4 Astronaut clicked
Astronaut
plays a pop sound and hides
The plan lists each event with its outcome. The green flag has two outcomes, one for each sprite.
An outcome can start another event. When the Rocket changes the backdrop to Moon, this is the event that starts the Astronaut’s script. The plan shows the chain: event 2 leads to event 3.
Class activity
Plan a play (2 to 4 players, paper). Choose a short story with two characters and two scenes, such as a farm in the morning and a farm in the evening. Write the purpose. Write four events, for example ‘the scene card is turned’ or ‘a character card is tapped’. For each event write what the characters say or do. Then act the play: one player reads out each event in turn, and the others carry out the outcomes. Does the plan work? Is any event missing?
Practice
1
Which of these are events? (a) the green flag is clicked, (b) say Hello! for 2 seconds, (c) the space key is pressed, (d) move 10 steps.
(a) and (c). They start a script. (b) and (d) are steps that a script carries out.
2
Write the purpose of a program in which a cat says ‘Meow!’ when it is clicked and the backdrop then changes to Night.
For example: to show a cat that meows when clicked and to change the scene to night. Accept any sensible purpose.
3
A sea program has a Fish and a Crab. When the green flag is clicked, the Fish goes to the middle of the stage. Each press of the space key makes the Fish move 10 steps. When the Crab is clicked, it says ‘Hello, Fish!’ for 1 second. Complete the outcomes in the plan.
Event
Sprite
Expected outcome
green flag clicked
Fish
?
space key pressed
Fish
?
Crab clicked
Crab
?
Green flag: the Fish goes to x: 0, y: 0. Space key: the Fish moves 10 steps. Crab clicked: the Crab says ‘Hello, Fish!’ for 1 second.
4
In the rocket plan, which event is not started by the player? What starts it?
Event 3, ‘backdrop switches to Moon’. The Rocket’s click script starts it when it switches the backdrop.