That Blue Square Thing

Scratch Programming - The Mouse Maze Game

This is a complete (but not very good!) game. It features a little mouse trying to navigate the maze to get to some cheese. It uses the arrow keys in a really simple fashion.

Code iconThe original Mouse Maze game with inefficient code - you may need to right click and Save as to save the game to your computer

Note that this a Scratch 2 project. It needs version 2 of Scratch to work!

The Mouse Maze game is pretty lame (but all my own work). There's lots that could be done to improve it. Better graphics and more levels make sense. Perhaps a scoring system or a timer of some kind. A start screen would be good with some instructions. Then you could get really complex and use your imagination (some poisoned cheese perhaps?).

The key teaching element of the program code here is to try to simplify it. I started by including code after each button click to move the mouse, check if it is touching red and deal with the sound and move if it is and finally check if it is touching yellow (in which case you win and go to a second backdrop).

That code isn't very efficient though. This means that it's got lots of repeated code in it which fills up the script section very quickly.

To simplify the code I've sent messages. These messages can then be coded just once rather than four times. This makes the code much more efficient to run and it's much easier to work out what the program is doing.

Code iconThe improved Mouse Maze game - you may need to right click and Save as to save the game to your computer

Making code more efficient like this is really good programming style. In more complex languages you'd say you were calling a function, method or sub-routine. It's the same idea - code once to save time and make your code easier to understand.

PDF iconCode details - walks you through the code and how I simplified it.

The Mouse Maze game is all my own work. It is released under the Creative Commons Attribution-ShareAlike 2.0 Generic licenseexternal link icon. In other words, use it however you like, but give me credit for using it (and link to here please if you put it online)

Using Scratch

Scratch is available free on the web without having to log in or download anything.

There are basic instructions on the my first Scratch page.

> Start using Scratch on the webexternal link icon