
Following on from our earlier discussions about the history
of computer games and our explorations of the Scratch software last week to
create a simple Etch-a-Sketch game, this week it was time for Year 5 to develop
their understanding of programming concepts by learning how to use a new
selection of command blocks. To do this, I decided to teach them how to create
a simple racing car game in the software and without any shadow of a doubt I
can honestly say that they all absolutely loved it – it was one of those
lessons which both the children and I didn’t want to end!
Before they started, we had a talk about the different
elements of a controllable system and used a flow chart to apply this to a
Scratch computer game which triggers responses depending on what keys have been
pressed on a keyboard.
- an input device transfers information from the outside world
into the computer;
- the computer processes the information entered using a
control program;
- the control program responds by producing an output.
Having done this, I then showed the children how to design
their cars and racetracks. Now, having done this lesson last year I knew not to
spend too long on this section since it would otherwise waste the precious
game-playing time later. I therefore opted to guide the class step-by-step
through the processes that they needed to follow. Like last time, I asked them
all to load up the same game template I created containing the familiar
LOGO-type triangle as the main character to move. The two things that they had
to do were:
- to paint a racetrack by filling the stage background in
green, using a thick grey brush to draw a road with a few bends in from one
side of the screen to the other and by using the straight line tool to then
draw a finish line at one end;
- to paint a racing car by editing the sprite character using
the eraser and brush tool until it looked like below, ensuring to: use the zoom
tool to zoom out so that the painting area matched the stage screen size, set the
rotation centre for the sprite as the middle of the car and use the ‘shrink’
tool if necessary to shrink the size of the car if it was too big to be able to
fit comfortably on the race track road.
Following this, they could then begin programming their
game on their own. I provided them with a set of commands which they seemed to work fairly
well to copy into Scratch, with a few reminders from me to encourage them to
frequently test to check that they worked expected and if not, to make any
required modifications. The principles behind this code are quite
straightforward – the car gets placed at the start of the track when the green
flag is pressed and can then be moved around when different arrow keys are
pressed on the keyboard.

To teach them how to use
conditional statements, I also
included some ‘IF’ statements for them to put in to enhance their game-playing
experience – notably to move the car back to the start IF it touches the grass
(and goes off the road) and to say a short ‘well done’ message IF it touches
the finish line (and complete the race track). For the geeks out there, for
information, running several stacks of commands at the same time like this in
the game is an example of
parallel execution, although I didn’t feel the need
to actually teach this term. To challenge the more confident children, I also
tried to get them to add a timer to their game which would time each race and
display it when the finished line is reached.

This lesson took exactly an hour and by the end of it all
the children were impressed with what they had achieved. If we would have had
longer I perhaps would have given them some time to go back and improve the
appearance of their race track backgrounds (e.g. adding details like trees and
spectators) or to possibly add some sound effects, however I do think that what
they managed in the end was pretty good. Yet again, I’ve been given more
evidence to prove that primary school children can be taught programming and
absolutely thrive at the opportunity to learn how to produce their own games,
including the challenges involved in debugging their projects.
This is a good tool to get kids and beginners introduced to the basic concept of game programming. I use scratch in my computers class to teach HS kids these fundamentals.
Posted by: Game Programming | 17 November 2010 at 08:01 PM
I'm planning to use an adapted version of this at an interview lesson on Monday.
A couple of things that I'm changing though to make it a little more efficient/easier to explain are as follows:
Put a forever in the first when click green flag instruction and have 'move [2] steps' in this instruction. This means that I get rid of the Up/Down commands and only have rotate and not move in the left/right commands.
As an extension I later put in a variable of speed that can be changed with +0.2 for Up and -0.2 for Down so students get acceleration and changing of variables (very high ability).
With the 'Say timer' command you may want to put that above the 'Say Well done' command. This means that you won't have to put the minus 2 section into the code (Unless you did this intentionally to show the students operators).
Thank you for all of your resources Simon, there are so many amazing lessons on here that I use as regularly as I can to help enthuse and enhance the students learning.
Posted by: Chris Andrews | 20 April 2013 at 09:46 AM