Scratch Maze Game in 30 Minutes: A Free Step-by-Step for Kids

A maze game is the best first Scratch project because it is a real game a child can finish in one sitting — and because every part of it teaches something a later project will reuse. Drawing the maze teaches the paint editor. Moving the sprite teaches events and coordinates. Walls that block teach collision, which is the single most useful idea in game-making. And a timer turns a walk through a maze into a game worth replaying.
This tutorial is written for a parent to sit through with a child aged about 7 and up. No experience is needed. Scratch is free, runs in the browser, and you can start building without creating an account.
Why a maze game first
Most Scratch tutorials start with "make the cat dance" — a sprite that moves and says something. That is fine for five minutes, but it is not a game, and a child knows the difference. A maze game has a goal, a fail state (hitting a wall sends you back), and a win state (reaching the end). Those three things are what make something feel like a game rather than a demo.
It also has the right difficulty curve. The first version — a sprite that moves — takes five minutes. Each step after that adds exactly one new idea. Nothing in this tutorial asks a child to hold three new ideas in their head at once, which is the usual reason a first project falls apart halfway through.
What you need (free, no install)
Go to scratch.mit.edu and click "Create". That opens the editor in the browser — nothing to download, nothing to install, and it works on Windows, Mac, and Chromebook. You can build and test the whole game without an account. Saving the project so you can come back to it tomorrow needs a free Scratch account, which takes about two minutes to create with a parent's email; sharing it publicly is optional and not needed for this tutorial.
One practical note: the editor works best with a mouse or trackpad, because drawing the maze is easier that way than on a touchscreen. A laptop or desktop is ideal; a tablet will work, but the drawing step will be slower.
Step 1: Draw the maze
When the editor opens, you will see a cat sprite on a white stage. Ignore the cat for now — first, the maze. Click the "Backdrop" tab at the bottom left (it says "Choose a Backdrop", then pick "Paint" to open the paint editor).
Choose the rectangle tool, pick a thick line — set the outline width to about 8 — and draw the maze as a set of walls. Keep it simple for the first version:
- An outer border around the whole stage, with a gap at the bottom left where the player starts and a gap at the top right where the goal will be.
- Three or four inner walls that force the player to turn. Straight corridors are fine — the first maze should be easy enough to solve in under a minute.
- One colour for all walls. Use a strong colour that appears nowhere else on the backdrop — dark blue works well. This matters in Step 4, because the game will detect walls by their colour.
- Leave wide corridors. The player sprite is about 50 pixels across, so corridors should be at least twice that wide. Narrow corridors look clever and play terribly.
Now draw the goal: a green circle or star at the top right, on the backdrop, in a colour used nowhere else. Green is the goal colour; blue is the wall colour. Two colours, two jobs — that separation is the whole trick of this game.
When the maze looks right, click the "Code" tab to go back to the blocks. Name the backdrop "Maze 1" by clicking its name — a small habit that saves confusion when the project grows to three mazes.
Step 2: The player sprite
Click the cat sprite, then the "Costumes" tab, and pick a costume that looks like a character rather than a cat — the "Avery" walking character or a simple ball both work well. Or keep the cat; the game does not care, and a child who likes the cat will play longer. What matters is size: click the sprite, and in the size box above the stage, set it to about 50. Too big and it will not fit through the corridors; too small and it is hard to see.
Drag the sprite to the starting gap at the bottom left of the maze. Then, in the code area, note the x and y numbers shown above the stage — something like x: -200, y: -140. Write those numbers down. The game will need them in a moment, because every time the player hits a wall, the sprite has to go back to exactly this spot.
Step 3: Move with the arrow keys
Click the "Code" tab with the player sprite selected. Drag these blocks together in this order:
when green flag clicked
go to x: -200 y: -140
forever
if <key [right arrow] pressed?> then
change x by 4
end
if <key [left arrow] pressed?> then
change x by -4
end
if <key [up arrow] pressed?> then
change y by 4
end
if <key [down arrow] pressed?> then
change y by -4
end
end
Click the green flag. The sprite should now move with the arrow keys — and walk straight through walls, which is expected. Movement first, collision second: that order keeps the two ideas separate in a child's head, and it means there is always a working version to go back to.
If the sprite does not move, check two things: the sprite (not the backdrop) is selected, and the blocks are actually snapped together — a block sitting loose next to the stack does nothing. The forever block is doing the important work here: without it, the code would check the keys once and stop. The loop is what makes the game keep listening.
Step 4: Walls that actually block you
This is the clever step, and it uses colour. Inside the forever loop, after the movement blocks, add:
if <touching color [#0000ff]?> then
go to x: -200 y: -140
end
Click the colour square in the block and use the eyedropper to pick the exact blue of your maze walls. This matters: if the picked colour is even slightly different from the wall colour, the detection will miss. Use the eyedropper on a wall, not on the colour palette.
Click the green flag and steer into a wall. The sprite should jump back to the start. That jump is the fail state, and it changes the game completely — suddenly the maze has to be navigated carefully instead of walked through. If the sprite jumps back when it is not touching a wall, the colour in the block is wrong: re-pick it with the eyedropper. If it walks through walls, the block is outside the forever loop — it must be inside, so it is checked many times a second.
One design choice worth discussing with your child: going back to the start is the strict rule. A gentler rule is to step back one move instead — remember the last safe position and return there. The strict rule is easier to build and easier to understand, which is why this tutorial uses it. The gentler rule is a good second version.
Step 5: Win the game
Add a second colour check inside the forever loop, after the wall check:
if <touching color [#00ff00]?> then
say [You win!] for 2 seconds
stop [all]
end
Pick the green with the eyedropper, from the goal you drew. Now play: steer through the maze to the green goal, and the game announces the win and stops. The game is now complete — it has a start, a fail state, and a win state. Everything after this is polish, and polish is optional, which is the point: a finished simple game beats an unfinished fancy one every time.
Step 6: Add a timer
A timer turns one playthrough into a game worth replaying. At the top of the code, under "when green flag clicked", add:
reset timer
And in the win block, before the "say" block, add:
say (join [You win! Time: ] (join (timer) [ seconds])) for 2 seconds
That looks complicated, but it is just joining pieces of text together: "You win! Time: " plus the timer number plus " seconds". Now the game reports a time, and the obvious next question — "can you beat your time?" — is built in. If the joined-text block is fiddly, a simpler version works just as well: show the timer on the stage (tick the checkbox next to the timer block in the Sensing palette) and let the player read it themselves.
Five ways to make it harder
- A second level. Duplicate the backdrop, draw a harder maze on the copy, and switch backdrops when the player wins level 1. The movement and collision code does not change at all — only the picture does.
- A moving obstacle. Add a second sprite that glides back and forth across a corridor (use
glideinside aforeverloop). Touching it sends the player back to the start, exactly like a wall. Now the game needs timing, not just navigation. - Collect coins. Add small yellow circle sprites. Touching one hides it and adds 1 to a score variable. To win, the player must reach the goal and have collected all the coins — which forces a route through the whole maze instead of the shortest path.
- A countdown. Give the player 60 seconds. If the timer runs out, the game says "Time's up!" and stops. This is the same timer block from Step 6, used as a limit instead of a stopwatch.
- A harder wall rule. Replace "back to the start" with "back to the last safe spot". To build it, store the sprite's position in two variables (safe x, safe y) every half second while it is not touching a wall, and return to those variables on a collision. It is the hardest change on this list, and the most satisfying.
When things go wrong
- The sprite walks through walls: the colour check is outside the
foreverloop, or the colour in the block does not match the wall. Re-pick with the eyedropper. - The sprite jumps back for no reason: the wall colour appears somewhere it should not — often the sprite's own costume contains the same blue. Change the wall colour or the costume.
- The game never says "You win!": the goal colour in the block does not match the drawn goal, or the goal is on the backdrop but the sprite never actually overlaps it. Make the goal bigger.
- Movement is slow or jerky: the "change x by" number is too small (try 5 or 6), or the computer is running many browser tabs. Close the other tabs.
- Nothing happens when the flag is clicked: the code is on the backdrop instead of the sprite, or the blocks are not snapped together. Click the sprite, check the stack is connected.
Debugging in Scratch is visible in a way that text code is not: you can watch the sprite, see the blocks light up as they run, and click any single block to run it on its own. That is why Scratch is a good first environment — the feedback loop is seconds, not minutes.
What your child just learned
In about 30 minutes, this game covers events (the green flag, key presses), loops, conditionals, coordinates, variables (the timer and, later, the score), and collision detection — the core vocabulary of game-making. The next project can reuse every one of those ideas: a chasing game swaps the maze for an open stage, a platform game swaps arrow-key movement for gravity, but the loop-and-decision shape stays the same. That is the real lesson of a first project — not the maze, but the shape underneath it.
Frequently asked questions
What age is this right for?
About 7 and up. A 7-year-old can draw the maze and drive the sprite; a parent can place the blocks while the child decides where they go. The decisions are the learning, not the dragging.
Does Scratch cost anything?
No. Scratch is free, made by MIT, and runs in the browser. An account is free too, and is only needed to save projects and share them. If a site charges for "Scratch lessons" before your child has built anything, you do not need it.
Can we save the game?
Yes, with a free Scratch account — create one from the "Join Scratch" button with a parent's email, then File, then "Save now". Without an account, the project lives only in that browser tab, so do not close it until you have saved.
How long does it take?
About 30 minutes for the working game with a timer. The five harder versions are best spread over a few days — one change at a time, testing after each.
What should we build next?
A chasing game: one sprite chases the player, and touching it ends the game. It reuses movement, collision, and loops, and adds an enemy that moves on its own — which is the next big idea after a maze.
Sources
These are the official, free resources this guide draws on. Prices and program details change — always confirm on the program’s own site before enrolling.