UNIT 5: APP INVENTOR 2 (LEARN TO MAKE YOUR OWN APP'S)
Mole Mash - App Inventor 2 - Basic Tutorial
This tutorial shows you how to create MoleMash, a game inspired by the arcade classic Whac-AMole™ , 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.
What You’ll Build For the MoleMash app shown in, 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 of “hits” (increasing it by one), and move the mole immediately to a new location.
• Tapping the screen but missing the mole increments a display of “misses.”
• Pressing a Reset button resets the counts of hits and misses. What You’ll Learn The tutorial covers the following components and concepts:
• The ImageSprite component for touch-sensitive movable images.
• The Canvas component, which acts as a surface on which to place the Image Sprite.
• The Clock component to move the sprite around once every second.
• The Sound component to produce a vibration when the mole is tapped.
• The Button component to start a new game.
• Procedures to implement repeated behavior, such as moving the mole.
• Generating random numbers.
• Using the addition (+) and subtraction (–) blocks.