Chapter 3. MoleMash

MoleMash

This chapter shows you how to create MoleMash, a game inspired by the arcade classic Whac-A-Mole, in which mechanical critters pop out of holes, and players score points when they successfully whack them with a mallet. MoleMash was created by a member of the App Inventor team, ostensibly to test the sprite functionality (which she implemented), but really because she’s a fan of the game.

When Ellen Spertus joined the App Inventor team at Google, she was eager to add support for creating games, so she volunteered to implement sprites. The term, originally coined to describe mythological creatures such as fairies and pixies, was adopted by the computing community in the 1970s to refer to images capable of movement on a computer screen (for video games). Ellen first worked with sprites when she attended a computer camp in the early 1980s and programmed a TI 99/4. Her work on sprites and MoleMash was motivated by double nostalgia—for both the computers and games of her childhood.

The MoleMash user interface
Figure 3-1. The MoleMash user interface

What You’ll Build

For the MoleMash app shown in Figure 3-1, you’ll implement the following functionality:

  • A mole pops up at random locations on the screen, moving once every second.
  • Tapping the mole causes the device to vibrate, increment a display ...

Get App Inventor 2, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.