Week 24 · Unit 10: Be a game developer · 3 lessons
1
Plan a game
Computing 6: Unit 10, pp. 134–149
GoalBreak a game idea into elements and sprites, and write what each sprite must do.
New words
game element · a feature that makes a game work or fun, such as a goal, scoring, time, levels or a storysprite · a character or object in a Scratch projectdecomposition · breaking a big problem into smaller parts that are easier to solvecriteria · a list of things that a sprite or a program must do
Explanation
A game is much easier to build when it is planned first. Start with the big idea: who plays, and what is the goal? Games are made from elements such as a goal, scoring, time, levels, a story and competition. Next use decomposition and split the game into parts, with one part for each sprite. For every sprite write criteria, which say exactly what it must do. Then write an algorithm for each sprite, as a flowchart or as steps. Good games for a class are about catching, collecting, racing or dodging, not about hurting anyone. Build one sprite at a time and test it before you start the next.
Sprite
Its job in ‘Sea clean-up’
Diver
moves up and down with the arrow keys
Bottle
drifts in from the right; the diver collects it to score a point
Timer
counts down from 30 seconds; the game ends at 0
Worked examples
Element
In ‘Sea clean-up’
goal
collect 10 bottles
scoring
1 point for every bottle
time
30 seconds on the clock
levels
level 2: the bottles drift faster
story
the sea is dirty and the diver cleans it
Here are the five game elements for the ‘Sea clean-up’ game. Each one answers a different question about the game.
These are the criteria for the Bottle sprite, and the script that meets them. It starts at the right edge at a random height and drifts left. If the diver touches it, the score goes up by 1 and a new bottle appears on the right. A bottle that reaches the left edge also starts again on the right.
Decomposition gives each sprite its own small job. A big game is then a set of small programs that work together.
Class activity
Paper game plan (no computer): choose a game idea about catching, collecting, racing or dodging. Fill in a plan sheet with the five elements: goal, scoring, time, levels and story. Draw the stage on a large sheet and cut out three paper sprites. Write two criteria for each sprite on its back. A friend reads the criteria aloud while you move the paper sprites to play one round. Did the plan have a gap? If you have a computer or tablet, build the first sprite in Scratch and test it.
Practice
1
‘Bus dash’: the player drives a bus and collects passengers before a clock reaches zero. Each passenger scores 2 points. Name the goal, the scoring and the time element.
For example: goal – collect as many passengers as possible (or a target number); scoring – 2 points for each passenger; time – the clock that counts down to zero.
2
The plan for ‘Kite collector’ has one job missing. Write a good job for the Star sprite so that the game has a score.
Sprite
Job
Kite
moves in four directions with the arrow keys
Star
?
Cloud
the kite loses a life when it touches a cloud
For example: the Star appears at a random place. When the kite touches it, the score goes up by 1 and the star jumps to a new random place.
3
Break a memory-quiz game into three parts. Say what each part does.
For example: a Question sprite shows a question; an Answer sprite checks the answer and gives feedback; a Scoreboard sprite adds a point for each right answer.
4
Why is it better to test each sprite when you build it, and not only at the end?
If a bug is found in the one sprite that was just built, it is easy to find. At the end there are many scripts, and a bug could be in any of them.