- Learnt28 min · escapes, lives, and ending the round
- Basic24 min · the finished game
- Challenge 1–327 min · harder, a lasting best, spiky bubbles
- Extrabonus · ship it
Review — the arc so far 5 min
create clone of [myself v], a clone script, anddelete this clonefor every one of them.- Sprite-only variables give each clone its own speed, size and worth.
when this sprite clickedlands on the clone you hit.
Quick-fire
Your popping game runs for twenty-six bubbles and then stops, whether you are any good at it or not. What is missing?
Reveal the answer
A way to lose. A game needs a cost for failing and an ending that depends on how you played — and both of those come from the bubble that gets away.
Today’s Topic 3 min
- A clone doing something on its way out, not just vanishing
lives, and why the decrement needs a guardrepeat untilas the spawner’s loop, so the round ends itself- A difficulty that rises, and a best score that outlives the green flag
Learning outcome
By the end of this lesson you will be able to:
- Make a round end because of how the player played, not after a fixed count.
- Build a difficulty curve with two blocks.
- Keep a best score across several rounds.
Learnt — escaping, and losing 28 min
1 · The clone reports on its way out
Up to now a bubble reaching the surface just deleted itself. But that clone is the only thing in the project that knows it got away — so that is where the counting belongs:
when I start as a clone
show
repeat until <(y position) > (165)>
change y by (speed)
end
change [escaped v] by (1)
delete this clone
How to use this: Click the green flag and pop some but not all. The two counters split between you and the bubbles.
2 · Lives
Turn the escape counter into a cost. lives is shared — there is one player — and starts at 3:
repeat until <(y position) > (165)>
change y by (speed)
end
if <(lives) > (0)> then
change [lives v] by (-1)
end
delete this clone
if is not optional. Read on.3 · A round that ends itself
The spawner has been using repeat (26), which means the round lasts the same length however you play. Swap the loop:
repeat (26)
go to x: (pick random (-175) to (175)) y: (-170)
create clone of [myself v]
wait (0.3) seconds
end
repeat until <(lives) = (0)>
go to x: (pick random (-175) to (175)) y: (-170)
create clone of [myself v]
wait (0.3) seconds
end
One word changed, and the game got a proper shape: it now depends on the player. Then wait a moment for the last clones to clear, and show the card.
How to use this: Click the green flag and let three bubbles escape on purpose. The spawner stops on its own.
Basic — the finished game 24 min
Open last lesson’s popping game. Four changes and it is a real game.
Step 1 — lives
- Make
lives, for all sprites, and show it. - Set it to 3 under the green flag, before anything else.
Step 2 — escaping costs
- In the clone script, after the rise loop, add
if <(lives) > (0)> then. - Inside it:
change [lives v] by (-1). - Leave
delete this clonebelow the whole thing.
Step 3 — the round ends itself
- Swap the spawner’s
repeat (26)forrepeat until <(lives) = (0)>. - Run it. Play badly on purpose and watch it stop.
Step 4 — the game-over card
- After the loop, wait about a second for the last bubbles to clear.
- Bring the original to the middle, set it large,
showit. - Say the totals, then say
Game over., thenhide.
when flag clicked
hide
set [lives v] to (3)
set [score v] to (0)
set [popped v] to (0)
repeat until <(lives) = (0)>
go to x: (pick random (-175) to (175)) y: (-170)
set [my size v] to (pick random (20) to (62))
set [speed v] to (round ((10) - ((my size) / (10))))
set [worth v] to (round ((8) - ((my size) / (10))))
switch costume to (pick random (1) to (5))
create clone of [myself v]
wait (0.4) seconds
end
wait (1) seconds
go to x: (0) y: (0)
set size to (60) %
show
say (join [Popped ] (join (popped) (join [ for ] (score)))) for (2.5) seconds
say [Game over.] for (3) seconds
hide
How to use this: Click the green flag and play properly. Let three bubbles past and the game ends.
No bubbles appear at all.
lives is 0 when the loop is reached — the set [lives v] to (3) is missing or is below the loop.
Lives goes to −3 and the card is late.
The guard is missing. The bubbles still in flight when the round ended are taking lives they should not.
The game never ends however many escape.
The decrement is in the click script instead of after the rise loop, so only popping costs you lives — the opposite of the rule.
The card never appears.
A forever loop where a repeat until belongs, or a stop [all v] before the card.
The card appears while bubbles are still rising.
The wait after the loop is too short. A second or two covers the slowest bubble’s trip to the surface.
It gets harder
A flat game is boring. Make the bubbles come faster the longer you survive.
- A
gapvariable used by the wait, instead of a fixed number. - Every sixth bubble, the gap shrinks by a fifth.
- The gap is visible, so you can watch the game tighten.
How to use this: Click the green flag and survive as long as you can. Watch the gap box shrink.
Teacher reveal — every sixth one
change [made v] by (1)
if <((made) mod (6)) = (0)> then
set [gap v] to ((gap) * (0.8))
end
wait (gap) seconds
mod from Lesson 3-2, doing real work: “is this a multiple of six?”. Multiplying by 0.8 rather than subtracting keeps the gap positive for ever, which subtracting would not.
A best that lasts
Play three rounds without touching the green flag, and keep the highest score across all of them.
- A key starts a round, not the flag.
scoreresets each round;bestnever does.- A new best is announced when it happens.
How to use this: Click the green flag, then press G several times. Watch best hold while score changes.
best untouched.Teacher reveal — where the reset goes
when flag clicked
set [best v] to (0)
when [g v] key pressed
set [score v] to (0)
Two hats, and the whole idea is which one holds which reset. Same shape as the Line Follower’s lap record and the Quiz Master’s best — say so, because a pupil who spots the repeat is generalising.
Spiky bubbles
Some bubbles must not be popped. Roughly one in four is orange and spiky, and clicking it costs a life.
- A sprite-only
spiky, 1 or 0, decided before the clone is made. - A spiky bubble is a different colour, obviously.
- Clicking a spiky one loses a life; clicking a normal one scores.
- A count of how many mistakes you made.
How to use this: Click the green flag and pop only the blue ones. The orange ones bite.
Teacher reveal — the click branches on the clone’s own kind
when this sprite clicked
if <(spiky) = (1)> then
change [lives v] by (-1)
change [spiky popped v] by (1)
else
change [score v] by (1)
end
delete this clone
If spiky is shared, every click is judged by the newest bubble’s kind and the game becomes random. It is the same bug as Lesson 3-19’s shared worth, and by now they should predict it before you run it.
Ship it
Put the whole arc into one project you would be happy to hand to somebody else to play.
- A title before the first bubble.
- Three lives, and a round that ends itself.
- Sizes, speeds and worths rolled per bubble.
- A rising difficulty, golden bubbles, and a visible burst.
- A score card, and a best that survives the round.
How to use this: Click the green flag, wait for the title, and play. Golden ones are worth twelve.
Teacher note
Worth counting the blocks with them. The shipped game is not much bigger than the Lesson 3-17 stream — almost everything added was a variable with the right scope, not more code. That is the message of the whole arc.
Summary 5 min
- A clone can act on its way out — counting the escape belongs to the clone.
repeat until <(lives) = (0)>makes the round last as long as the player does.- Guard the decrement with
if <(lives) > (0)> then, or bubbles still in flight take lives you have not got. - A gap variable multiplied by 0.8 is a difficulty curve in two blocks.
bestresets under the flag;scoreresets each round.
- Escape
- A bubble reaching the surface unpopped.
- Guard
- An
ifthat stops a change happening when it should not. - Difficulty curve
- A game getting harder the longer it lasts.
- Game over card
- The original sprite reappearing to report the run.
Hand in
Save your shipped game. You have finished the clones arc — one sprite, three hundred bubbles, and every one of them knowing its own business.