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

Find and fix bugs

Week 25 · Unit 10: Be a game developer · 3 lessons
3

Plan a boat race

Computing 3: Unit 10, pp. 147–160
GoalPlan a two-sprite game with algorithms for each sub-task, then check that the program matches the plan.
New words
plan · to decide what you will do before you startevaluate · to check how well something works, compared with the plancollision bug · a bug where a sprite goes through something it should not
Explanation

Before we make a game, we plan it. We choose a backdrop and the sprites. We decide what each sprite does when the game starts, when a key is pressed and when it is clicked. Then we write an algorithm for each sub-task. Only then do we build the program in Scratch. We test it and debug it. At the end we evaluate it: does the program match the algorithms? Were the algorithms good? In real games, testers also look for collision bugs, where a sprite goes through a wall that it should not.

riverBackdropstartright arrowBlue boatstartD keyRed boatBoat race game
Worked examples
SpriteStarts whenWhat it does
Blue boatgreen flaggo to x: −200, y: 50
Blue boatright arrow keychange x by 30
Red boatgreen flaggo to x: −200, y: −50
Red boatD keychange x by 30
This is the plan for a two-player boat race. Each boat has two sub-tasks. Both boats move 30 steps for each key press, so the race is fair.
PressesBlue boat x
0−200
5−50
10100
13190
Test the plan with numbers. The finish line is at x: 190. A boat needs 13 presses, because −200 + 13 × 30 = 190. After 5 presses of the right arrow, the blue boat is at −200 + 150 = −50, and the red boat is still at x: −200.
The plan saysThe program doesMatch?
blue boat: change x by 30change x by (30)yes
red boat: change x by 30change x by (20)no
Now evaluate. We compare the program with the plan, one line at a time. One line does not match, so we debug it. We also ask: is the game fair, and is it fun?
Class activity

Design your game (in a group): choose a backdrop and two sprites and draw them on paper. Write a plan table like the one in the examples: sprite, starts when, what it does. Give each sprite at least two sub-tasks. Trade plans with another group. They act out your game on the floor: do they get the same result that you planned? Then evaluate: what would make the game fairer or more fun?

Practice
1
Name three events that can start a sub-task in a Scratch game.
2
The blue boat starts at x: −200 and moves 30 steps for each press. Where is it after 6 presses?
Startwhenclickedgo to x:-200y:50Presswhenright arrowkey pressedchange x by30
3
The plan says both boats move 30 for each press. What is the bug in the red boat’s program, and why is the race unfair?
Blue boatwhenright arrowkey pressedchange x by30Red boatwhendkey pressedchange x by3
4
After you build your game, which two things do you compare to evaluate it?