- Learnt28 min · Make a Block, define, and calling it
- Basic24 min · a show made of calls
- Challenge 1–327 min · a second block, a nested one, one edit
- Extrabonus · a countdown
Review — the Card Battle arc 5 min
- Linear search walks a list until it finds what it wants.
- Bubble sort swaps neighbours until a pass goes by with nothing to swap.
- A swap needs a third box — and lists in step are swapped together.
Quick-fire
Your bubble sort’s nine-block swap appears in three different scripts. You find a bug in it. How many places do you have to fix?
Reveal the answer
Three — and you will forget one. Today is about the Scratch feature that turns that three into one.
Today’s Topic 3 min
- My Blocks — making a block of your own
define launch— the hat that holds the work- Calling it, as many times as you like
- A block that calls another block
Learning outcome
By the end of this lesson you will be able to:
- Make a block and put a stack inside it.
- Call your own block from a script.
- Say why one definition beats three copies.
Learnt — giving a stack a name 28 min
1 · One firework is eight blocks
Here is a firework: a rocket appears at the bottom, glides up, hides, and leaves a burst of clones behind it.
show
set size to (45) %
go to x: (0) y: (-170)
glide (0.4) secs to x: (0) y: (90)
hide
repeat (14)
create clone of [myself v]
end
Now you want three. So you copy it, twice. And now:
- The script is twenty-four blocks and runs off the bottom of the screen.
- To make the bursts bigger you change three numbers, in three places.
- If you miss one, two fireworks are big and one is not, and you will not notice.
How to use this: Click the green flag and watch three fireworks. They look fine — the problem is in the code, not on the Stage.
2 · Make a Block
- Scroll to the bottom of the block palette and click My Blocks.
- Click Make a Block.
- Type
launchas the name and click OK. - A pink
define launchhat appears in your code area. - A pink
launch :: customblock appears in the palette.
define launch
show
set size to (45) %
go to x: (0) y: (-170)
glide (0.4) secs to x: (0) y: (90)
hide
repeat (14)
create clone of [myself v]
end
3 · Calling it
Now the green-flag script says what happens, not how. Three calls, three fireworks:
when flag clicked
launch :: custom
wait (0.9) seconds
launch :: custom
wait (0.9) seconds
launch :: custom
How to use this: Click the green flag. The show is identical to the last one — look at the blocks-used box.
4 · The definition is the one true copy
Change repeat (14) to repeat (30) inside the define hat. Every firework in the show gets bigger, because there is only one place the burst size lives.
Basic — a show made of calls 24 min
Start a new project. A night backdrop and one star sprite is all you need.
Step 1 — the spark
- Add
when I start as a clone. - Under it:
show,set size to (35) %,point in direction (pick random (-180) to (180)). - Then
repeat (12)holdingmove (pick random (6) to (14)) stepsandchange [ghost v] effect by (8). - Finish with
delete this clone.
Step 2 — one firework
- Build the seven-block rocket stack from the Learnt.
- Put it under the green flag and check you get a burst.
Step 3 — make the block
- My Blocks → Make a Block → call it
launch. - Drag your rocket stack out from under the flag and under the define hat.
- Put one
launch :: customunder the flag instead. - Run it. It should be exactly as it was.
Step 4 — a show
- Put
repeat (5)under the flag. - Inside it:
launch :: customandwait (0.7) seconds.
Step 5 — make each one different
- Inside the definition, change the go-to and glide x to
(pick random (-160) to (160)). - Change the glide y to
(pick random (40) to (120)). - Run it. Five fireworks, all over the sky, from one block.
define launch
change [fireworks v] by (1)
show
set size to (45) %
go to x: (pick random (-160) to (160)) y: (-170)
glide (0.4) secs to x: (x position) y: (pick random (40) to (120))
hide
repeat (16)
create clone of [myself v]
end
when flag clicked
set [fireworks v] to (0)
repeat (5)
launch :: custom
wait (0.7) seconds
end
(x position) so the rocket goes straight up.How to use this: Click the green flag and watch five fireworks. Press it again — they land somewhere new.
Nothing happens when I press the flag.
Your stack is under the define hat but nothing is calling it. Drag a pink launch :: custom under the green flag.
The rocket appears but there is no burst.
The when I start as a clone script is missing, or it starts with hide instead of show.
The sparks never disappear and the project slows down.
delete this clone is missing at the end of the clone script. Clones pile up until Scratch refuses to make more.
The rocket goes up diagonally.
The glide has a different random x from the go-to. Use (x position) in the glide so it keeps the one it already has.
A second block
One block is a habit. Two is a vocabulary.
- Make a second block called
finalethat fires three at once. - The script is: launch, launch, finale.
- Somebody reading your script can tell what the show does without running it.
How to use this: Click the green flag: two singles, then three at once.
Teacher note
The naming is the lesson. Ask them to read their script out loud — if it sounds like an instruction to a person, the names are right.
A block inside a block
Your blocks can use each other.
- A
volleyblock that callslaunchthree times. - The script calls
volleytwice. - Six fireworks, and the word “launch” appears once in your whole project.
How to use this: Click the green flag. Two volleys of three, and the counter proves it.
Teacher reveal
define volley
launch :: custom
wait (0.35) seconds
launch :: custom
wait (0.35) seconds
launch :: custom
⚠️ A block must not call itself — not yet. Scratch will let you, and it runs for ever. That is recursion, and it is a Level 4 idea; if a pupil finds it by accident, admire it and then take it out.
One edit, every firework
Prove the payoff. Change the show without touching the script.
- Double the number of sparks in every firework.
- You may change exactly one number.
- You may not touch the green-flag script at all.
How to use this: Click the green flag and compare these bursts with the ones in the Basic above.
Teacher note
Worth pairing with the copy-paste version from the Learnt: ask a pupil to make the same change there and time them. Three edits, and somebody always misses one.
Give the show an opening
A firework show starts with a countdown. Make that a block too, and your script becomes a running order.
- A
count downblock that shows 3, 2, 1, GO! - The script is: count down, then four launches.
- The countdown is big and readable, and the rocket is not.
How to use this: Click the green flag and watch the countdown, then four fireworks.
Teacher reveal
define count down
show
go to x: (0) y: (0)
set size to (90) %
set [count v] to (3)
repeat (3)
say (count) for (0.7) seconds
change [count v] by (-1)
end
say [GO!] for (0.7) seconds
hide
The commonest bug is forgetting set size to (45) % afterwards, so every rocket is enormous. It is a good one to let happen — it makes the “put back what you change” rule land harder than saying it does.
Summary 5 min
- My Blocks → Make a Block gives you a block of your own.
- The work goes under the
define launchhat. A definition does not run by itself. - The script calls it, as many times as you like.
- One definition means one place to fix, and one place to improve.
- A block can call another block. Name each one for what it does.
- My Block
- A block you make yourself, holding a stack you name.
- Define
- The pink hat that holds a My Block’s blocks.
- Call
- Using your block in a script.
- Definition
- The one place a My Block’s work actually lives.
Hand in
Save your show. Next lesson your block learns to take instructions — where to fire, how high, and how big the burst should be.