Code your own maze game with multiple levels, cool power ups and custom artwork – for ages 7 and up.

Mazes are a great game to make in Scratch, for either new comers or pros. In this guide you’ll learn to design a custom map and then code the game to send you back to the start if you touch the walls or one of the enemy sprites. We’ll also show you how to create cool power-ups to help you whizz past enemies or shrink through tiny gaps.

What you’ll need to get started

  • A laptop with a modern browser
  • An internet connection
Scratch is designed especially for ages 8 to 16, but is used by people of all ages. Millions of people are creating Scratch projects in a wide variety of settings, including homes, schools, museums, libraries, and community centers.

Help support Signals

Get Started

Step 1. Design your level

After visiting the Scratch website, hit CREATE and start a new project.

The first task is to design your maze, so click STAGE on the right hand side and then BACKDROPS. This is where we’ll put our maze artwork.

To design your maze, either use the line tool for straight lines or the paintbrush tool for freehand lines. Its really important that you only use one colour for your maze.

Top Tip: Don’t forget to make your maze big enough for your character to move through. If you need to change your character size, simply click on the sprite and then adjust the SIZE number (below the game window).

Select STAGE and then BACKDROPS

Draw your maze using your chosen colour

Step 2. Make your player move

Now we’ve got our first level, lets get our character moving. In this game the player will navigate the maze with their mouse, with the sprite following them as they move.

So, we want to tell the computer ‘If the computer mouse is touching the sprite, make the sprite go to the mouse’s position’.

We also need to put this selection of blocks inside a forever loop as we want the computer to be constantly checking if the mouse is touching the sprite. If its not inside a forever, it’ll only check once at the start.

 

Step 3. Adding the challenge

In this game, if the player touches the walls they get sent back to the start. For this we’re going to use “colour sensing”.

Your code wants to say “if the sprite is touching a certain colour, then send that sprite back to the beginning”. For this, you’ll need to tell the computer two things. First, what colour and secondly where the beginning is.

The colour and coordinates in the example shown are unique to the map layout, so yours might be different.

Step 4. Adding extra levels

If we want to add extra maze levels to the game, we need something to act as a checkpoint to tell the computer we’ve reached the end of the maze.

Create a new sprite and call it checkpoint, in this example we’ve used a flag from the Scratch library but it could be whatever fits in with your theme!

Now you can design your new levels, but don’t forget to keep the colour exactly the same so the code still works! If you changed colour then the easiest way to find the previous one is to use the pipette tool shown in the second image.

To make the game switch levels, we need to tell it two things. First, what backdrop if needs to show when the game starts and second, what backdrop to display when touching the checkpoint sprite.

Remember, this all needs to go inside the forever loop otherwise it’ll only check once!

Add a checkpoint sprite

Use the pipette tool to find the same colour as level 1 if you changed it

Design your second level, use the points tool if you need to make it bigger or smaller for your player sprite

Add the code to change backdrops when you touch the checkpoint sprite

Step 5. Adding power-ups!

Why not take your game further and add power-ups. Lets add a power-up that allows us to shrink to a tiny size and squeeze through smaller gaps in the maze.

First off, lets add a power-up sprite.

Now, if we add code that says “If player touching power-up sprite, then SET size to 25” – this would shrink the player to a quarter of their size allowing them to squeeze through tiny gaps! Remember, we also need to tell the game what size our player sprite will be when the game starts too.

Top Tip: if you only want your power-up to appear on certain levels, use the “When backdrop switches to…” block in the events tab.

Add a new power-up sprite and insert the new code to the player sprite

Code your power-up sprite so it only appears on the level you want it to with these handy blocks. If you add extra levels, you’ll need to make it hide again too.

Congrats!

Congratulations – you just finished your maze game! What else could you add next? More levels? Sound effects? Heres one we made using this guide – try it out and let us know what you think.

Looking for more creative project ideas?