| 
  • If you are citizen of an European Union member nation, you may not use this service unless you are at least 16 years old.

  • Stop wasting time looking for files and revisions. Connect your Gmail, DriveDropbox, and Slack accounts and in less than 2 minutes, Dokkio will automatically organize all your file attachments. Learn more and claim your free account.

View
 

App Inventor - Lesson 3

Page history last edited by Mr. Howard 7 years, 2 months ago

Build the MoleMash Gamescreenshot

Molemash is a simple game in which a mole (or a picture of your little brother) jumps randomly around the screen and you try to touch it to get points. Build this game and learn how to add timing and randomness into your apps.

These lessons come from USF Professor David Wolber's AppInventor.org - A great resource for learning App Inventor.

They are copied here simply because YouTube is blocked at our school.

Steps: (watch the video for each lesson and follow along)


 


Part 1: Design the user interface and make the mole move randomly

Add a canvas, image sprite, and clock, then code blocks so that the mole moves to a new random spot each interval.

Watch the video and follow along. Any code/settings can be also found below the video. 

> Go to http://beta.appinventor.mit.edu/ to begin.

 

In this step you will need one file (also available on S:\Shared\Students\Tech Ed\App Inventor\Lessons\MoleMash). Click the link to save the file to your desktop.
mole.png

 

 


Part 2: Add a point when the user touches the mole

Program the MoleSprite.Touched event to add one to the label showing the score

Watch the video and follow along. Any code/settings can be also found below the video. 

 

 


Part 3: Subtract a point when the user misses the mole

Change the if clause in the Canvas.Touched into an if-else
Watch the video and follow along. Any code/settings can be also found below the video.

 

 


Part 4: Change the app so that an energy bar gets smaller when the user misses

Drag in a label for the bar and define a variable "energy". When the user misses, subtract from energy and change width of label.

Watch the video and follow along. Any code/settings can be also found below the video.

 

 


Part 5: Make the game end when energy is zero

When energy becomes 0 tell the user (text-to-speech) and disable the clock and behaviors
Watch the video and follow along. Any code/settings can be also found below the video.

 

 


Challenges

Do after completing the videos:

  1. MANDATORY (-30 if missing): Add a Start button that enables the clock, resets the width of the health bar, resets the global energy variable to zero, and resets the score to zero.
  2. OPTIONAL: Make the game harder by changing the Timer Event interval to 300ms (making it faster) at 50 points
  3. OPTIONAL: Make the Mole say "Missed me" when you miss and "Ouch" when you hit it.
  4. OPTIONAL: Add a second character that subtracts score when you hit it
  5. OPTIONAL: Add a power up that slows things down for a bit
    HINT: Set a Timer.Interval property in code to change the clock speed

 

Comments (0)

You don't have permission to comment on this page.