Mouse Maze (Part 3)

Making Better Mazes

Now we’ve got a mouse that has to follow the rules to go through a maze, but the maze looks boring. The walls always have to be black! That’s no fun. The good news: there’s another way to do it that lets you make a maze any color you like! Instead of drawing on backgrounds, we’re going to use a sprite.

Getting Ready

Before we start we need to clear out some things.

Delete all backgrounds so you’re left with a single all-white background.

Remove the “if touching color” block from the mouse’s sensing code. We’ll be putting something else there.

Create a new sprite. Name it Maze. Draw your maze with any colors you like, but keep the path empty. As you draw it you may need to move it around so it covers the whole screen.

Go back to the sensing code on the mouse sprite. Insert the “touching mouse pointer” block, and change it to “touching Mazes.”.

Now you can use any color you like. You can even insert images!

Multiple Mazes

Multiple mazes are easy, but we have to broadcast a message from the mouse to make it work.

Add a costume of each maze to the Mazes sprite. You can add as many as you like.

This example only has three mazes, but you can make a lot more than that.

Now go back to the sensing mode on the mouse. Take out the “next backdrop” block and add the “broadcast message” block (it’s in “Events”) to the “sensing cheese” if statement. Click “message1” the select “New message”:

Name the new message “Next Maze” and select OK.

Switch to the mazes sprite and add the code that tells the sprite to switch to the next costume when it gets the “Next Maze” message.

And you have multiple mazes!


If you want to make sure players always start on the same maze, you can add this code (change the costume name to the name of the maze you want to start on):

If you want to make sure players won’t cheat by dragging the mouse to the cheese (or the cheese to the mouse) you can set the sprites to “not draggable” by adding the drag mode block to the top of the code for each sprite:

…and that’s it! I look forward to seeing the mazes you create!