dark mode light mode Search Menu

Ghost Hunter

It’s Halloween time. So, let’s make a ghost-catching game for Mini Micro.

This program requires at least version 1.2 of Mini Micro, which you can download from https://miniscript.org/MiniMicro. If you don’t already have Mini Micro, or if your Mini Micro doesn’t print “version 1.2” or higher when you launch it, then go get the latest version for your computer from the web page. Then, enter reset at the blinking prompt to clear memory, followed by edit to open the code editor.

We’re going to build the program in two steps this time. Start by carefully typing in Listing 1. Click the Run button (or close the editor and type run), and it should make a cool 3D grid. The for loop on lines 6-9 draws the vertical lines, with some extra math in line 8 to bend them away from the center. Then the while loop on lines 11-16 draws the horizontal lines, with the spacing (dy) adjusted in the floor area to create that 3D effect.

If your display doesn’t look like the picture, then use the edit command again to check your work. Once that’s working, edit again, and finish the game by adding Listing 2. Now when you run the program, the screen will be dark everywhere except for a little circle around the mouse cursor, like a flashlight. Hiding in the darkness somewhere is a ghost. Find it and click it as quickly as you can. How many ghosts can you catch in 60 seconds?

This program uses a technique called object-oriented programming. Line 19 declares ghost as a type of Sprite (a little picture that can be efficiently drawn and moved by Mini Micro). Then lines 22-42 add custom reset, update, and catch functions, which all update the ghost by referring to it as self. With these functions in hand, the main loop (lines 47-58) is relatively simple; it can just say things like ghost.update and ghost.catch to use those functions defined above.

Want to take this program further? Try making the ghost move faster (hint: increase the size of self.dx and self.dy in or after line 25). Or play with the first part of the program, from Listing 1, to change the color of the grid or give it more lines.

Happy Coding!

Learn More

Mini Micro


Make a Game in Mini Micro


Ghost Buster Game