- Learnt27 min · counting the wall, the next level, and winning
- Basic25 min · build three levels
- Challenge 1–327 min · your own levels, a front door, every ending
- Extrabonus · a second player at the top
Review — where we got to 5 min
You can clear the wall. But then nothing happens. We fix that today.
- A
repeat (6)lays the row out. Each clone waits to be hit, then deletes itself. - Every break speeds the ball up and shrinks the paddle.
Quick-fire
How does the game know the last target has gone?
Reveal the answer
It does not know yet. A deleted clone leaves nothing behind to count. So a variable does the counting.
Today’s Topic 3 min
- A variable that counts what is left. Scratch cannot count clones for us.
- A builder that takes orders. One loop can make every level.
- Two endings, a win and a loss. Why they must not look the same.
- A title screen and a best score, built like Jump Dash’s.
Learning outcome
By the end of this lesson you will be able to:
- Spot the moment the wall is cleared.
- Build a harder wall from the same loop.
- Give a game a win screen that is not its game-over screen.
Learnt — counting, levels, and winning 27 min
1 · Counting what is left
A deleted clone leaves nothing behind. So the row keeps its own count. The last break takes the count to zero.
- Make a variable called
targets. - In the builder, before the repeat,
set [targets v] to (0). - Inside the repeat, after the clone,
change [targets v] by (1). - In the clone stack, before the delete,
change [targets v] by (-1). - Then ask
if <(targets) = (0)> thenand broadcastcleared. - Play. Clear the row. Watch the number fall to zero.
when I start as a clone
show
wait until <touching [Ball v]?>
start sound [Glass Breaking v]
change [score v] by (10)
change [targets v] by (-1)
if <(targets) = (0)> then
broadcast [cleared v]
end
delete this clone
How to use this: Click the green flag, click the stage once, then hold ← or →. Watch the targets box fall to zero on the last break.
2 · The next level
Now you can ask the builder for a wall. Level 1 asks for one row. Level 2 asks for two.
- Make a variable called
level. Set it to1on the flag. - Change the builder’s hat block to
when I receive [build v]. - On the flag,
broadcast [build v]once. - Put the row repeat inside another
repeat (level). It steps down 60 each time round. - Use
when I receive [cleared v]. Under it, putchange [level v] by (1). Wait, then broadcastbuildagain. - Play until level 2 appears.
when I receive [build v]
hide
set [targets v] to (0)
go to x: (-175) y: (130)
repeat (level)
repeat (6)
create clone of [myself v]
change [targets v] by (1)
change x by (70)
end
set x to (-175)
change y by (-60)
end
How to use this: Click the green flag, click the stage once, then hold ← or →. Clear the first row and the second level builds itself.
3 · Two endings
Now you can win the game. A win must not look like a loss. So each one gets its own screen.
- In the cleared stack, ask
if <(level) = (3)> thenbefore building again. - If it is,
broadcast [you win v]instead. - On the paddle, receive it. Show a different backdrop, a cheer, and the score.
- Check the game over screen still says something else.
- Win it once and lose it once.
when I receive [you win v]
switch backdrop to [Light v]
start sound [Cheer v]
say (join [All three levels! Score: ] (score)) for (4) seconds
stop [all v]
How to use this: Click the green flag, click the stage once, then hold ← or →. Three short levels, so you can actually reach the win screen.
Basic — build three levels 25 min
Build the count first. Nothing else works without it.
Step 1 — counting
- Make the targets variable. Count up as you build.
- Count down in the clone stack.
- Clear a row. Check it stops at zero.
Step 2 — the message
- Broadcast cleared at zero.
- Receive it somewhere and say something. This proves it arrives.
Step 3 — the builder takes orders
- Move the builder onto a receive hat.
- Broadcast build from the flag.
- Check level 1 still looks the same as before.
Step 4 — more levels
- Add the outer repeat and the row step.
- Add 1 to the level on cleared. Then build again.
- Play up to level 3.
Step 5 — the two endings
- Win on level 3 instead of building a fourth.
- Make the win screen look nothing like the game over screen.
- Reach both endings before you leave.
Level 2 builds on top of level 1.
The builder never went back to its starting y. Set the position at the top of the build stack. Do not set it on the flag.
Cleared fires twice.
Two clones reached zero at the same moment. Ask the question before the count changes. Or move the check into the builder.
The level number keeps going up for ever.
The level 3 question is missing. So the game goes on to build level 4, 5 and 6.
The next level starts before the ball is ready.
There is no wait in the cleared stack. Give the player a second to see what they did.
Three levels that feel different
More targets is not a new level. It is the same level again. Give each level its own idea.
- Three levels, each with something the others do not have.
- You can say in one sentence what each level is about.
- You can win all three.
Give it a front door
You built one of these in Topic 1.39. Build the same thing for this game, from memory.
- A title screen with the game’s name and one button.
- Nothing runs until the button is clicked.
- A best score that stays when you lose.
- A way to play again without the green flag.
Teacher note — the second time is the test
This is deliberately a repeat of Jump Dash IV. A pupil who can do it again without the lesson open has learnt the pattern; one who cannot should reread their own project rather than these notes.
A screen for every ending
Write down every way your game can stop. Then check each one has a screen. A player must understand it.
- A list of every way the game can end.
- You test each one, on purpose.
- No ending leaves the player with a stuck Stage.
Teacher note — the endings pupils forget
Losing on the last level, and clearing a level with the last life, are the two that usually have no screen. Both are reachable in a couple of minutes with the lives set to 1 for testing.
A second player at the top
Put a paddle along the top. Give it two keys of its own. The ball can now be lost at either end.
How to use this: Click the green flag, click the stage once, then hold ← or → for the bottom paddle and A or D for the top one. Both paddles are yours — or hand one set of keys to somebody if they are around.
- Two paddles and two sets of keys, all on one keyboard.
- A ceiling that loses the ball, just like the floor does.
- A point to whoever did not miss.
- Both paddles move at the same speed. Both are the same size.
Teacher notes — what has to change, and what must not
The top paddle is a duplicate with two changes: its y and its keys. That is the Space Race rule from Topic 1.32, and pupils who remember it will get this working in five minutes.
The targets have to go, or the two players fight over them. A two-player version is a different game living in the same project, and saying that out loud is worth doing.
Going further: the last arc of Level 1 puts every game you have built behind one menu.
Summary 4 min
Paddle Bounce is finished. It is the first game in the course you can win.
- Scratch cannot count clones, so a variable counts them.
- Put the builder on a receive hat. Then you can ask it for a bigger wall.
- A loop inside a loop builds many rows, not just one.
- A win and a loss each need their own screen.
- Level
- A number the builder reads. Change it and the wall changes.
- targets
- How many are left. It counts up as they are built. It counts down as they break.
- Cleared
- The broadcast that goes out when the last target breaks.
- Win screen
- An ending that looks nothing like the losing one.
Next lesson: the last arc of Level 1. One project with all your games inside it.