Learning Goals 3 min
By the end of this lesson you will be able to:
- Predict what an L3-level stack will do before clicking the flag — covering arithmetic operators, lists, my blocks, clones, game-state, top-down mazes, and scrolling platformers.
- Name the eight clusters of Level 3 and give one example block per cluster, so you can find any L3 idea by walking through the mental map.
- Use the L4 Cold-Memory Reference Card at the bottom of this lesson to confirm that every L3 essential is still solid before the big L4 projects begin.
Warm-Up — predict before you click 10 min
Level 4 doesn't reteach Level 3 — it uses Level 3 as the floor for two hundred-block projects. Before we add anything new, let's prove the floor holds. Look at each stack, say (or write) what happens when the flag is clicked, then peek at the reveal. No clicking allowed.
Puzzle 1 — arithmetic and pick random
when flag clicked
set [total v] to (0)
repeat (5)
set [roll v] to (pick random (1) to (6))
set [total v] to ((total) + (roll))
end
say (join [Total: ] (total)) for (2) seconds
Reveal puzzle 1
The script rolls a fake six-sided dice five times and adds each roll into total. The lowest possible total is 5 (all ones), the highest is 30 (all sixes), and a typical run lands somewhere around 17 or 18. The final say (join …) for (2) seconds sticks the number onto a piece of text using join. (L03-02, L03-03.)
Puzzle 2 — looping through a list
when flag clicked
delete all of [kuih v]
add [kuih lapis] to [kuih v]
add [ondeh ondeh] to [kuih v]
add [seri muka] to [kuih v]
set [i v] to (1)
repeat (length of [kuih v])
say (item (i) of [kuih v]) for (1) seconds
change [i v] by (1)
end
Reveal puzzle 2
The sprite says "kuih lapis", then "ondeh ondeh", then "seri muka" — one second each. The i variable is the counter that walks through positions 1, 2, 3. The loop runs exactly length of [kuih v] times, which is 3. If Daniel added a fourth kuih before the loop, it would automatically read four — that's the point of length of instead of hard-coding 3. (L03-09, L03-10, L03-12.)
Puzzle 3 — my block with an input
when flag clicked
erase all
draw-polygon (3) :: custom
draw-polygon (6) :: custom
define draw-polygon (sides)
pen down
repeat (sides)
move (60) steps
turn cw ((360) / (sides)) degrees
end
pen up
Reveal puzzle 3
The pen draws a triangle (3 sides, 120° turn each step) and then a hexagon (6 sides, 60° turn each step) on top of it. The custom block draw-polygon takes a number input sides, and the (360) / (sides) trick computes the exterior angle so any regular polygon comes out right. (L03-15, L03-16, L03-19.) Notice the recap reaches into the Pen extension a little — you'll meet those blocks properly in cluster B next week.
New Concept — your map of Level 3 14 min
Level 3 had 48 lessons. Nobody carries 48 separate things in their head — your brain groups them. The 48 lessons clumped into eight clusters, each one teaching a single big idea. If you can name the eight clusters, you can find any L3 block, pattern, or trick by walking the map.
The eight L3 clusters
| Cluster | Big idea | Signature block or pattern |
|---|---|---|
| A · Operators deep dive | Arithmetic, pick-random, mod, round, abs, floor — turning numbers into game logic. | pick random (1) to (10) |
| B · Lists | Many values in one named slot. Add, replace, delete, loop through, count. | item (1) of [list v] |
| C · My Blocks | Define your own block once, call it everywhere. Inputs make it reusable. | define block-name (input) |
| D · Clones | Live copies of one sprite. Each runs its own clone-hat script independently. | when I start as a clone |
| E · Game state | Title / play / paused / game-over as values of one variable. Scripts gate on it. | set [state v] to [play] |
| F · Top-down maze | Touching-colour walls, bounded movement, goals, patrolling enemies. | touching color [#000000] ? |
| G · Scrolling platformer | Move the world, not the player. Gravity, jumping, multi-backdrop levels, coin clones. | change [velocity-y v] by (-1) |
| H · Design & debugging | Plan on paper, debug big stacks, optimise many sprites, share the build. | (no single block — a habit) |
Why this map matters in L4
Level 4 doesn't add new clusters — it stitches several together into projects. The multi-level platformer (cluster D of L4) is L3's scrolling platformer (G) plus L3's game state (E) plus L3's lists (B). The trivia studio (cluster G of L4) is L3's lists (B) plus L3's my blocks (C). You're not learning new clusters. You're wiring the ones you already know into projects ten times bigger than anything in L3.
One question per cluster
Say the answer in your head first, then read on. If three or more catch you off-guard, please re-skim SCR-L03-48 (the L3 Recap) before continuing — every answer is there with a worked example.
- A: What does (7) mod (3) report, and why is mod useful in games? (Reports
1— the remainder after dividing. Useful for "every Nth frame" or wrapping a score around a fixed value.) - B: What's the difference between add [x] to [list v] and insert [x] at (1) of [list v]? (Add appends to the end; insert puts at any position and shifts the rest down.)
- C: Why would you tick "Run without screen refresh" on a my block? (So the whole my block runs in one frame — needed for tight pen drawings and recursive shapes.)
- D: A clone is created. What hat block runs on the new clone? (when I start as a clone — not the green-flag hat. The original sprite's green-flag script does not re-fire.)
- E: If state equals
paused, how do you make the player's movement script ignore the arrow keys? (Wrap the movement inside if <(state) = [play]> then — every gameplay script gates on state.) - F: In a top-down maze, what stops the player from walking through black walls? (After each move, check touching color [#000000] ? and if so, undo the move — usually by stepping back.)
- G: In a scrolling platformer, what moves when the player presses the right arrow — the player or the world? (The world. The player stays roughly centred; backdrops, platforms, and enemies shift left.)
- H: Why sketch a game on paper before opening Scratch? (So the structure — sprites, variables, broadcasts — is decided before you start dragging. Saves the "halfway through I realised I need a different state machine" rewrite.)
The highest-leverage idea per cluster
Out of every L3 lesson, one idea per cluster will pay back the most in L4. Memorise these eight sentences.
- A — arithmetic: any number you compute can be plugged anywhere a number block fits. go to x: ((mouse x) + (50)) y: (0) is as legal as a literal.
- B — lists: a list and a counter (i) is how you walk through anything. Item-by-item is the universal pattern.
- C — my blocks: any stack you write twice should become one custom block. Inputs make it reusable.
- D — clones: one sprite + clones = many of the same kind of thing. Falling stars, coins, bullets, bricks — all clones.
- E — game state: every gameplay script gates on the state variable. Title screen is one value; play is another; everyone agrees.
- F — top-down: colour collision = simple wall logic. Paint walls one colour, check that colour, undo the move on touch.
- G — platformer: gravity is one variable that grows more negative each frame until you touch the ground (which resets it to zero).
- H — workflow: plan first. The bigger the project, the cheaper the pencil-and-paper time.
Worked Example — read & predict "Coin Run Lite" 12 min
Open this stack in your head — don't open Scratch yet. We'll walk through every script across three sprites and you'll predict what happens before peeking at the answer. This is the exact reading skill L4 demands every single lesson.
Step 1 — meet the sprites and variables
Three sprites: Player (an aljay-style cat at the bottom), Coin (a small kuih sprite used as a falling collectible via clones), and Slime (a patrolling enemy). Four variables, all "for all sprites": state (text: title / play / over), score, lives, and velocity-y.
Step 2 — read the Player's gameplay loop
when flag clicked
set [state v] to [title]
set [score v] to (0)
set [lives v] to (3)
set [velocity-y v] to (0)
go to x: (0) y: (-100)
when [space v] key pressed
if <(state) = [title]> then
set [state v] to [play]
end
when flag clicked
forever
if <(state) = [play]> then
if <key [right arrow v] pressed?> then
change x by (5)
end
if <key [left arrow v] pressed?> then
change x by (-5)
end
change [velocity-y v] by (-1)
change y by (velocity-y)
if <(y position) < (-150)> then
set [velocity-y v] to (0)
set y to (-150)
end
end
end
Cluster E (state) gates cluster G (gravity + arrow keys). The title screen is silent until space is pressed.
Step 3 — read the Coin's clone spawner
when flag clicked
hide
forever
if <(state) = [play]> then
create clone of [myself v]
wait (1.5) seconds
end
end
Cluster D pattern with a cluster E gate. The original Coin sprite stays hidden; every falling coin is a clone.
Step 4 — read the Coin clone's fall script
when I start as a clone
show
go to x: (pick random (-200) to (200)) y: (160)
repeat until <<touching [Player v] ?> or <(y position) < (-170)>>
change y by (-4)
end
if <touching [Player v] ?> then
change [score v] by (1)
end
delete this clone
One repeat until with an <> or <> condition does both exits in one loop. After the loop ends, a single if-then decides whether to award a point.
Step 5 — read the Slime's patrol
when flag clicked
go to x: (-150) y: (-140)
point in direction (90)
forever
if <(state) = [play]> then
move (3) steps
if <<(x position) > (150)> or <(x position) < (-150)>> then
turn cw (180) degrees
end
if <touching [Player v] ?> then
change [lives v] by (-1)
go to x: (-150) y: (-140)
end
end
end
Cluster F (patrol) plus cluster E (state gate). When it touches the player, lives drop and the slime resets to its starting corner.
Step 6 — predict before clicking
Without running it — what does the player see when the flag is clicked? Pause and answer in your head before reading on.
Step 7 — peek at the answer
The player sees a still cat in the middle-bottom of the Stage, nothing falling, no slime moving. Title screen. The instant they press space, state flips to play and everything wakes up — coins start falling every 1.5 seconds, slime starts patrolling, arrow keys move the cat. Catching a coin: score +1. Touching the slime: lives −1 and the slime resets. The script has no game-over check yet — at 0 lives, the game keeps running. That's the missing piece.
Step 8 — find the missing piece
Where would you add the game-over check? (Inside the Player's gameplay forever, at the top, an if <(lives) < (1)> then that sets state to over. Optionally broadcast broadcast [game-over v] so a separate "Game Over" sprite can show.)
What you just proved: you can read a three-sprite, four-script, clone-based, state-machine game and predict its behaviour cold. The L3 floor is solid. L4 builds up from here.
Try It Yourself — three predict-before-click drills 15 min
Goal: Read this list-and-counter stack and predict what the sprite says. Then build it and check. (Predict first.)
when flag clicked
delete all of [drinks v]
add [teh tarik] to [drinks v]
add [milo ais] to [drinks v]
add [air bandung] to [drinks v]
set [i v] to (length of [drinks v])
repeat (length of [drinks v])
say (item (i) of [drinks v]) for (1) seconds
change [i v] by (-1)
end
Think: Notice i starts at length of [drinks v] (which is 3) and counts down by −1 each loop. So the sprite reads the list backwards: "air bandung", "milo ais", "teh tarik". The pattern is identical to a forward read — only the counter's start and step have changed. (L03-09, L03-12.)
Goal: Read this clone-and-state stack. Predict (1) how many bats are visible 4 seconds after the flag, and (2) what one tap of P does.
when flag clicked
set [state v] to [play]
hide
forever
if <(state) = [play]> then
create clone of [myself v]
wait (1) seconds
end
end
when [p v] key pressed
if <(state) = [play]> then
set [state v] to [paused]
else
set [state v] to [play]
end
when I start as a clone
show
go to x: (pick random (-220) to (220)) y: (pick random (-160) to (160))
forever
if <(state) = [play]> then
move (3) steps
if on edge, bounce
end
end
Think: Spawn rate is 1 clone/second, so after 4 seconds there are about 4 bats drifting and bouncing. P toggles state between play and paused; because every clone gates its own movement on (state) = [play], all bats freeze in place at the same instant — and the spawner also pauses, so no new bats appear while paused. (L03-22, L03-26, L03-28.)
Goal: Read this platformer player loop and predict three things — (1) when the player presses space mid-air, what happens, (2) what happens if they press space while standing on the green ground, and (3) what the maximum jump height looks like in pixels.
when flag clicked
set [velocity-y v] to (0)
go to x: (-180) y: (-120)
forever
if <key [right arrow v] pressed?> then
change x by (5)
end
if <key [left arrow v] pressed?> then
change x by (-5)
end
change [velocity-y v] by (-1)
change y by (velocity-y)
if <touching color [#00aa00] ?> then
set [velocity-y v] to (0)
end
if <<key [space v] pressed?> and <touching color [#00aa00] ?>> then
set [velocity-y v] to (12)
end
end
Think: (1) Pressing space mid-air does nothing — the <> and <> requires touching green too. No infinite double-jumps. (2) On the ground, space sets velocity-y to +12 — the player launches up. (3) After launch, gravity subtracts 1 per frame. The player rises 12, then 11, then 10 … reaching ~78 pixels (the sum 12+11+10+…+1) before falling back. Change the initial jump from 12 to 18 and the leap nearly doubles. (L03-39, L03-40, L03-43.)
Mini-Challenge — Hafiz's frozen clones 5 min
"Why do the stars stop falling on level 2?"
Hafiz built a falling-stars game with two levels. Stars are clones of a single Star sprite. The first level works fine — stars fall, player catches them. The instant level changes from 1 to 2, every existing star freezes mid-fall and no new stars appear. Here are the two Star scripts:
when flag clicked
hide
forever
if <(level) = (1)> then
create clone of [myself v]
wait (1) seconds
end
end
when I start as a clone
show
go to x: (pick random (-200) to (200)) y: (180)
forever
if <(level) = (1)> then
change y by (-4)
if <(y position) < (-170)> then
delete this clone
end
end
end
What's the bug — and what's the smallest fix?
Reveal one valid solution
Both scripts gate on (level) = (1). The spawner only spawns on level 1 (correct enough — he wants different stars on level 2 maybe), but every existing clone also only falls on level 1. The instant level becomes 2, all clones are stuck in their forever loops doing nothing — and they never get their delete this clone call either, so they pile up frozen.
The smallest fix depends on what Hafiz wants. If level 2 should also have the same falling stars, drop the gate from the clone script:
when I start as a clone
show
go to x: (pick random (-200) to (200)) y: (180)
forever
change y by (-4)
if <(y position) < (-170)> then
delete this clone
end
end
If level 2 should have no stars, change the gate to delete the clone when the level changes:
when I start as a clone
show
go to x: (pick random (-200) to (200)) y: (180)
forever
if <not <(level) = (1)>> then
delete this clone
end
change y by (-4)
if <(y position) < (-170)> then
delete this clone
end
end
The lesson: when a clone gates its whole behaviour on a state variable, decide what should happen when the gate flips. Frozen-forever is almost never what you want. L4 cluster D revisits this pattern across boss fights and brick walls.
Recap — the L4 Cold-Memory Reference Card 3 min
You named the eight L3 clusters, predicted three stacks before clicking, read a state-machine coin-run, and untangled Hafiz's frozen clones. From here on, everything below is what Level 4 assumes you remember cold. Print this list. Tape it next to your L3 card. We will not reteach any of it.
- Arithmetic & pick-random
- The four green arithmetic blocks () + (), () - (), () * (), () / () nest like LEGO. pick random (1) to (10) reports a fresh integer each call — perfect for random spawns and rolls. (L03-02, L03-03.)
- List + counter
- A list is many values in one slot. Walk through it with item (i) of [list v] inside a repeat (length of [list v]), incrementing i each pass. Same pattern reads forward, backward, or every-other. (L03-06 to L03-13.)
- My block (define)
- A custom block defined once on a sprite, callable any number of times. Inputs are typed in the "Make a Block" dialog. Tick "Run without screen refresh" for pen drawings and recursion. (L03-14 to L03-19.)
- Clone & when-I-start-as-a-clone
- create clone of [myself v] spawns a live copy. when I start as a clone is the clone's own hat block — runs independently per clone. End each clone with delete this clone, or they pile up and slow the project. (L03-20 to L03-25.)
- Game-state variable
- A text variable like state with values
title/play/paused/over. Every gameplay script gates on it: if <(state) = [play]> then. One source of truth, many scripts. (L03-26 to L03-31.) - Top-down wall collision
- Paint walls one colour. After each move, check touching color [#000000] ? and undo the move if true. The simplest grid-free wall logic in Scratch. (L03-32 to L03-37.)
- Platformer gravity loop
- One variable, velocity-y. Each frame: change [velocity-y v] by (-1) then change y by (velocity-y). Touching the ground resets
velocity-yto0. Jump with set [velocity-y v] to (12) — but only when on the ground. (L03-38 to L03-43.)
Homework 2 min
The L3-Cluster Audit. Pick the two L3 clusters you feel weakest on. Build the smallest possible script that uses each cluster's signature pattern.
- Open a fresh Scratch project. Pick one of the eight L3 clusters you feel weakest on. Build the smallest possible script that uses its signature pattern. (Examples: cluster B → a sprite that adds three foods to a list and says them in order. Cluster D → one sprite that spawns five clones at random positions across the Stage. Cluster G → a sprite that falls under gravity, lands on a green floor at the bottom, and jumps when space is pressed.)
- Save as
HW-L4-01-Cluster-X.sb3where X is the cluster letter. - Repeat for at least one more cluster — pick a different letter.
- Write one sentence per project: "This is the smallest example of cluster X because it uses the signature block …."
Bring back next class:
- At least two
.sb3files and your one-sentence notes. - Your three remix candidates from the Mission above.
- Your answer to: "Which cluster did you skip building? Why does it feel solid enough to skip?" Your answer tells me where L4 can push hard and where to slow down.
Heads up for next class: SCR-L04-02 is the first meta-lesson of L4 — Project Workflow. We'll stop building blocks for an hour and learn the five-step rhythm — plan, vertical slice, playtest, polish, ship — that turns a vague idea into a real 500-block project without drowning.