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

Break it into parts

Week 24 · Unit 10: Be a game developer · 3 lessons
1

Break a game into parts

Computing 3: Unit 10, pp. 147–160
GoalBreak a big job, such as making a game, into smaller sub-tasks.
New words
sub-task · a smaller job that is part of a bigger jobdecomposition · breaking a big problem into smaller partsgame developer · a person who designs and builds games
Explanation

A big job is easier when we break it into smaller jobs. A smaller job that is part of a big job is called a sub-task. Breaking a problem into parts is called decomposition. A game developer does this all the time. A game can be split into the part that happens when the game starts and the part that happens when a player clicks a sprite. Each sub-task is easier to follow, to test and to change. Different people can even build different sub-tasks and put them together.

Set up the fieldRun the racesGive out prizesSchool sportsday
Worked examples
go to the bottomsay Ready!When the gamestartsglide to the topsay Wheee!When the kite isclickedKite game
Here is a small kite game. When the green flag is clicked, the kite goes to the bottom of the stage and says “Ready!”. When the kite is clicked, it glides to the top and says “Wheee!”. We split the game into two sub-tasks.
Sub-task 1: the game startsSub-task 2: the kite is clicked
1 When the green flag is clicked1 When this sprite is clicked
2 Go to x: 0, y: −1202 Glide 2 seconds to x: 0, y: 100
3 Say “Ready!” for 2 seconds3 Say “Wheee!” for 2 seconds
Each sub-task gets its own algorithm. Sub-task 1 starts with the green flag and sub-task 2 starts when the kite is clicked.
Sub-task 1whenclickedgo to x:0y:-120sayReady!for2secondsSub-task 2when this sprite clickedglide2secs to x:0y:100sayWheee!for2seconds
Each algorithm becomes its own script. We can change the words in script 1 and the kite still glides in script 2, because the sub-tasks do not depend on each other.
Class activity

Plan a picnic (in a group): write six jobs on slips of paper: pack the sandwiches, pack the drinks, walk to the park, choose a place to sit, put the blanket down, play a game. Sort the slips into three sub-tasks and give each group a title. Compare with another group: did you sort them the same way? Then act out the kite game. One person is the kite, another says “Green flag!” and the kite goes low and says “Ready!”. Another says “Click!” and the kite rises and says “Wheee!”.

Practice
1
Why is it useful to break a big job into sub-tasks?
2
A game has a snail and a bird. At the start the snail goes to x: −150 and the bird goes to x: 100, y: 80. When the space key is pressed, the snail moves 30 steps and the bird says “Tweet!” for 1 second. Break the game into two sub-tasks.
snailbird
3
Which sub-task does this script belong to: “when the game starts” or “when the sprite is clicked”?
when this sprite clickedchange size by10
4
Write the sub-tasks for “getting ready for a swimming lesson” in your own words.