- Learnt28 min · the redraw rule, and where a crowd comes from
- Basic24 min · dust that tidies up
- Challenge 1–327 min · leftovers, the ceiling, and hiding
- Extrabonus · run without screen refresh
Review — finding a bug 5 min
- Write the number you expect before you look at anything.
- Monitors and one
saybeat reading a script. - Halve the project until one script is left; then change one block.
Quick-fire
Last week a loop counted to a hundred thousand in about a second. How many times was the Stage drawn while it did that?
Reveal the answer
About thirty. A hundred thousand turns of the loop, thirty pictures. Those are the two speeds a Scratch game runs at, and today is about the difference.
Today’s Topic 3 min
- Why some loops run once a frame and others run thousands of times
delete this clone— and what happens to the ones you forget- Three hundred clones is the whole project’s share, not one sprite’s
run without screen refreshon a My Block
Learning outcome
By the end of this lesson you will be able to:
- Say why a loop ran more times than you expected.
- Make hundreds of clones and leave none behind.
- Spot a game that has quietly run out of clones.
Learnt — thirty pictures a second 28 min
1 · The rule under everything
Scratch draws the Stage about thirty times a second. A loop that changed something you can see waits for the next drawing before going round again — so it goes round thirty times a second. A loop that changed nothing visible does not wait.
repeat until <(timer) > (7)>
change [seen v] by (1)
change y by (0)
end
repeat until <(timer) > (7)>
change [unseen v] by (1)
end
How to use this: Click the green flag and watch the two monitors race. Both loops stop at the same moment.
This is why last week’s countdown vanished, and it is why a cooldown counted in loop turns never lasts as long as it says. It is also good news: a game loop with movement in it keeps time by itself.
2 · Where a crowd comes from
Our engine makes one speck of dust per tick of thrust. That sounds tiny. A gentle descent is 180 ticks long and burns for about a third of them:
if <(costume [name v]) = [lander-thrust]> then
set [puff x v] to (x position)
set [puff y v] to ((y position) - (24))
create clone of (Dust v)
end
How to use this: Click the green flag and watch the two monitors: specks made climbs all the way down, specks alive stays small.
3 · Making them is not free either
create clone of (myself v) puts something new on the Stage, so it waits for the next drawing too. Two hundred clones in an ordinary loop take two hundred frames to arrive.
How to use this: Click the green flag. The same two hundred specks are made twice — first in an ordinary loop, then inside a ticked My Block.
Basic — dust that tidies up 24 min
Give your own game something that appears in numbers — dust, sparks, bubbles, coins — and make sure every one of them leaves.
Step 1 — one clone per tick
- Make the sprite and two variables,
puff xandpuff y. - In the flight loop, set those two and
create clone of (Dust v). - Run it. The Stage should fill up quickly.
Step 2 — a life, then a goodbye
- In
when I start as a clone, go to the puff, thenrepeat (12)drifting and fading. - After the repeat,
delete this clone. Nothide. - Run it again. The Stage should now stay tidy while the flight goes on.
Step 3 — fewer, and nobody notices
- Make a speck only every third tick:
if <((ticks) mod (3)) = (0)> then. - Watch it. It looks the same, and it is a third of the clones.
How to use this: Click the green flag and hold the up arrow to make dust. The two monitors count what was made and what is still alive.
Every speck appears in the same place.
The clone is reading puff x and puff y after the lander has moved on, or it never reads them at all. Set them immediately before create clone of (Dust v), and go to them as the clone’s first action.
The dust fades but the Stage still fills up.
You used hide or ghost 100 instead of delete this clone. Invisible is not gone — that is Challenge 1.
My specks alive monitor counts up and never down.
Put change [specks alive v] by (-1) directly above delete this clone. After the delete, nothing runs.
After a while no new dust appears at all.
You have hit three hundred. Everything else in your project has stopped being able to clone as well — see Challenge 2.
The specks that never leave
This lander’s dust fades to nothing, which looks exactly like tidying up. Prove that it is not.
- Watch both monitors for a whole flight.
- Compare what was made with what is still alive at the end.
- Work out how many flights this game would survive.
How to use this: Click the green flag and let it land. Read specks made and specks alive at the end — they are the same number.
Teacher note
Ask for the division out loud: 300 divided by 56. Five flights, and then a game that stops working for reasons nothing on screen explains. This is the most common way a Scratch project mysteriously breaks after ten minutes of play.
The explosion that never came
Three hundred is the whole project’s allowance, not one sprite’s. Here is what that looks like from the inside.
- The dust asks for four hundred specks. Count what it gets.
- The crash then asks for five pieces of wreckage.
- Find the error message Scratch shows. There is not one.
How to use this: Click the green flag. Read specks alive first, then watch the bits monitor when the lander switches to its crashed costume.
Teacher note
The silence is the lesson. A pupil whose explosion stops working will look at the explosion — and the explosion is perfect. Give them the habit of putting specks alive, or any clone counter, on the Stage while they build.
Hidden is not gone
Same three hundred specks. This time every single one of them is hidden, so the Stage is empty — and the project is just as full.
- Run it. Look at the Stage, then look at the monitor.
- Ask for the five pieces of wreckage again.
- Say, in one sentence, the difference between
hideanddelete this clone.
How to use this: Click the green flag. Nothing appears — read the specks alive monitor, then the bits monitor after the crash.
hide in your own project that should have been a delete, and changed it.Teacher reveal — the one-line difference
when I start as a clone
show
repeat (12)
change y by (-2)
change [ghost v] effect by (6)
end
change [specks alive v] by (-1)
delete this clone
hide changes what a clone looks like. delete this clone ends it: its scripts stop, and its place in the three hundred is given back. Only one of those two makes room for the next one.
Run without screen refresh
A My Block has a tick-box nobody reads. Turning it on tells Scratch to finish the whole block before drawing anything — so two hundred steps happen inside one frame.
- Make a My Block that does two hundred steps of work.
- Time it with
(timer), twice: tick off, then tick on. - Use it for something real — building a crowd, or checking a whole list.
How to use this: Click the green flag and wait. The same two hundred steps run twice, and the sentence at the end gives both times.
Teacher note
Good place to name the trade the whole lesson is about: Scratch spends its time either drawing or thinking. Every trick here is a way of choosing which.
Summary 5 min
- The Stage is drawn about thirty times a second.
- A loop that changed something visible waits for that. One that did not, does not.
- A project may hold 300 clones at once, shared by every sprite.
hideis notdelete this clone.- A ticked My Block finishes before the next drawing — good for work, not for movement.
- Frame
- One drawing of the Stage. About thirty of them a second.
- Redraw
- Scratch putting the Stage on the screen again after something changed.
- Clone limit
- The 300 clones a whole project may have alive at one time.
- Run without screen refresh
- A My Block setting that finishes all its work inside one frame.
Hand in
Save your game with a clone counter on the Stage. Next week it gets a score, a board, a front door and a proper test.