- Learnt28 min · the wall colour, and move-ask-undo
- Basic24 min · a mouse that cannot leave the corridors
- Challenge 1–327 min · noticing without stopping, too big, a clean run
- Extrabonus · why glide cheats
Review — the Storm Flight arc 5 min
- A
statevariable names the situation, and every script asks it first. - A collision is tested every frame, so a cool-down flag stops one touch being sixty.
wait until <(state) = [play]>at the top of a loop is pause.
Quick-fire
In Storm Flight the parrot could fly anywhere on the Stage. In a maze it must not. Which block already in your toolbox could tell a sprite it has hit something?
Reveal the answer
touching (Bolt v)? — but a maze would need a sprite for every wall. Today’s block asks about a colour instead, and one colour can be the whole maze.
Today’s Topic 3 min
touching color [#1F7A8C]?— asking where you are standing- Why the walls must be one flat colour
- Move, ask, undo — and why the order cannot be changed
- Sprite size against corridor width
Learning outcome
By the end of this lesson you will be able to:
- Stop a sprite walking through a painted wall.
- Explain why the check happens after the move, not before.
- Say why a gradient wall makes the block look broken.
Learnt — the wall is a colour 28 min
1 · A maze is a picture until you say otherwise
Here is a mouse in a maze with no wall check. It behaves exactly as you would expect something that cannot see to behave:
How to use this: Click the green flag and watch the mouse cross four walls without noticing.
2 · The block that asks
touching color [ ]? reports true when any part of the sprite is over that colour. You choose the colour by clicking the swatch and using the eyedropper on the Stage.
3 · Move, ask, undo
Here is the part that surprises everybody. You cannot ask before you move, because touching color [ ]? reports where the sprite is — and where it is is not where it is about to be.
So the order is: move first, then ask, then take the move back if the answer was yes.
change x by (4)
if <touching color [#1F7A8C]?> then
change x by (-4)
end
How to use this: Click the green flag. The mouse walks right and stops dead where the corridor ends.
Basic — a mouse in the corridors 24 min
Start a new project. You are painting a maze and driving a mouse round it.
Step 1 — paint the maze
- Make a new backdrop and fill it with a pale colour for the floor.
- With the rectangle tool, draw your walls in one colour. Use the fill tool, and turn the outline off.
- Leave corridors about as wide as two rectangles of the toolbar — roughly 40 pixels.
- Leave a clear start corner and a clear finish corner.
Step 2 — the mouse
- Add the
Mouse1sprite and set its size to about 35. - Send it to your start corner with
go to x: () y: (). - Add
set rotation style [don't rotate v]so it stays the right way up.
Step 3 — one direction first
- In a
foreverloop, addif <key (right arrow v) pressed?> then. - Inside:
change x by (4). - Then the check:
if <touching color [ ]?> thenchange x by (-4). - Test it. Drive right into a wall and stop.
Step 4 — the other three
- Copy the block for left, up and down, changing the key and the direction.
- Left is
change x by (-4)and its undo ischange x by (4).
Step 5 — count the bumps
- Make a variable
wall bumpsand add one inside each undo. - Drive the whole maze and see how tidily you can do it.
How to use this: Click the green flag and drive with the arrow keys. Try to reach the bottom-right corner.
The mouse walks through walls anyway.
The eyedropper picked the floor, or a slightly different shade of the wall. Re-pick it by clicking the swatch and then clicking the wall on the Stage.
The mouse cannot move at all.
It is too big for the corridor, or it started on top of a wall. Shrink it and check where it starts. This is Challenge 2.
It stops in some places and not others.
Your walls are not all the same colour — usually because some were drawn with an outline on, or one was filled with a slightly different pick.
It gets stuck and will not come back out.
The undo does not match the move. If you move 4 and undo 4 this cannot happen; if you undo 3, it can.
Noticing is not stopping
Take out the undo but keep the check, and count what the check reports.
- The
ifstill asks about the wall. - It counts every time the answer is yes.
- It does nothing else at all.
How to use this: Click the green flag. Watch the counter climb while the mouse keeps going.
Teacher note
Pupils often write the check and stop there, because writing the question feels like solving the problem. This makes the gap visible: the block reports, and reporting on its own changes nothing. The same lesson returns in 3-28, where a guard notices the wall and walks through it.
Too big for the corridor
Set the mouse to 90% and try to drive it anywhere.
- Count the steps attempted and the steps actually taken.
- Work out roughly how small it has to be.
- Write down the rule in your own words.
How to use this: Click the green flag and watch a mouse that fills the corridor try to move.
Teacher note
This is the most common “my maze game does not work” in the whole course, and it does not look like a size problem: the mouse simply sits still, exactly as it would with a broken key check. Teach the diagnosis — shrink it and see — rather than the number.
A clean run
Drive from the start to the cheese without touching a wall once.
- A bump counter that starts at 0.
- A cheese sprite in the far corner.
- A run that reaches it with the counter still reading 0.
How to use this: Click the green flag and watch the route being walked. The counter never moves.
Teacher note
The counter turns a maze into a score, which is worth more than it sounds — it gives the fast finishers something to do that is not “make the maze bigger”. Pairs challenging each other on bump count works well here.
Why glide cheats
Replace the stepping with one glide across the maze, and count how many times the wall check runs.
- One
glide (1.5) secs to x: () y: ()from the start to the far side. - A counter that adds one every time the check runs.
- Read the counter at the end.
How to use this: Click the green flag and watch one glide carry the mouse over every wall in its way.
Teacher note
The “going further” answer is the good bit: twenty short glides with a check between them is stepping, just spelled differently. That realisation — that smooth movement is small movements checked often — is the idea behind every collision system a pupil will ever meet, and it returns as tunnelling in the next lesson.
Summary 5 min
touching color [ ]?asks whether the sprite is standing on a colour.- Paint walls in one flat colour, no outline, no gradient, or the block looks broken.
- Move, ask, undo. The check reports where you are, so you have to go there first.
- Undo exactly what you moved, or the sprite creeps into the wall.
- The sprite must be narrower than the corridor, or it cannot move at all.
- A glide is one block, so nothing can check during it.
- Colour sensing
- Asking whether a sprite is touching a particular colour.
- Collision
- Two things being in the same place when they should not be.
- Step back
- Undoing a move that turned out to be illegal.
- Corridor
- The walkable gap between two walls.
Hand in
Save your maze. Next lesson the movement stops being clumsy — and you meet the three ways it can still go wrong.