- Learnt28 min · rounds, two scores, three endings
- Basic25 min · turn your race into a match
- Challenge 1–327 min · a scoreboard, best of five, hand it over
- Extrabonus · a handicap for the winner
Review — where we got to 5 min
You have a two-player race with rocks and a countdown. Today you use blocks you already know. This is your biggest project so far.
- The broadcast chain from the Quiz Show. One script finishes and calls the next.
- The
race onswitch from two lessons ago. - An if inside an else, from the medal card.
Quick-fire
You beat your friend once. They say it was luck. How can you find out who is better? What must change in your project?
Reveal the answer
More races. So the project must know three new things. How many races have run? Who won each one? When should it stop?
Today’s Topic 3 min
- A
roundcounter, and a referee who knows when the match is over. - Two win counters, one for each player.
- Three endings: blue, red and a draw.
- A broadcast instead of
stop [all v], so the game can carry on.
Learning outcome
By the end of this lesson you will be able to:
- Run a set number of rounds, one after the other.
- Keep a score for two players at once.
- Name the champion, or say it is a draw.
Learnt — rounds, scores, a champion 28 min
1 · The winner stops stopping everything
stop [all v] is the problem. After it, nothing is left running. So nothing can start a second race. Use a message instead.
when I receive [new round v]
go to x: (-200) y: (70)
wait until <touching [Finish v]?>
change [blue wins v] by (1)
say [Blue takes it!] for (2) seconds
broadcast [round over v]
The referee hears round over and decides what happens next. It uses an if / else. This runs the whole match.
when I receive [round over v]
set [race on v] to (0)
wait (3) seconds
if <(round) > (2)> then
broadcast [match over v]
else
broadcast [new round v]
end
3 > 2 is true.2 · Two scores
Two players need two counters. What matters is where you SET them. It is the same rule as the Quiz Show’s best score.
| Set on the green flag | Set at the start of each round |
|---|---|
blue wins | race on |
red wins | Both rockets’ positions |
round | — |
What if you put a win counter in the right-hand column? Every round sets it back to 0. The match is always 1–0 to whoever won last.
when I receive [new round v]
set [race on v] to (0)
change [round v] by (1)
say [3] for (1) seconds
say [2] for (1) seconds
say [1] for (1) seconds
set [race on v] to (1)
say [GO!] for (1) seconds
How to use this: Click the green flag to start it. Nothing else to press — watch it through, then use ↺ Reset to run it again.
3 · Three endings
Blue can win, or red can win. Sometimes the scores are level. This can happen with an even number of rounds, or a round nobody finishes. Every match needs all three endings.
when I receive [match over v]
start sound [Triumph v]
if <(blue wins) > (red wins)> then
say [Blue is the champion!] for (4) seconds
else
if <(red wins) > (blue wins)> then
say [Red is the champion!] for (4) seconds
else
say [A draw! Race again.] for (4) seconds
end
end
How to use this: Click the green flag to start it. Nothing else to press — watch it through, then use ↺ Reset to run it again.
How to use this: Click the green flag, click the stage once, then race with D in one hand and → in the other. Three races decide the match.
Basic — turn your race into a match 25 min
You already have almost every block you need. You change which hat block each script starts with.
Step 1 — the three variables
- Make
blue wins,red winsandround. - Show all three.
- Set all three to 0 on the referee’s green-flag stack.
- End that stack with
broadcast [new round v].
Step 2 — move the countdown
- Change the referee’s countdown hat from
when flag clickedtowhen I receive [new round v]. - Add
change [round v] by (1)near the top of it. - Press the flag. One countdown should run.
Step 3 — the winning scripts report
- Change each rocket’s winning hat to
when I receive [new round v]. - Put the
go to x: (-200) y: (70)block at the top of it. - Swap
stop [all v]forbroadcast [round over v]. - Add
change [blue wins v] by (1)before the message.
Step 4 — the referee decides
- Build the round-over script on the referee.
- Test it. Three countdowns should run, one after another.
- Check the round counter gets to 3 and stops.
Step 5 — the champion
- Build the match-over script. Put the if inside the else.
- Play a whole match. Drive both rockets yourself.
- Play a second match. Check everything starts again from 0.
The countdown runs for ever.
The round counter is not going up, so round > 2 is never true. The change block goes in the new-round script, not the round-over one.
Round 2 is won straight away.
A rocket did not go back to its start line. So it is still touching the finish. The go to x: (-200) y: (70) is the first block of the winning script.
The score is always 1-0.
The new-round script sets the win counters to 0. They belong on the green flag.
Both players score in the same round.
The race does not switch off when somebody wins. The loser reaches the line during the three-second wait.
A scoreboard you can read while flying
Players are racing. They should not have to squint at the corner to see the score.
- You can see the score during the race. Not only between rounds.
- The round number is on screen.
- Nothing covers a lane or a rocket.
Best of five, decided early
Make it best of five. Stop as soon as one player has won three. Do not play races that cannot change anything.
- Up to five rounds.
- When a player gets three wins, the match ends straight away.
- A 3–0 match plays three races, not five.
- A 3–2 match plays all five.
Teacher note — three questions, not one
The round-over script now asks three things: has blue won three, has red won three, or have we run out of rounds? Any of them ends the match. The tidy way is three ifs before the else, and the interesting mistake is checking the round count FIRST, which plays race four before noticing the match was already over.
Hand it to two strangers
The last challenge of Level 1. Two people who have never seen your game play a whole match. You say nothing.
- They work out which rocket is theirs.
- They work out which keys are theirs.
- They play three races without asking you anything.
- They know who won.
Teacher note — the keys have to be on the screen
This is the one thing almost every project fails on, and it is invisible to the author because they know their own keys. A line on the title screen, or a label under each rocket, is all it takes. It is the same lesson as the Quiz Show’s stranger test and the Pet Pal’s: whatever you wanted to say out loud belonged on the screen.
A handicap for the winner
When a fast player races a slow one, the match is over after round one. Make the winner of a round start a little further back in the next one.
How to use this: Click the green flag to start it. Nothing else to press — watch it through, then use ↺ Reset to run it again.
- If you win a round, your start line moves back for the next one.
- Losing does not.
- Nobody ever starts off the left edge of the Stage.
- The handicap goes back to 0 at the start of a new match.
Teacher notes — a start position that is a variable
when I receive [new round v]
go to x: (blue start) y: (70)
wait until <touching [Finish v]?>
change [blue wins v] by (1)
change [blue start v] by (-15)
broadcast [round over v]
The move worth naming: go to x: (blue start) y: (70) has a variable where every other one in the course has had a number. The rocket’s starting place is now something the game decides.
Keeping it on the Stage needs a floor. The honest Level 1 answer is a guard, added straight after the change block:
if <(blue start) < (-215)> then
set [blue start v] to (-215)
end
A pupil who asks whether there is a neater way has found the reason other languages have a block for “whichever of these two is bigger”. Scratch does not, so the guard is the answer here.
Going further: Level 2 opens with clones that each carry their own numbers, and a whack-a-mole game built on the mouse rather than the keyboard.
Summary 5 min
Thirty-six lessons ago, the cat moved ten steps. Today two people play a three-round match.
stop [all v]ends a project. A broadcast ends a ROUND.- A referee holds the counters. It decides when the match is over.
- Set match scores on the green flag. Set round things at the start of each round.
- Three endings, tested in order. One of them is the draw.
What the six arcs covered
- Moving, turning, gliding, and x and y on the Stage.
- Costumes, backdrops, saying, sound, and two things at once.
- Events, loops, if, if / else, and the questions Sensing can ask.
- Variables: as a score, a countdown, a mood and a switch.
- Clones, broadcasts, and a game with a title screen and an ending.
- Round
- One race. A match is several of them.
- Match
- A set of rounds. The winner is decided at the end.
- Draw
- Nobody won. It needs its own ending, even when it seems it can never happen.
- Referee
- The sprite that holds the rules. Nobody plays it.
Next lesson: a new game. One key, one hop, and you can never stand still.