Coding a game with variables worksheet for Years 5–6: Build a game

Members Chapter 5 of Variables in Coding: Build Scores and Timers with Bit · Year 5, Year 6 · 3 pages · PDF, A4

All 5 worksheets in this game

One for each chapter

Build a Game is a printable coding worksheet for Years 5 and 6 (ages 9 to 11) that brings variables, repeat loops, if blocks, inputs and outputs together in one game called Star Catcher. It follows the national curriculum in England for Key Stage 2 computing: use sequence, selection and repetition in programs, and work with variables and various forms of input and output.

  • 3 A4 pages
  • Answers sheet
  • About 30 minutes
  • Colour or black and white
  • National curriculum

For members Membership opens every worksheet and every game. Already a member? Log in

Start with the free one: What is a variable? (chapter 1).

The game for this worksheet Variables in Coding: Build Scores and Timers with Bit Chapter 5 · Build a game with a score, a timer, inputs and outputs · read aloud ▶ Play chapter 5 in the gameChapter 1 is free

Print it on A4, in colour or black and white. Do it after the chapter, or before it to see what your child already knows.

What's on the worksheet

Plan and debug a game that uses a score, a timer, inputs, outputs, loops and if blocks together. Includes a plan-and-play-test activity, a bug hunt in block code and an answers sheet.

Page 1 · Learn
The full Star Catcher code with a name, a score and a 30-second timer, a list showing where each coding idea appears, Flip's tip on planning variables and a warm-up.
Page 2 · Try it together
Plan and play-test: plan a sock-throwing game with three variables and an if rule, then play it with the grown-up acting as the computer.
Pages 2–3 · Practise
Match game parts to coding ideas, trace a score through stars and a bomb, find and fix three bugs in Leo's game, and write an if block for a new record.
Answers sheet
Every answer by page, what to watch out for (forgetting to reset, a timer counting the wrong way) and ideas to go further.

3 A4 pages and an answers sheet · about 30 minutes

Using it at home

  • In the play-test, follow the plan exactly, like a computer. If the plan forgot to reset the score, play twice and see what happens.
  • Let your child explain each line of Star Catcher in their own words before starting the bug hunt. The sheet takes about 30 minutes.

Watch out for

Forgetting to set a variable back to its starting value when a new game starts.
Every variable that changes during a game needs a set block under when game starts.
Showing a word instead of a value, like say "score".
Text typed in the white space shows the word itself; the variable block shows the number stored.

Questions from the worksheet

  1. A new game starts and score is set to 0. The player catches a star, catches a star, hits a bomb and catches a star. What is the final score?
  2. Leo's game has 3 bugs. Find and fix them.
  3. Write an if block: if the score is more than 15, say "New record!"
  4. Ava says, "I don't need set score to 0. Variables start at 0 anyway." Is she right?

The answers are on the answers sheet, for grown-ups.

National curriculum in England

This worksheet practises this statement from the Years 3–6 computing programme of study:

  • Use sequence, selection, and repetition in programs; work with variables and various forms of input and output

Source: National curriculum in England: computing programmes of study (DfE)

In the classroom

  • Use Leo's buggy code as a pairs debugging task, then compare fixes as a class.
  • Let groups plan a game on the variable table, then swap plans and play-test each other's.

Questions and answers

What coding ideas do you need to make a simple game?

Most simple games use variables (such as score and timer), repetition to count down, selection to make decisions, inputs from the player and outputs on the screen.

How do you find bugs in block code?

Trace the code one block at a time and write down each variable's value. Check that every variable has a starting value and changes the right way.

More worksheets from Variables in Coding: Build Scores and Timers with Bit

More Year 5 technology worksheets

One for every chapter of every game, with answers.

Browse them →