- Learnt27 min · counting the wall, the next level, and winning
- Basic25 min · build three levels
- Challenge 1–327 min · levels of your own, a front door, honest endings
- Extrabonus · a second player at the top
Review — where we got to 5 min
The wall exists and can be cleared. When it is, nothing happens — that is today.
- A
repeat (6)lays the row out; each clone waits to be hit and 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, yet. Deleted clones leave nothing behind to count, so a variable has to do the counting instead.
Today’s Topic 3 min
- A variable that counts what is left, because clones cannot be counted
- A builder that takes orders, so one loop can make every level
- Two endings: winning and losing, and why they must look different
- A title screen and a best score, the same shape as Jump Dash’s
Learning outcome
By the end of this lesson you will be able to:
- Notice the moment a 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 tally, and the last break is the one that reaches 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, and 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
The builder becomes something you can ask for a wall. Level 1 asks for one row; level 2 asks for two.
- Make a variable called
leveland set it to1on the flag. - Change the builder’s hat block to
when I receive [build v]. - On the flag,
broadcast [build v]once. - Wrap the row-building repeat in another
repeat (level), stepping down 60 each time round. - On
when I receive [cleared v]:change [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
The game can now be won. A win that looks like a loss is worse than no win at all, so they get different screens.
- In the cleared stack, ask
if <(level) = (3)> thenbefore building again. - If it is,
broadcast [you win v]instead. - On the paddle, receive it: a different backdrop, a cheer, and the score.
- Check the game-over screen still says something different.
- 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
The count comes first. Nothing else works without it.
Step 1 — counting
- Make the targets variable and count up as you build.
- Count down in the clone stack.
- Clear a row and check it lands exactly on zero.
Step 2 — the message
- Broadcast cleared at zero.
- Receive it somewhere and say something, just to prove 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 exactly as it did.
Step 4 — more levels
- Add the outer repeat and the row step.
- Raise the level on cleared and 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 one.
- 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, not on the flag.
Cleared fires twice.
Two clones reached zero in the same frame. Ask the question before the count is changed, or move the check into the builder.
The level number keeps climbing for ever.
The level 3 question is missing, so the game builds level 4, 5 and 6 quite happily.
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 twice. Give each of yours one idea.
- Three levels, each with something the others do not have.
- You can say in one sentence what each level is about.
- All three are winnable.
Give it a front door
You built one of these in Topic 1.39. Build the same thing here, from memory, for this game.
- A title screen with the game’s name and one button.
- Nothing runs until the button is clicked.
- A best score that survives losing.
- 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.
Every ending accounted for
Write down every way your game can stop. Then check each one has a screen a player would understand.
- A list of every way the game can end.
- Each one tested, on purpose.
- None of them leave the player looking at a frozen 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, and let the ball 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, two sets of keys, both reachable at one keyboard.
- A ceiling that loses the ball, the same way the floor does.
- A point to whoever did not miss.
- Both paddles move at the same speed, and 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, and it is the first game in the course you can win.
- Clones cannot be counted, so a variable counts them.
- A builder on a receive hat can be asked for a bigger wall.
- A loop inside a loop builds rows instead of a row.
- Winning and losing need different screens, or neither means anything.
- Level
- A number the builder reads. Change it and the wall changes.
- targets
- How many are left. Counted up as they are built, 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 of your games inside it.