๐Ÿฑ My First Scratch Game ยท Episode 4 of 6 ยท See All Episodes
๐ŸŒ€ Episode 4 ยท Walls ยท Keys ยท 3 Levels ยท Timer

Find the Exit!
Maze Game

Draw your own maze, collect a key to unlock the exit door, and escape before the timer runs out โ€” across three levels of increasing difficulty!

๐Ÿ‘ถ Ages 7+ โฑ๏ธ ~1.5 Hours ๐Ÿฑ Scratch โœ“ Free
๐Ÿ’ฅ Color collision ๐Ÿ“ก Broadcasts ๐Ÿ“ฆ Variables ๐Ÿ—บ๏ธ Multiple levels โฑ๏ธ Timer ๐Ÿ–ผ๏ธ Backdrop switching
โญ
0 XP
Level 1
๐Ÿ”ฅ0
Your Progress0 / 11 steps
1
๐Ÿฑ
Set Up & Draw Level 1 Maze
Open Scratch and draw your first maze as a backdrop
Active
๐ŸŽฏ
Goal for this step

Draw a maze backdrop with blue walls and a black background. The player detects touching blue to bounce back.

๐Ÿ‘จโ€๐Ÿ‘ง
Parent note: In this game, the maze walls are drawn as a backdrop (the background). The player sprite detects when it touches the wall colour and bounces back. Draw large, chunky walls thin walls are hard to navigate and tricky to detect.
  • 1Go to scratch.mit.edu, start a new project and name it "Maze Game". Delete the cat.
  • 2Click the Stage. Click Paint to draw a custom backdrop.
  • 3Fill the entire backdrop with black using the fill bucket tool.
  • 4Select a bright blue colour. Use the Rectangle tool to draw thick walls forming a maze. Leave corridors wide enough to walk through!
  • 5Leave a start gap in the top-left and an exit gap in the bottom-right we'll add the door there.
  • 6Name this backdrop Level1.
๐Ÿ’ก
Make your corridors at least 40 pixels wide. Narrow corridors are frustrating to navigate with a sprite. You can always edit the backdrop later if a path is too tight!
โœ๏ธ
Fill in the Concept
+15 XP
In this maze game, the walls are drawn on the using a bright colour. The player sprite detects walls by checking if it is that colour.
๐Ÿง 
Knowledge Check
+15 XP
In this maze game, how does the player detect walls?
ABy checking if the sprite touches the edge of the screen
BBy detecting when the sprite touches the blue wall colour on the backdrop
CBy using invisible wall sprites placed around the maze
2
๐Ÿง‘
Add the Player Sprite
Create a small character to navigate the maze
Locked
๐ŸŽฏ
Goal for this step

Add a small player sprite that starts in the maze's start gap.

  • 1Click Choose a Sprite. Pick a small character Pico, Nano or any compact sprite.
  • 2Set Size to 30 โ€” smaller than usual so it fits the maze corridors.
  • 3Drag the sprite to the start gap of your maze (top-left area).
  • 4In the Code tab, add: "when ๐Ÿณ clicked โ†’ go to x: (-180) y: (140)" adjust to your start gap position.
๐Ÿ’ก
Check the x and y coordinates of your start gap by hovering over it on the stage the coordinates show in the bottom right of the stage area.
๐Ÿง 
Knowledge Check
+15 XP
Why do we set the player sprite's size to 30 instead of the default 100?
ATo make it move faster
BTo make it invisible
CSo it's small enough to fit through the maze corridors
3
โฌ…๏ธ
Add Movement & Wall Collision
Move with arrow keys bounce back when touching blue walls
Locked
๐ŸŽฏ
Goal for this step

The player moves with arrow keys. Touching the blue wall colour reverses the last move so the player can't pass through walls.

  • 1In the player's code, add a "when ๐Ÿณ clicked โ†’ forever" loop.
  • 2Inside: "if key [right arrow] pressed? then change x by 3". Immediately after: "if touching color [blue]? then change x by -3".
  • 3Repeat for left: "if key [left arrow] โ†’ change x by -3 โ†’ if touching blue โ†’ change x by 3".
  • 4Repeat for up: "if key [up arrow] โ†’ change y by 3 โ†’ if touching blue โ†’ change y by -3".
  • 5Repeat for down: "if key [down arrow] โ†’ change y by -3 โ†’ if touching blue โ†’ change y by 3".
๐Ÿง‘ Player โ€” Movement with wall bounce (right arrow example)
if key [right arrow] pressed? then change x by (3) if touching color [blue]? then change x by (-3) end end
๐Ÿ“–
Use the eyedropper inside the "touching color?" block to pick the exact blue colour you painted. Click the coloured circle โ†’ click the eyedropper icon โ†’ click on the blue wall in the stage.
๐Ÿ’ป
Code Challenge
+20 XP
Fill in the blanks to make the player move left and bounce back if touching the wall:
if key [] pressed? then change x by () if touching color [blue]? then change x by () end end
๐Ÿ’ก Hint: Moving left means x decreases (negative). The bounce-back reverses it (positive same amount).
โšก
True or False โ€” Movement
+15 XP
Pressing the right arrow key increases the sprite's x position.
If the sprite touches a blue wall, it keeps moving in the same direction.
Moving up means increasing the y value (change y by a positive number).
๐Ÿง 
Knowledge Check
+15 XP
Why do we immediately reverse the movement after detecting a wall touch?
ATo make the sprite spin around
BSo the player bounces back and can't pass through the wall
CTo make the game harder
4
๐Ÿ—๏ธ
Add a Key to Collect
Place a key somewhere in the maze find it to unlock the exit
Locked
๐ŸŽฏ
Goal for this step

Place a key sprite inside the maze. Collecting it sets a HasKey variable to 1.

  • 1Make a variable called HasKey. Uncheck it so it doesn't show on screen.
  • 2Click Choose a Sprite and search for "Key". Add it, size to 40.
  • 3Drag the key to somewhere inside the maze โ€” not too easy to reach!
  • 4In the Key's code: "when ๐Ÿณ clicked โ†’ set HasKey to 0 โ†’ show โ†’ forever โ†’ if touching [Player]? then set HasKey to 1 โ†’ hide".
๐Ÿ’ป
Code Challenge
+20 XP
Fill in the blanks to make the key collectible:
when ๐Ÿณ clicked set [HasKey] to () show forever if [Player]? then set [HasKey] to () hide end end
๐Ÿ’ก Hint: HasKey starts at 0 (no key), and becomes 1 when the player touches the key sprite.
๐Ÿ”ฎ
Predict What Happens
+15 XP
Scenario: The player walks over the key sprite, but you forgot to add "set HasKey to 0" at the start. The player plays the game a second time without restarting Scratch. What happens?
AThe key doesn't appear at all
BThe game crashes
CHasKey is still 1 from last game, so the door opens immediately without collecting the key
๐Ÿง 
Knowledge Check
+15 XP
What does "set HasKey to 0" do at the start of the script?
AIt resets the variable so the player starts each game without a key
BIt deletes the key sprite from the stage
CIt makes the key invisible permanently
5
๐Ÿšช
Add the Exit Door
The door only opens once the key is collected
Locked
๐ŸŽฏ
Goal for this step

Place a door at the maze exit. It only lets the player through if HasKey = 1.

  • 1Paint a new sprite draw a rectangle in yellow/gold. Name it Door. Size to fit the exit gap of your maze.
  • 2Drag it to the exit gap of your maze to block it.
  • 3In Door's code: "when ๐Ÿณ clicked โ†’ show โ†’ forever โ†’ if touching [Player]? and HasKey = 1 then broadcast [NextLevel] โ†’ stop this script".
  • 4Add: "if touching [Player]? and HasKey = 0 then say [Find the key first!] for 1 second".
๐Ÿ’ก
The broadcast block (in Events) sends a message to all sprites. We'll use the "NextLevel" broadcast to switch backdrops and move the player. Create it by clicking the broadcast block โ†’ "New message" โ†’ type "NextLevel".
โœ๏ธ
Fill in the Concept
+15 XP
The door checks two conditions: is the player the door, AND is the variable equal to 1? If both are true, it sends a called "NextLevel".
๐Ÿง 
Knowledge Check
+15 XP
What does a broadcast block do in Scratch?
AIt deletes all other sprites
BIt saves the project to the cloud
CIt sends a message that all sprites and the Stage can listen for and respond to
6
โฑ๏ธ
Add a Countdown Timer
Race against 60 seconds to find the key and escape
Locked
๐ŸŽฏ
Goal for this step

A 60-second timer counts down. Running out of time sends the player back to the start.

  • 1Make a variable called Timer (keep it visible on stage).
  • 2Click the Stage (not any sprite). Add: "when ๐Ÿณ clicked โ†’ set Timer to 60 โ†’ repeat until Timer = 0 โ†’ wait 1 second โ†’ change Timer by -1 โ†’ end".
  • 3After the repeat: "say [Time's Up! Try again!] for 2 seconds โ†’ broadcast [Restart]".
  • 4In the Player sprite, add: "when I receive [Restart] โ†’ go to x: (-180) y: (140)" โ€” back to start position.
  • 5Also in the Stage: "when I receive [Restart] โ†’ set Timer to 60 โ†’ repeat..." โ€” restart the timer too.
๐Ÿ’ป
Code Challenge
+20 XP
Fill in the blanks to create the countdown timer:
when ๐Ÿณ clicked set [Timer] to () repeat until (Timer) = () wait () seconds change [Timer] by () end
๐Ÿ’ก Hint: The timer starts at 60, waits 1 second each loop, and subtracts 1 each time until it reaches 0.
๐Ÿ”ข
Order the Steps
+15 XP
Click the steps in the correct order to build the countdown timer:
Wait 1 second, then change Timer by -1
Set Timer to 60
Say "Time's Up!" and broadcast Restart
Repeat until Timer = 0
๐Ÿง 
Knowledge Check
+15 XP
Why do we put the timer code on the Stage instead of on a sprite?
ASprites can't use variables
BThe timer is a game-wide feature, not tied to any specific sprite
CThe Stage runs code faster than sprites
7
๐ŸŸฆ
Draw Level 2
Add a second, harder maze backdrop
Locked
๐ŸŽฏ
Goal for this step

Draw a second maze backdrop with tighter corridors and a shorter timer for more of a challenge.

  • 1Click the Stage โ†’ Backdrops tab. Right-click Level1 and choose Duplicate.
  • 2Rename the copy Level2. Modify the maze make corridors more complex, add dead ends, change the key and exit positions.
  • 3In the Stage's "when I receive [NextLevel]" script, add: "switch backdrop to [Level2] โ†’ set Timer to 45 โ†’ set HasKey to 0".
  • 4Also move the player back to the new start position: broadcast [LevelStart] and handle it in the player.
  • 5Move the Key and Door sprites to new positions matching Level 2's layout.
โšก
True or False โ€” Multiple Levels
+15 XP
Each level uses a different backdrop in Scratch.
You need to reset HasKey to 0 when a new level starts.
The key and door sprites automatically move to new positions when the backdrop changes.
๐Ÿง 
Knowledge Check
+15 XP
When switching to Level 2, why do we "set HasKey to 0" again?
ASo the player must find a new key for Level 2 โ€” the old key doesn't carry over
BTo delete the key sprite
CIt's not needed โ€” the key resets automatically
8
๐ŸŸช
Draw Level 3
The final challenge the hardest maze with the shortest timer
Locked
๐ŸŽฏ
Goal for this step

Create the final level a devious maze with only 30 seconds on the clock.

  • 1Duplicate Level2 and rename it Level3. Redesign the maze to be the trickiest yet many dead ends, key hidden deep inside.
  • 2In the Stage's NextLevel script, add a check: "if backdrop name = Level2 then switch to Level3 โ†’ set Timer to 30".
  • 3After Level 3 is completed, show a You Win! message: "if backdrop name = Level3 then say [You escaped all 3 mazes! ๐ŸŽ‰] for 3 seconds โ†’ stop all".
๐ŸŽ‰
Make Level 3 genuinely difficult you designed it, so you know the solution! But can a friend or parent figure it out in 30 seconds?
๐Ÿ”ข
Order the Steps
+15 XP
Put the game flow in the correct order from start to finish:
Complete Level 2 and switch to Level 3 (30 seconds)
Title screen โ€” click to play
Beat Level 3 โ€” "You Win!" message appears
Play Level 1 with 60-second timer, find key, reach door
๐Ÿง 
Knowledge Check
+15 XP
How many seconds does the player have to complete Level 3?
A60 seconds
B45 seconds
C30 seconds
9
๐Ÿ”Š
Add Sound & Polish
Key collect sound, door unlock jingle and background music
Locked
๐ŸŽฏ
Goal for this step

Add atmosphere with sounds a jingle when collecting the key and tense background music.

  • 1Select the Key sprite โ†’ Sounds tab โ†’ Choose a Sound. Add "Collect" or "Ding".
  • 2In the Key's code, add "play sound [Ding]" just before the hide block.
  • 3Select the Stage โ†’ Sounds โ†’ add a looping background track like "Mysterious Ticking Noise" or "Cave".
  • 4In the Stage's "when ๐Ÿณ clicked" script, add "play sound [Cave] until done" inside a loop, or "start sound [Cave]" to play continuously.
โœ๏ธ
Fill in the Concept
+15 XP
"Play sound until " waits for the sound to finish before running the next block. " sound" plays the sound in the background and moves on immediately.
๐Ÿง 
Knowledge Check
+15 XP
What is the difference between "play sound until done" and "start sound"?
AThere is no difference โ€” they do the same thing
B"Play until done" waits for the sound to finish before continuing; "start sound" plays it in the background and moves on
C"Start sound" plays it louder
10
๐Ÿ 
Add a Start Screen
A title screen that shows before the game begins
Locked
๐ŸŽฏ
Goal for this step

Add a title backdrop with a "Click to Play" message before the maze begins.

  • 1In the Stage's Backdrops tab, add a new backdrop and draw a title screen โ€” write the game name and "Click to Play".
  • 2Name it TitleScreen. Move it to be the first backdrop in the list.
  • 3In the Stage's code: "when ๐Ÿณ clicked โ†’ switch backdrop to [TitleScreen] โ†’ wait until mouse down? โ†’ switch backdrop to [Level1]".
  • 4Then start the timer and send the player to the start position via a broadcast.
๐Ÿ”ฎ
Predict What Happens
+15 XP
Scenario: The title screen says "Click to Play." You used "wait until mouse down?" to detect the click. But what if you accidentally used "wait 10 seconds" instead?
AThe game would never start
BThe game would always start after 10 seconds, regardless of clicking
CThe game would crash
๐Ÿง 
Knowledge Check
+15 XP
What block do we use to pause the game until the player clicks?
A"wait until mouse down?" โ€” it pauses the script until the player clicks
B"wait 10 seconds" โ€” it pauses for a fixed time
C"stop all" โ€” it stops everything until a click
11
๐ŸŒ
Test & Share!
Complete all 3 levels and publish your maze
Locked
๐ŸŽฏ
Goal for this step

Play through all 3 mazes, check everything works, then share it for others to try!

  • 1Press Green Flag and play from title screen through all 3 levels.
  • 2Check: key collection works on each level, door blocks without key, timer resets between levels.
  • 3If walls feel too tight, edit the backdrops to widen corridors.
  • 4Click File โ†’ Save now then Share. Challenge family to escape all 3 mazes!
๐ŸŽ‰
You designed 3 unique mazes and built all the game logic! Can anyone beat Level 3 with only 30 seconds?
โšก
True or False โ€” Final Review
+15 XP
A broadcast can be received by any sprite or the Stage.
You used cloning to create copies of the player sprite in this project.
The "touching color" block uses the eyedropper to match the exact wall colour.
๐Ÿง 
Final Knowledge Check
+15 XP
Which of these did you NOT use in this maze game?
ABroadcasts to switch between levels
BCloning sprites to create copies
CTouching colour to detect walls
DVariables to track HasKey and Timer
๐ŸŽ‰๐ŸŒ€๐Ÿ—๏ธ๐ŸŽŠ๐Ÿšช
You Built a Maze Game!

Three levels, a key, a locked door, a timer and a win screen. You're a proper game designer now!

0
Total XP
1
Level
0
Best Streak
0%
Accuracy
๐Ÿ–ฑ๏ธ Episode 5: Clicker Game โ†’ โญ View My Progress & Certificates

This workshop was free and took many hours to build. If it helped you learn something new, consider supporting the project.

☕ Support on Ko-fi