- Learnt27 min · a lane, a finish line, and two of everything
- Basic25 min · build the race
- Challenge 1–328 min · your race, a fair one, an obvious winner
- Extrabonus · a third player
Review — where we got to 5 min
Pet Pal is finished. Nothing new is coming today — everything in this lesson is something you have already built.
- The controller from Topic 1.6:
foreverwithif <key [d v] pressed?> theninside it. touching [Star v]?, from the Maze Escape’s exit.
Quick-fire
Two players are going to share one keyboard. What is the first thing that will go wrong?
Reveal the answer
The hands. Two sets of keys in the same corner of a keyboard get in each other’s way — whether that is two people, or your own two hands testing it. They have to sit at opposite ends.
Today’s Topic 3 min
- Two sprites, two lanes, two different keys
- A finish line sprite, and a race that ends when somebody reaches it
wait until <touching [Finish v]?>as a whole script- Why two controllers must be identical except for the key and the lane
Learning outcome
By the end of this lesson you will be able to:
- Build a controller for one player and copy it for a second.
- End a race when either player reaches the finish.
- Say why a race that one player always wins is a bug and not a skill.
Learnt — a lane, a line, and two of everything 27 min
1 · One lane first
Build half a race. One rocket, one key. If it does not work with one player it will not work with two.
- New project, cat deleted, the Space backdrop.
- Add a rocket sprite. Name it
Rocket 1and put it atx: -200 y: 70. - Add
point in direction (90), so a second run always starts it facing the right way. - Build the forever loop with one if in it, listening for the D key.
- Press the flag, click the Stage once, and hold D.
when flag clicked
set size to (80) %
point in direction (90)
go to x: (-200) y: (70)
forever
if <key [d v] pressed?> then
change x by (4)
end
end
How to use this: Click the green flag, click the stage once, then hold D. One rocket, one key — half a race.
2 · The finish line
The line is a sprite. Reaching it is the same question the Maze Escape asked about its exit star, and the answer this time is a whole script of its own.
- Add a tall thin sprite at
x: 200. Paint one if you like. - Name it
Finish. - On the rocket, start a SECOND green-flag stack.
- Put
wait until <touching [Finish v]?>in it. - Under that, a sound, a message, and stop all.
when flag clicked
wait until <touching [Finish v]?>
start sound [Win v]
say [Blue wins!] for (3) seconds
stop [all v]
How to use this: Click the green flag, click the stage once, then hold D all the way to the line. Then try letting go halfway.
3 · Two of everything
The second player is a copy of the first with exactly two changes. Anything else you change by accident makes the race unfair.
- Right-click
Rocket 1in the sprite list and choose Duplicate. - Rename the copy
Rocket 2. - Change its
go to x: (-200) y: (70)toy: -70. - Change its key dropdown from
dtoright arrow. - Change the words in its say block to
Red wins! - Give it a different costume colour so the two are told apart at a glance.
when flag clicked
set size to (80) %
point in direction (90)
go to x: (-200) y: (-70)
forever
if <key [right arrow v] pressed?> then
change x by (4)
end
end
How to use this: Click the green flag, click the stage once, then hold D with one hand and → with the other. Both rockets are yours.
Basic — build the race 25 min
One rocket working properly is worth more than two half-built ones.
Step 1 — the track
- New project, cat deleted, a backdrop you like.
- Add a tall thin sprite on the right and name it
Finish. - Give it a flag stack that puts it in place, so it can never be nudged.
Step 2 — the first racer
- Add your first racer sprite in the top lane.
- Build its green-flag stack: size, direction, start position.
- Build the controller loop with one key.
- Test it. Get all the way to the line by hand.
Step 3 — winning
- Add the second stack with the wait-until in it.
- Put a sound, a message and a stop under it.
- Test it three times.
Step 4 — the second racer
- Duplicate the whole sprite.
- Change its lane, its key and its winning message.
- Change its colour or its costume.
- Read both controllers side by side and check every OTHER number is the same.
Step 5 — play it
- Race yourself five times: left hand on D, right hand on the right arrow.
- Swap hands over and race five more.
- If the same racer wins every time whichever hand drives it, something is not equal. Go and find it.
Neither rocket moves.
Nobody has clicked the Stage. A project only hears the keyboard once it has been clicked on.
Both rockets move when I press one key.
The duplicated sprite kept the original key. Open its controller and change the dropdown.
One player always wins, whoever is in the seat.
Their move number is bigger, or their start x is further right. Read the two green-flag stacks next to each other.
The winning message flashes and the race is still going.
stop [all v] is missing, or the say block has no seconds on it so it disappears immediately.
Your race, your world
Rockets in space is mine. Make it yours.
- A backdrop that is not space.
- Two racers that suit it and are easy to tell apart.
- A finish line that looks like a finish line.
Prove it is fair
A race that one side always wins is broken, not hard. Prove yours is fair, and write down how you proved it.
- Both lanes are the same length.
- Both racers move by the same amount.
- You have raced five times, then swapped seats and raced five more.
- You can say what the results were.
Teacher note — swapping seats is the whole test
A pair who race ten times without swapping learn nothing: the better player wins and everybody assumes that is why. Swapping is what separates a fast player from a fast sprite, and it is the reason this mission is worth ten minutes rather than two.
Make the winner obvious
A photo finish should not need an argument. Make the winning moment impossible to mistake.
- The winner does something the loser does not.
- It is clear from across the room, with the sound off.
- It says which player won, not just that somebody did.
- It stays on screen long enough to be read.
Teacher note — the honest photo finish
If both rockets touch the line in the same frame, both winning scripts run and the second message replaces the first. That is a real bug and the class will hit it. The fix — a variable saying whether the race has been won — is next lesson, so today the right answer is to notice it and say so, not to fix it.
Room for a third
Add a third lane and a third player. The hard part is not the blocks — it is finding three keys three pairs of hands can reach at once.
How to use this: Click the green flag, click the stage once, then try D, K and → at the same time. See how many of the three you can drive at once.
- Three lanes, evenly spaced, all the same length.
- Three keys that three people can hold at the same time without touching.
- All three racers are told apart at a glance.
- Any of the three can win, and the message says which.
Teacher notes — the duplicate trap, and the keyboard one
Duplicating a sprite copies its key. A pupil who duplicates twice and changes one dropdown ends up with two racers on the same key, which looks like one racer moving twice as fast. Make them read all three controllers out loud.
The keyboard problem is real and worth stopping on. D, K and the right arrow spread three hands across the whole keyboard. A, S and D put three children in the same six centimetres.
Some keyboards also refuse to report more than a few keys held at once. If a lane goes dead when all three players press together, that is the hardware and not the project — spreading the keys further apart usually fixes it.
Going further: next lesson nobody can start before the countdown finishes.
Summary 4 min
Nothing new today, and a game nobody could have built in week one.
- A lane is a controller that only moves one way.
- A finish line is a sprite, and reaching it is a touching question.
wait until <>makes a whole winning script out of five blocks.- Two controllers must differ in exactly two things: the key and the lane.
- Lane
- One player’s row of the Stage. Same length as everybody else’s.
- Finish line
- A sprite at the end of the track. Touching it wins.
- Fair
- Both players can win. Swapping seats is how you prove it.
- Duplicate
- Copying a whole sprite with its scripts. Faster than rebuilding, and easier to get wrong.
Next lesson: a countdown, and a race nobody can start early.