AdvertisementYour brand could be hereYour brand hereOn every Darslab page · students, parents and teachersinfo@darslab.comAsk for pricesPricesinfo@darslab.com
☰ Year plan · Computing

Plan before you code

Week 9 · Unit 4: Be a storyteller · 3 lessons
2

Purpose, events and outcomes

Computing 5: Unit 4, pp. 44–57
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.

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.
EventSpriteExpected outcome
1 green flag clickedRocketbackdrop is Sky; says ‘Ready for launch!’ for 2 seconds
1 green flag clickedAstronauthides
2 Rocket clickedRocketglides for 2 seconds to the top; backdrop changes to Moon
3 backdrop switches to MoonAstronautshows; says ‘We made it!’ for 2 seconds
4 Astronaut clickedAstronautplays a pop sound and hides
The plan lists each event with its outcome. The green flag has two outcomes, one for each sprite.
click: glide, backdrop = Moonbackdrop switches to Moon: show, say
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) green flag is clicked(b) say Hello! for 2 seconds(c) space key is pressed(d) move 10 steps
2
Write the purpose of a program in which a cat says ‘Meow!’ when it is clicked and the backdrop then changes to Night.
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.
EventSpriteExpected outcome
green flag clickedFish?
space key pressedFish?
Crab clickedCrab?
4
In the rocket plan, which event is not started by the player? What starts it?