Learning Goals 3 min
By the end of this lesson you will be able to:
- Explain in your own words what
if on edge, bouncechecks before it does anything. - Place the block after a move so the cat turns round instead of getting pinned to the edge.
- Predict what the Direction box will read after a bounce off any of the four edges.
Warm-Up 7 min
Your cat can go anywhere in the garden and face any way. But there is one thing it still handles badly, and you have probably already seen it happen.
Quick-fire puzzle
Daniel built this script and clicked the flag three times. The cat began at the centre. What happens on the third click?
when flag clicked
move (200) steps
Reveal the answer
Click 1 takes the cat from 0 to 200. Click 2 tries for 400, but the Stage stops it at 240. Click 3 does nothing at all — the cat is already against the edge and there is nowhere further to go.
The cat is not broken. It is simply still facing right, with no right left. Today’s block notices that situation and turns it round.
New Concept — bouncing off the edge 15 min
Think of a ball rolling across a room. When it meets the wall it does not stop dead or pass through — it comes back. if on edge, bounce gives your sprite that same behaviour in one block.
Blocks reference
| Block | Category | What it does |
|---|---|---|
if on edge, bounce | Motion | Checks whether the sprite is touching an edge. If it is, flips the heading round and nudges it back inside. If it is not, does nothing whatsoever. |
It asks a question first
This is the first block you have met that decides something. Every block so far has simply done as it was told. This one looks at the Stage first and only acts if the answer is yes.
That is why dropping it into the middle of the garden appears to do nothing — the cat is not touching an edge, so the honest answer is “no”, and the block moves on.
What a bounce actually changes
Watch the Direction box while this happens. Bounce off the right edge and 90 becomes -90. Bounce off the top and 0 becomes 180. The bounce is really just a very well-timed change of heading — the thing you spent all of last lesson learning to control.
The block in a stack
when flag clicked
go to x: (0) y: (0)
point in direction (90)
move (250) steps
if on edge, bounce
Order matters, again
The bounce block has to come after the move. Put it before, and it asks its question while the cat is still safely in the middle, gets the answer “no”, and does nothing useful.
Why it matters
Without this block, sprites pile up against the edges and freeze. With it, they keep going forever. Almost every Scratch game with something moving on its own uses it somewhere.
Worked Example — Mei Ling’s bouncing cat 15 min
We build the stuck version first, on purpose, so that the fix is worth having.
Step 1 — Reset, face, travel
Build the four-block stack: when flag clicked, go to x: (0) y: (0), point in direction (90), then move (250) steps.
when flag clicked
go to x: (0) y: (0)
point in direction (90)
move (250) steps
Step 2 — Watch it get stuck
Click the flag. The cat shoots to the right edge and pins there. Read the Direction box: still 90. The cat is facing off the Stage, which is why another click achieves nothing.
Step 3 — Add the bounce
Scroll down the Motion category to if on edge, bounce and snap it on the bottom.
Step 4 — Run it again and read the box
The cat reaches the edge, then flips to face left. The Direction box now reads -90 and the cat itself appears mirrored. Nothing moved — only the heading changed.
Step 5 — Prove the bounce is doing the work
Temporarily drag the go to x: (0) y: (0) and point in direction (90) blocks out of the stack, leaving just the hat, the move and the bounce. Now click the flag repeatedly.
The cat crosses to the right, bounces, crosses back to the left, bounces again, and keeps going with every click. That is the behaviour the whole arc has been heading toward — you are simply supplying the repetition by hand.
Step 6 — Put the reset blocks back
Snap the two reset blocks back on top. A predictable start is worth more than a party trick, and next lesson’s finale depends on it.
What changed: your cat can now meet the end of the garden and deal with it. That was the last thing standing between you and a project that runs by itself.
The full assembled stack (your reference)
when flag clicked
go to x: (0) y: (0)
point in direction (90)
move (250) steps
if on edge, bounce
Try It Yourself — three small builds 12 min
Goal: Bounce off the left edge instead. Predict what the Direction box will read afterwards before you click.
when flag clicked
go to x: (0) y: (0)
point in direction (-90)
move (250) steps
if on edge, bounce
Think: a bounce turns the heading round. Going in at -90, the cat comes out at 90 — exactly the reverse of the right-edge case.
Goal: Bounce off the top. The same block, an edge you have not tried yet.
when flag clicked
go to x: (0) y: (0)
point in direction (0)
move (200) steps
if on edge, bounce
Think: the top edge sits at y = 180, so 200 steps is more than enough. Heading 0 becomes 180 — the cat now points at the ground.
Mini-mission: there and back in one click. Get the cat to cross the garden, bounce, cross all the way back, and bounce again — without you touching the flag a second time.
It works if: a single click sends the cat to one edge, turns it round, sends it to the opposite edge, and turns it round again — leaving it facing its original direction. Stay within 8 blocks.
Think: after the first bounce the cat is at one edge facing the other way. How far is it from there to the far edge — and is one move block enough to cover it?
Mini-Challenge — thank the wall 5 min
“The polite cat”
Send the cat into the edge of the garden and have it react — but only after it has turned round, not before.
It works if:
- One flag click runs the whole thing.
- The cat visibly reaches an edge and turns round.
- The bubble appears after the turn, with the cat facing the new way.
- You used only blocks from this lesson and earlier.
Reveal one valid solution (teacher)
when flag clicked
go to x: (0) y: (0)
point in direction (90)
move (250) steps
if on edge, bounce
say [Terima kasih, dinding!] for (2) seconds
Six blocks. The interesting error is putting the say block before the bounce — it still runs, but the cat speaks while still facing the wall, which is exactly the ordering point.
Recap 2 min
The bounce block asks one question — am I touching an edge? — and only acts if the answer is yes. When it does act, it turns the sprite’s heading round and nudges it back inside. It has to come after the move, it works on all four edges, and it is the first block you have met that makes a decision instead of just following orders.
- if on edge, bounce (block)
- Turns a sprite’s heading round if it is touching an edge of the Stage. Does nothing if it is not.
- Edge
- Any of the four borders: left x = −240, right x = 240, top y = 180, bottom y = −180.
- Bounce
- A change of heading caused by meeting an edge. Right-edge bounce turns 90 into −90.
Homework 1 min
The boomerang cat. One click, two edges, two bounces — and the cat back where it started, facing the way it began.
- Build the seven-block stack below.
- Click the flag once and watch both bounces.
- Read the Direction box afterwards. It should match what it was at the start.
- Screenshot your Script Area.
when flag clicked
go to x: (0) y: (0)
point in direction (90)
move (250) steps
if on edge, bounce
move (500) steps
if on edge, bounce
Bring back next class:
- A screenshot of your seven-block Script Area.
- Your answer to: “If you deleted the second bounce block, where would the cat end up and which way would it be facing?”
Heads up for next class: SCR-L01-14 is the arc finale. Everything from these eight lessons comes together into one Cat’s Garden Stroll you save and show.