- Learnt28 min · clicking a clone, and its own worth
- Basic24 min · the popping game
- Challenge 1–327 min · the shared-points bug, combos, golden bubbles
- Extrabonus · a pop you can see
Review — last lesson 5 min
- For all sprites is one box for the project; for this sprite only is one box per clone.
- A crowd moving in lockstep means a shared variable.
- A clone inherits the sprite’s position, size, costume and sprite-only values.
Quick-fire
Your reef has twenty bubbles rising at their own speeds. You want a score. Is score shared, or for this sprite only?
Reveal the answer
Shared — there is one game and one score. But how much a bubble is worth belongs to the bubble, so that one is sprite-only. Today needs both at once.
Today’s Topic 3 min
when this sprite clickedon a clone — it runs on the one you hit- Deleting the clicked clone, and only that one
- Points that belong to the bubble, added to a score that belongs to the game
- A streak, and a rare bubble worth ten
Learning outcome
By the end of this lesson you will be able to:
- Make a clone respond to being clicked.
- Score a click by what that particular clone was worth.
- Say why a shared
worthgives a wrong score that looks plausible.
Learnt — the click finds the clone 28 min
1 · A hat that clones do run
Clones ignore when flag clicked. They do not ignore these:
when this sprite clickedwhen [space v] key pressedwhen I receive [message1 v]
The click one is special: Scratch works out which clone was under the pointer and runs that clone’s script. Its nineteen neighbours carry on rising and never hear about it.
when this sprite clicked
change [popped v] by (1)
delete this clone
delete this clone removes the one that was clicked.How to use this: Click the green flag, then click bubbles as they rise. The counter goes up by one each time.
2 · Points that belong to the bubble
A game where every bubble is worth 1 is dull. Make the small fast ones valuable and the big slow ones cheap — which needs each clone to carry its own worth.
Three sprite-only variables, all set in the spawner before the clone is made:
set [my size v] to (pick random (20) to (64))
set [speed v] to (round ((9) - ((my size) / (12))))
set [worth v] to (round ((8) - ((my size) / (10))))
create clone of [myself v]
How to use this: Click the green flag, then pop a big bubble and a small one. Watch the last worth box.
3 · Shared plus sprite-only, in one line
when this sprite clicked
change [popped v] by (1)
change [score v] by (worth)
delete this clone
popped and score are shared — one game. worth is sprite-only — this bubble. Read that line out loud and the rule sticks.Basic — the popping game 24 min
Open last lesson’s shoal. You are turning it into something you can play.
Step 1 — the shared score
- Make
scoreandpopped, both for all sprites. - Set both to 0 under the green flag. Show both readouts.
Step 2 — the bubble’s own numbers
- Make
my sizeandworth, for this sprite only. You already havespeed. - In the spawner, roll
my sizefrom 18 to 62. - Work
speedout from it, andworthtoo — both wrapped inround.
Step 3 — the clone uses them
- In the clone script:
set size to (my size) %. - Rise using
speedas before, then delete.
Step 4 — the pop
- Add
when this sprite clickedto the Bubble. - Inside:
change [popped v] by (1), thenchange [score v] by (worth). - Finish with
delete this clone.
Step 5 — the result card
- After the spawner’s loop, wait a couple of seconds for the last bubbles to clear.
- Bring the original back to the middle,
showit, andsaythe two totals joined together. hideit again so it is not sitting there next run.
when flag clicked
hide
set [score v] to (0)
set [popped v] to (0)
repeat (26)
go to x: (pick random (-175) to (175)) y: (-170)
set [my size v] to (pick random (18) to (62))
set [speed v] to (round ((9) - ((my size) / (12))))
set [worth v] to (round ((8) - ((my size) / (10))))
switch costume to (pick random (1) to (5))
create clone of [myself v]
wait (0.24) seconds
end
wait (2.5) seconds
go to x: (0) y: (0)
show
say (join (popped) (join [ popped for ] (score))) for (3) seconds
hide
How to use this: Click the green flag and pop as many as you can. Go for the small fast ones.
Clicking a bubble does nothing.
The when this sprite clicked hat is on the Stage or another sprite. It must be on the Bubble itself — clones only run their own sprite’s scripts.
Clicking one bubble deletes all of them.
You used delete this clone inside a loop, or a stop [all v] crept in. The block on its own removes exactly one clone.
Every pop scores the same number.
worth is shared. Make it for this sprite only — this is Challenge 1, and worth doing on purpose.
The score has long decimals in it.
A missing round around the worth sum.
The card never appears.
The show is missing, or the say is inside the repeat instead of after it.
The wrong score
Make worth shared instead, and see what a plausible-looking wrong score feels like.
- The
worthreadout is visible and changes constantly. - You pop a tiny bubble and score whatever the newest one is worth.
- Write down why nobody playing would notice.
How to use this: Click the green flag. Watch the worth box while you aim at a small bubble, then pop it.
Teacher note
This is the most valuable minute of the arc. The game still works, the score still goes up, and it is completely wrong — which is exactly what a shared-variable bug looks like in real code. Put the readout on screen; watching it flicker is what convinces them.
Combo
Reward accuracy. Pops in a row are worth more; letting one escape costs the streak.
- A shared
streakthat goes up on every pop. - The score rises by
worth×streak. - A bubble reaching the surface sets the streak back to 0.
- A
best streakthat remembers the run’s high point.
How to use this: Click the green flag and try to pop every bubble. Miss one and watch the streak drop.
Teacher reveal — where the reset goes
repeat until <(y position) > (165)>
change y by (speed)
end
set [streak v] to (0)
delete this clone
The reset is in the clone’s own exit, not in the spawner — the escaping bubble is the thing that knows it got away. That is the same shape as the escape counter they meet next lesson.
Golden bubbles
About one bubble in eight is golden: smaller, brighter, and worth ten of the others.
- A sprite-only
goldenthat is 1 or 0, decided in the spawner. - A golden bubble looks unmistakably different, and is worth 10.
- A counter of how many golden ones the run produced.
How to use this: Click the green flag and hunt for the bright yellow ones. Ten points each.
Teacher reveal — the clone dresses itself
when I start as a clone
show
if <(golden) = (1)> then
switch costume to [yellow v]
set size to (34) %
set [brightness v] effect to (40)
else
switch costume to [blue v]
set size to (48) %
clear graphic effects
end
The else branch matters: without it a golden clone leaves its brightness behind for the next one that reuses the costume. Ask them to remove it and watch the reef slowly turn gold.
A pop you can see
At the moment a bubble just disappears. Make it burst: grow, fade, and only then delete itself.
- The clicked bubble grows and fades over a handful of steps.
- The other bubbles are completely unaffected while it does.
- The score goes up straight away, not after the animation.
How to use this: Click the green flag, then pop two bubbles quickly one after the other.
Teacher note
A good place to ask what would happen if the burst were a My Block running without screen refresh — the answer is you would not see it at all, which ties last arc to this one.
Summary 5 min
when this sprite clickedruns on the clone you actually hit.delete this cloneremoves that one clone, not the rest.- Score and streak are shared; worth, size and speed belong to the bubble. One line often uses both.
- A shared
worthgives a wrong score that still looks like a working game. - Wrap derived numbers in
roundor the player sees decimals.
- Hit test
- Scratch working out which clone the pointer was over.
- Worth
- What one particular bubble scores — sprite-only, always.
- Streak
- How many pops in a row without a miss.
- Result card
- The original sprite reappearing at the end to report the totals.
Hand in
Save your game. Next lesson it becomes a game you can lose — and the round ends by itself.