Give the perfect gift for tech-minded kids in your life: 25% off!

dark mode light mode Search Menu

Explore Mars like a Rover

Joe Strout

In this issue of beanz, you’ll find a story about Robots exploring Mars. How would you like to be one?

Just download this search-and-find game for Mini Micro from (You also can use Mini Micro directly in a browser, but then you can’t save your work, so best to get your own local copy.)

Once you have Mini Micro running locally, type reset at the blinking prompt to be sure the memory is clear, then type edit to open the code editor. Carefully type in Example A. Click the Save button in the toolbar to save it, and give it a name like “rover” so you can find it again.

Example A

When you run the game, you should see a big, dusty red field of dirt and rocks. Hidden somewhere in that field are a couple of treasures—a particularly cool rock and some water. But you can only find them using your sensors. As you move your mouse around, listen to the beep. The beeps will get faster and higher-pitched as you get closer to one of the hidden items. (If the sound doesn’t work for you, you can also watch for a number in the upper-left corner that will get smaller as you get closer to a target.) When your mouse is directly over one of the hidden items, you’ll hear a “wow” sound and the name of the hidden item will be revealed.

The first two lines of this program import some helper modules: mathUtil provides the distance function used on line 24, and “sounds” provides the ding and wow sound effects. Then, lines 4-7 set up the screen, drawing a sand texture but with a pink tint to look more like Mars.

Line 9 creates a list that will hold the hidden items, and lines 10-15 define a hide function to add something to this list with a random position on the screen. Lines 17-18 use this function to hide two items. This is a great place to add your own touch: insert a few more hide lines here to hide additional treasures.

Finally, the main loop of the program is lines 20-43. It checks the distance to each hidden item, keeping track of the closest one in closestItem and its distance in minD. These are used to adjust the ding sound (line 30), numeric display (lines 31-32), and the wait interval before we check again (line 33). The if block on lines 34-42 detects when you have gotten close enough to an item to reveal it, and handle that (including removing it from the hidden list on line 39).

Have fun exploring Mars on your computer.







Related Posts