- Learnt27 min · a ball, a paddle, and a bounce you control
- Basic25 min · build the rally
- Challenge 1–327 min · your court, no stuck balls, a rally worth watching
- Extrabonus · two balls, one paddle
Review — where we got to 5 min
Jump Dash is finished and shared. Two of its ideas come with us.
- A controller:
foreverwith anif <key [right arrow v] pressed?> theninside it. - A title screen and a button, which this game will get in three weeks.
Quick-fire
The hare hopped when you pressed a key. What will the ball do if you press nothing at all?
Reveal the answer
Keep going. That is the whole difference: this game runs on its own and you have to keep up with it.
Today’s Topic 3 min
move (6) stepsandif on edge, bouncein a forever loop- Direction, and why 90 and 0 are not the same kind of thing
- A paddle that only moves along one line
- A bounce off the paddle that you choose, not the edge
Learning outcome
By the end of this lesson you will be able to:
- Send a ball round the Stage for ever without it stopping.
- Steer a paddle left and right along the bottom.
- Bounce the ball off the paddle in a direction you decide.
Learnt — a ball, a paddle, a bounce 27 min
1 · A ball that never stops
Two blocks in a forever loop is the whole ball. Everything else in this arc hangs off those two.
- New project, cat deleted, the Neon Tunnel backdrop.
- Add the Ball sprite. Set its size to
70. - Start it in the middle with
go to x: (0) y: (0). - Point it somewhere with
point in direction (pick random (45) to (135)). - Add
foreverholdingmove (6) stepsandif on edge, bounce. - Press the flag and watch it for a minute.
when flag clicked
go to x: (0) y: (0)
point in direction (pick random (45) to (135))
forever
move (6) steps
if on edge, bounce
end
How to use this: Click the green flag and watch the ball bounce. Nothing to press — press the flag again and it starts off in a new direction.
2 · A paddle on a line
The paddle is a controller you have built four times now. The only new thing is that its up and down is missing on purpose.
- Add the Paddle sprite.
- Put it on its line:
go to x: (0) y: (-140). - Build a
foreverwith two ifs in it, for left and right. - Add
if on edge, bounceso it cannot leave the Stage. - Press the flag, click the Stage, and slide it about.
when flag clicked
set rotation style [don't rotate v]
go to x: (0) y: (-140)
forever
if <key [left arrow v] pressed?> then
change x by (-12)
end
if <key [right arrow v] pressed?> then
change x by (12)
end
if on edge, bounce
end
change y by (10) anywhere. The paddle lives on one line and that is what makes the game hard.How to use this: Click the green flag, click the stage once, then hold ← or → to slide the paddle. It stops at both walls.
3 · The bounce you choose
A wall bounce is decided by the wall. A paddle bounce is decided by you, and that is where the game lives.
- Go back to the ball and open its forever loop.
- Add
if <touching [Paddle v]?> thenunder the bounce. - Inside it, point somewhere upward:
point in direction (pick random (-45) to (45)). - Then
move (12) steps, to get clear of the paddle. - Play. Keep it up for as long as you can.
forever
move (6) steps
if on edge, bounce
if <touching [Paddle v]?> then
start sound [Boing v]
point in direction (pick random (-45) to (45))
move (12) steps
end
end
How to use this: Click the green flag, click the stage once, then hold ← or → to slide the paddle under the ball. Nothing is lost yet — the floor still bounces.
Basic — build the rally 25 min
Build the ball first. A paddle with nothing to hit is not worth testing.
Step 1 — the ball
- New project, cat deleted, a dark backdrop.
- Add the ball, shrink it, and start it in the middle.
- Build the move-and-bounce loop.
- Watch it for a whole minute. It must never stop.
Step 2 — the paddle
- Add the paddle and put it on its line.
- Set its rotation style before anything else.
- Build the two ifs and test both keys.
Step 3 — the bounce
- Add the touching question inside the ball’s loop.
- Point it upward and move it clear.
- Play for a minute and count how many bounces you get.
Step 4 — tune it
- Too fast to hit? Take the ball down to 4 steps.
- Too easy? Take it up to 9.
- Change one number, play, then change the next.
Step 5 — the sound
- Give the paddle bounce a sound and the wall bounce a different one.
- Close your eyes and listen to a rally. You should be able to follow it.
The ball goes straight up and down for ever.
The random direction happened to be near 0 or 180. Narrow the range so it always starts at an angle.
The ball shakes on top of the paddle.
The move after the bounce is missing or too small. It has to carry the ball right off the paddle in one go.
The paddle spins.
set rotation style [don’t rotate v] is missing from the flag stack.
The ball goes through the paddle when it is moving fast.
Six steps at a time can jump right over a thin paddle. Slow the ball down, or use a taller paddle costume.
Your court
Pick a place for this game, and make sure the ball can be seen in it.
- A backdrop you chose.
- A ball you can follow across every part of it.
- A paddle that looks like it belongs to the same game.
A ball that never gets stuck
There are two ways this ball stops being a game. Find them both, then make sure neither can happen.
- The ball never ends up travelling flat along a wall.
- The ball never sits on the paddle shaking.
- You leave the game running for two minutes to prove it.
Teacher note — the flat ball, and why it is worth finding
A ball pointing at exactly 90 bounces left and right along the same line for ever. Ranges like pick random (45) to (135) avoid it at the start, but a paddle bounce can still produce it if the range includes 90 or −90.
This is a pupil’s first meeting with an edge case: a value that is legal, sensible, and ruins everything. Worth naming out loud.
Twenty bounces worth watching
Count your bounces and get to twenty. Then look at what those twenty bounces actually looked like.
- A counter on the Stage that goes up on every paddle bounce.
- Twenty in one rally.
- No two bounces sent the ball to the same place.
Teacher note — the counter is next week’s score
A variable set to 0 on the flag and changed by 1 inside the paddle if. It is the same shape as Jump Dash’s score, and next week it becomes one.
Two balls, one paddle
One ball is a rally. Two is a decision, every second, about which one you can still reach.
How to use this: Click the green flag, click the stage once, then hold ← or →. Two balls, one paddle — you have to choose which one to chase.
- Two balls on the Stage, both bouncing properly.
- They start in different places, going different ways.
- Both bounce off the paddle.
- They can pass each other without getting stuck together.
Teacher notes — two sprites or two clones
Duplicating the ball sprite is the straightforward answer and works perfectly. A pupil who tries clones will find that a clone runs the same loop happily — this is a good place to notice that clones are just copies that run the same code.
Balls colliding with each other is not required and is genuinely hard. If a pupil asks, the honest answer is that it needs more than Level 1 has.
Going further: next lesson the floor stops bouncing, and the ball can be lost.
Summary 4 min
A game that runs on its own, and a player who has to keep up with it.
move (6) stepsplusif on edge, bouncein a forever loop is a ball.- Direction counts clockwise from straight up: 0 is up, 90 is right.
- The paddle moves along one line and never changes its y.
- After a paddle bounce, move the ball clear or it bounces again.
- Direction
- Which way a sprite faces. 0 up, 90 right, 180 down, −90 left.
- Bounce
- Turning the ball round. The wall decides one; you decide the other.
- Rally
- A run of bounces with no miss in it.
- Rotation style
- Whether a sprite is allowed to turn. A paddle is not.
Next lesson: the floor stops being friendly, and missing starts to cost something.