- Learnt28 min · a round, a referee, a match
- Basic24 min · the match
- Challenge 1–327 min · stale orbs, a banner, a time limit
- Extrabonus · a healing star
Review — firing and health 5 min
- An orb is a clone that reads its fighter’s notes and flies until it hits something.
- A health bar is a costume per tenth.
- A cooldown is kept by the timer, not by counting.
Quick-fire
Right now, when a health bar reaches 0, what happens?
Reveal the answer
Nothing. Health just goes on down and the fight carries on. Nobody in the game is watching for the end — so today we add somebody whose only job is to watch: a referee.
Today’s Topic 3 min
- A referee script that waits for a knock-out
wins 1,wins 2, and first to two- Resetting for a new round: health, positions and orbs
- A
statethe fighters obey — Storm Flight again
Learning outcome
By the end of this lesson you will be able to:
- End a round when a condition is met, and score it.
- Reset everything a round leaves behind — including things still moving.
- Build a match out of repeated rounds.
Learnt — rounds 28 min
1 · A referee
Add a small sprite at the bottom of the arena — the referee. It does not fight; it watches:
wait until <<(health 1) < (1)> or <(health 2) < (1)>>
set [state v] to [over]
if <(health 1) < (1)> then
change [wins 2 v] by (1)
set [winner v] to [Giga]
else
change [wins 1 v] by (1)
set [winner v] to [Tera]
end
say (join [Round to ] (winner))
state is fight, so setting it to over stops the round at once.How to use this: Click the green flag. Both fighters fire from their corners until one is out.
2 · A match
Wrap the round in a loop that runs until someone has two wins, with a reset between rounds:
repeat until <<(wins 1) = (2)> or <(wins 2) = (2)>>
wait until <<(health 1) < (1)> or <(health 2) < (1)>>
score the round :: custom
change [round v] by (1)
set [health 1 v] to (100)
set [health 2 v] to (100)
broadcast [new round v] and wait
broadcast [to your corners v] and wait
set [state v] to [fight]
end
say (join (winner) [ wins the match!])
score the round is part 1’s scoring, moved into a My Block. new round clears the orbs; to your corners moves the fighters home.How to use this: Click the green flag and watch rounds until somebody has two.
Basic — the match 24 min
Open your duel and make it a match.
Step 1 — the referee
- A small sprite at the bottom of the arena.
- Make
state,round,wins 1,wins 2andwinner. - Build the match loop from Learnt part 2.
Step 2 — the fighters obey
- Wrap each fighter’s loop body in
if <(state) = [fight]> then. - Add
when I receive [to your corners v]: go to your start, face the other way.
Step 3 — the orbs obey
- Add
when I receive [new round v]→delete this cloneto both Orb sprites.
How to use this: Click the green flag. Player 1: W A S D and space. Player 2: arrows and L. First to two rounds.
The match ends in the first second.
wins 1 and wins 2 are not set to 0 at the start, so an old score carries over from the last game.
Round 2 starts already over.
One health was not reset to 100, and the referee sees it still at 0.
A fighter is hit the moment round 2 begins.
An orb from round 1 is still flying. That is Challenge 1.
Stale orbs
Leave out the new round broadcast, stop both fighters firing after round 1, and read Tera’s health a second into round 2.
- Nobody fires in round 2.
- Tera’s health should be 100. Is it?
How to use this: Click the green flag. Round 1 is fought, then round 2 begins with nobody firing — watch the blue bar.
Teacher note
A reset has to cover everything the round left behind, including things still moving. The orbs were fired fairly in round 1 and land unfairly in round 2 — one delete this clone on new round ends it.
A banner between rounds
Before each round, the referee says “Round 2... ready...” for two seconds, and nobody may fire.
- The state is
readywhile the banner shows. - Count the orbs fired during the banner.
How to use this: Click the green flag. Round 1 is fought; watch what happens during the banner before round 2.
Teacher note
No fighter code changes: they already only act when the state is fight. A new state is free once every script asks the state first — the Storm Flight lesson, paying off again.
A time limit
Give each round six seconds. If nobody is out when time runs out, more health wins.
- A
time leftcounter, a second at a time. - The round ends on a knock-out or at 0 seconds.
- Equal health is a draw.
How to use this: Click the green flag. Two slow-firing fighters and a six-second clock.
Teacher reveal — three endings
if <(health 1) > (health 2)> then
set [winner v] to [Tera]
else
if <(health 2) > (health 1)> then
set [winner v] to [Giga]
else
set [winner v] to [nobody - a draw]
end
end
The draw is the ending pupils forget, and the one that makes a match loop run for ever.
A healing star
Halfway through a round, a star appears in the centre. The first to touch it gets 30 health back.
- The star waits, appears, then waits to be touched.
- Healing never takes anyone above 100.
- It disappears once used.
How to use this: Click the green flag. Giga takes some hits, then walks to the star when it appears.
Teacher note
The cap at 100 is the bit to check: without it a player can stand on the star and go above full, and the health bar has no costume for 130.
Summary 5 min
- A referee waits for a knock-out, sets the state, and scores the round.
- A match is a loop of rounds until someone has two wins.
- A reset covers health, positions and anything still moving.
- New states, like a banner, cost nothing once every script asks the state.
- Round
- One fight, from full health to a knock-out or the time limit.
- Match
- A set of rounds; the first to win enough takes it.
- Referee
- A script whose only job is to notice when the game has changed.
- Reset
- Putting everything back as it was at the start.
Hand in
Save your match. Next lesson, the two copies of your fighter become one — and every unfairness this arc has found becomes impossible.