Look at this race track from above. Imagine it as a Scratch backdrop: a grey road, green grass and a finish line. Could you program a car that you steer with the arrow keys, that gets sent back if it drives onto the grass, and that tells you your lap time? By the end of this post, you can.

Image source: File:Circuit of the Americas, April 22, 2018 SkySat (cropped2).jpg (Wikimedia Commons)
In this post:
- How a keyboard controls a game
- Four new tools: the timer, reset timer, touching colour and sounds
- Step-by-step plan for a car racing game
- Play a car racing game in this post and see its scripts light up
- Group project checklist, a matching activity and a quiz
Brainstorm: keys that control games
With your group, list games you know and the keys they use. Common choices: arrow keys to move or steer, W A S D for a second player, space to jump or shoot. For a racing game, the up arrow could move forward and the left and right arrows could turn. What should happen when the car leaves the road? How will the player know their time?
New tools for games
| Block | Category | What it does |
|---|---|---|
| timer | Sensing | Counts the seconds since the project started or since it was last reset. Tick it to show it on the stage. |
| reset timer | Sensing | Sets the timer back to 0, for example when a race starts. |
| touching color [ ]? | Sensing | True when the sprite touches that colour. Click the colour box, then use the dropper to pick a colour from the stage. |
| start sound [ ] / play sound [ ] until done | Sound | Plays a sound. start sound lets the script carry on at once; play sound until done waits until the sound finishes. |
Plan: a car racing game
Step 1 – Backdrop: paint a track. Make the road one colour (grey) and everything off the road another colour (green grass). Add a finish line across the road as a separate, thin sprite.
Step 2 – Car sprite: paint a small car from above, or choose one from the library. Make it point to the right in its costume so that direction 90 means “forward”.
Step 3 – Steering: the up arrow moves forward and the left and right arrows turn:
when [up arrow] key pressed
move (10) steps
when [right arrow] key pressed
turn ↻ (15) degrees
when [left arrow] key pressed
turn ↺ (15) degrees
Step 4 – Off the track: when the car touches green, send it back to the start and play a crash sound:
when green flag clicked
go to x: (start x) y: (start y)
point in direction (90)
forever
if <touching color [green]?> then
start sound [crash]
go to x: (start x) y: (start y)
Step 5 – Timing: reset the timer at the start and show the time at the finish line:
when green flag clicked
reset timer
forever
if <touching [Finish line]?> then
say (join [Your time: ] (timer)) for (2) seconds
stop [all]
Step 6 – Sounds: add a sound when the race starts, when the car crashes and when it finishes.
Step 7 – Instructions and game over: have a sprite say the instructions at the start. Decide when the game ends: when the car finishes, or when the timer passes a time limit.
Activity: race!
Try it: drive one lap
Click the green flag button, then click the track and drive with the arrow keys (or hold the on-screen buttons). The scripts on the right light up when they run. Can you get round without touching the grass? What is your best time?
Scripts running now
when [up arrow] key pressed move (10) steps when [right arrow] key pressed turn ↻ (15) degrees when [left arrow] key pressed turn ↺ (15) degrees forever if <touching color [green]?> then start sound [crash] go to x: (start) y: (start) if <touching [Finish line]?> then say (join [Your time: ] (timer))
timer: 0.0
This game was written in JavaScript so it can run inside this page, but it follows exactly the same plan as the Scratch scripts above: keys move and turn the car, a forever check on the colour under the car sends it back to the start, and the timer is reported at the finish line.
Watch: make a race game in Scratch
This tutorial walks through building a race game in Scratch. Pause it often and build along with it.
Video: How to Make a Race Game in Scratch [15 Min Tutorial] – CodeSpeak Labs – https://www.youtube.com/watch?v=tFQkv1GJsoc
Activity: which block does the job?
Try it: match the job to the block
Choose the block you would use for each job in the racing game.
| Send the car back when it drives onto the grass | |
| Start counting the seconds again when the race begins | |
| Make a crash noise | |
| Show how long the lap took | |
| Turn the car when the right arrow is pressed | |
| Move the car forward |
Group project: build your racing game
In groups, build your own racing game in Scratch (or another interactive game controlled by the keyboard). Use this checklist to test each other’s games:
| Feature | Done? |
|---|---|
| The car moves forward and turns using the keyboard | |
| Touching the off-track colour sends the car back to the start | |
| The timer resets at the start of the race | |
| The time is shown when the car reaches the finish line | |
| At least two sounds are used (start, crash or finish) | |
| Instructions appear at the start | |
| The game ends properly (finish line or time limit) | |
| Sprites and backdrops have clear names |
Extension: duplicate the car for a second player, using W, A and D, and see who finishes first.
Self-check quiz
Click the best answer. You get feedback straight away; only your first click counts towards your score.
1. Which block sets the timer back to 0?
2. Which block can tell when the car drives onto the green grass?
3. Why does the touching-colour check go inside a forever loop?
4. What is the difference between start sound and play sound until done?
5. Which block shows the time at the finish?
6. The game ends as soon as it starts. What is the most likely problem?
Related posts on islandclass.org
- A simple game! – a 2019 game tutorial in five parts
- A simple Game! – Part 2
- A simple Game! – Part 3
- A simple Game! – Part 4
- A Simple Game! – Part 5
- Group Project – Create a Game in Scratch! – group project
- Practical- Interactive game Assignment and preparation 2026-05-20_13-55-07 – class recording
Next: Scratch: Reading Code and Predicting Output
Syllabus link: Forms 1–3 ICT curriculum, Module 5, Objective 5.16 – develop interactive games.
Attributions to media used in this post:
- Circuit of the Americas, April 22, 2018 SkySat (cropped2).jpg – Planet Labs, Inc. – CC BY-SA 4.0 (via Wikimedia Commons)
- Video: How to Make a Race Game in Scratch [15 Min Tutorial] – CodeSpeak Labs (YouTube)
Updates
2026/10/21
– Fixed the activity code so its buttons keep working.
© 2026 Vedesh Kungebeharry. All rights reserved.