- Learnt27 min · a floor, a serve, a score
- Basic25 min · build the game you can lose
- Challenge 1–327 min · a miss you feel, a fair serve, a fair score
- Extrabonus · an extra life you have to catch
Review — where we got to 5 min
The ball bounces off all four walls and off the paddle. You cannot lose yet.
move (6) stepsandif on edge, bounce, for ever.- The paddle bounce points the ball somewhere between −45 and 45.
Quick-fire
if on edge, bounce bounces off the bottom too. So how do we stop that?
Reveal the answer
We do not. We put something in front of the bottom edge. It catches the ball before it gets there.
Today’s Topic 3 min
- A floor sprite in front of the bottom edge.
- A serve. This puts the ball back in play after a miss.
- A score that counts bounces. Three lives that count misses.
- Why a game needs a short wait after a mistake.
Learning outcome
By the end of this lesson you will be able to:
- Take a life when the ball reaches the floor.
- Serve the ball back into play from the middle.
- End the game at zero lives and show the rally you managed.
Learnt — a floor, a serve, a score 27 min
1 · A floor in front of the wall
The bottom edge already bounces. No Level 1 block can turn off just one edge. So we never let the ball reach it.
- Add a second Paddle sprite. Name it
Floor. - Stretch it wide:
set size to (560) %. - Put it low:
go to x: (0) y: (-200). - Check the gap. The paddle sits at
-140. The floor is a thick bar. At-200, only its top edge shows, at about-158. - Give the floor a
go to [back v] layer. Now the ball is always drawn on top of it.
when flag clicked
set size to (560) %
go to x: (0) y: (-200)
go to [back v] layer
show
How to use this: Click the green flag and watch the ball drop onto the bar along the bottom. Nothing to press.
2 · The serve
A miss costs a life. Then the ball goes back to the middle. The short wait matters. If the ball comes back straight away, you can lose it twice.
- In the ball’s forever loop, add
if <touching [Floor v]?> then. - Inside it: a sound,
change [lives v] by (-1). - Then
go to x: (0) y: (0)andwait (1) seconds. - Then
point in direction (pick random (135) to (225)). - Play it. Miss on purpose and watch the ball come back.
if <touching [Floor v]?> then
start sound [Squawk v]
change [lives v] by (-1)
go to x: (0) y: (0)
wait (1) seconds
point in direction (pick random (135) to (225))
end
How to use this: Click the green flag and watch. Every time the ball reaches the floor it costs a life and is served again from the middle.
3 · Bounces are the score
In this game, a long rally is what you want. So the score is the number of paddle bounces. Three misses end the game.
- Make
scoreandlives. Set them on the flag: 0 and 3. - In the paddle-touching if, add
change [score v] by (1). - Under the life being taken, add
if <(lives) = (0)> thenwith a broadcast in it. - On the paddle, receive the message, say the score, and stop all.
- Play three whole games.
when I receive [game over v]
say (join [Longest rally: ] (score)) for (3) seconds
stop [all v]
How to use this: Click the green flag, click the stage once, then hold ← or → to slide the paddle. Three misses and the game is over.
Basic — build the game you can lose 25 min
Open last week’s project. Do not change the ball or the paddle.
Step 1 — the floor
- Add it, make it big, and put it below the paddle.
- Send it to the back layer.
- Check the ball can touch it without touching the paddle first.
Step 2 — losing a life
- Make the lives variable and set it to 3 on the flag.
- Add the floor-touching if to the ball.
- Miss three times on purpose. It should cost three lives, no more.
Step 3 — the serve
- Send the ball to the middle after a miss.
- Add the wait.
- Point it down, in a random direction.
Step 4 — the score
- Make the score variable and set it on the flag.
- Add the point inside the paddle-touching if.
- Play until it reads at least ten.
Step 5 — the ending
- Broadcast at zero lives.
- Receive it on the paddle. Say the score. Stop all.
- Play three games. Write down the three scores.
A single miss takes all three lives.
The ball is still touching the floor the next time round the loop. The go to x: (0) y: (0) must happen before the loop comes round again. Check it is inside the if.
The ball bounces off the floor instead of being lost.
The floor is below the bottom edge. So if on edge, bounce gets there first. Move the floor up.
The score goes up while the ball sits on the paddle.
The move block after the paddle bounce is missing. So the ball counts a bounce again and again.
The ball is hidden behind the floor.
go to [back v] layer is missing from the floor. Or it went on the ball by mistake.
Make a miss hurt
If a life goes quietly, nobody notices. Make a miss easy to see and hear.
- Something you hear.
- Something you see.
- A wait long enough to see what happened.
A serve nobody can complain about
A serve straight at the corner is not fair. Nobody can reach it. Find the range of directions that is fair, and use it.
- A player who is paying attention can reach every serve.
- No serve is too easy.
- You have tried at least ten serves to check.
Teacher note — the range, and the paddle’s speed
Fairness here is a race between the ball and the paddle. A slower serve or a faster paddle both fix an unfair one, and pupils should notice they have two dials, not one.
A score worth comparing
Your score must let you compare two games fairly. You might compare today with tomorrow. Or you might compare your game with a friend’s. Decide what the score counts. Then prove it works.
- You can say in one sentence what the number counts.
- You play two games with the same rules.
- The higher number belongs to the better game, every time.
Teacher note — total bounces or longest rally
Total bounces rewards surviving; longest rally rewards one good run. Both are defensible and the argument is the lesson. Longest rally needs a second variable and a comparison — the same shape as the best score in Topic 1.39.
An extra life you have to catch
Now and then a heart falls from the top. Catch it with the paddle to get a life back. But you cannot chase the heart and the ball at the same time.
How to use this: Click the green flag, click the stage once, then hold ← or → to catch the falling hearts. Lives never go above three.
- A heart falls now and then, not all the time.
- Catching it gives a life back.
- Lives never go above three.
- Missing a heart costs nothing.
Teacher notes — the cap, and where the tension comes from
if <(lives) < (3)> then around the change is what stops a hoard of nine lives. A pupil who skips it will find the game becomes unloseable, which is a fine thing to discover by playing.
The tension only exists if the heart falls somewhere the paddle is not. A heart at pick random (-200) to (200) does that by itself.
Going further: next lesson there is something up there to break, and the ball gets faster with every one.
Summary 4 min
You can lose the ball now. So keeping it up really counts.
- The floor is a sprite in front of the bottom edge. We need it because the edge always bounces.
- A miss costs a life and serves the ball again from the middle.
- The wait after a miss stops one mistake costing three lives.
- Bounces are the score, and three misses end the game.
- Floor
- A sprite across the bottom. Touching it is a miss.
- Serve
- Putting the ball back into play after a short wait. It goes in a new direction.
- Rally
- Bounces in a row with no miss. Some games score this instead of the total.
- Layer
- Which sprite is drawn in front. The floor belongs at the back.
Next lesson: targets to break, a ball that gets faster, and a paddle that gets smaller.