6. Cheese and mouse maze

Cheese and mouse maze

The mouse is very hungry and wants to eat the cheese as quickly as possible. We are making a game where you have to guide the mouse through a maze to get to the cheese. If that works, we can make the game even more difficult (cats in sight!).

You may use other scripts (eg a knight and a princess), but you must be sure to follow all programming steps as prescribed.

You learn to:

  • upload your own sprite (searched via eg Google)
  • control by using the arrow keys

Register before you start the exercise. Click the button below and sign up.

Click here


Take a look at the example and consider the following questions:

  • What should I do?
  • What are the goals?
  • What are the expectations?
  • What can I already do?
  • What do I still have to discover?

Try to bring the mouse to the block of cheese. This can be done using the arrow keys. The cats must not get to you and you must not touch the black lines of the maze.


View the steps at 'perform'. Then answer the following questions:

  • Which steps should I follow?
  • Which steps can I follow?
  • How much time do I need?
  • What tools do I need?


Do the steps one by one. Do you not remember how to do it? View the hints or download the solution.


You already know it: open the online Scratch editor and delete the cat sprite.

Choose a suitable backdrop ("playing field"). Preferably use a neutral backdrop. We do not choose a backdrop from the library this time, but go to Google. Save your chosen photo locally on your computer, for example on the desktop. Then you choose "upload backdrop".


Also add two new sprites (eg mouse and cheese cube) and place them in two opposite corners. Adjust the size.
If you cannot find a suitable drawing in the library, you can upload a photo yourself. Search via Google and save your chosen photo. To upload a sprite, use the following icon:



Draw the maze. You can choose the color yourself. You already learned how to draw a drawing on a playing field in one of the previous exercises. Do you still remember? You can also adjust the thickness of the lines. Use straight lines.



To draw horizontal or vertical lines, hold down the Shift key while drawing the lines (the up arrow).


We want to make our sprite (the mouse in our example) move.

What has to happen:

the mouse should move when the arrow keys are pressed.
the code should start when the green flag is clicked.
the mouse must always start at the same place (x and y coordinates)
The arrows left and right: affect the x coordinates (horizontal line).
The up and down arrows: affect the y coordinates (vertical line).

Think carefully!

Click on the green flag and test if you can indeed make your sprite move with the arrow keys.


If you hit the walls of the maze, you have to go back to the beginning. You can make your sprite say something when it hits the fence (eg "Au" and / or "try again!"). Then the mouse returns to the beginning. Can you design this block and put it in a logical place?

Think for yourself before using the hints.


You are won if you can move sprite 1 (the mouse in the example) to sprite 2 (the cheese cube in the example).

How can you let the player know about this? Make sure the whole game stops after that.


We're making it harder: cats lurking! Choose a sprite (a cat in the example) and add it to the playing field. Select the sprite by clicking on it and program the code.

The cat must always move and turn around at the edge.

To make the game more difficult, you can insert multiple monsters by always making a copy of the original sprite.
Select the sprite, press your right mouse button and select "duplicate". In the example, a total of three cats have been inserted.


Can you create a code that will make sure that when the mouse touches the cats, the message "GAME OVER" appears?

Is everything working? Well done!
You can now make the monster move differently, make more monsters, make sliding doors, locks and keys and create different mazes. Everything is possible!


Look back at the project you just made. Ask yourself the following questions:

  • Does the program work as I expected? Why / why not?
  • What works well?
  • What works less well?
  • How can I approach it differently?


Click on the link below to download a sample solution.


Upload the project in Scratch. Click the button below and follow the steps.

Click here