App Inventor Logo
http://ai2.appinventor.mit.edu/

Let's Build an APP

Hi-Lo A classic Number guessing Game

Programming - switch to BLOCKS:

blocks

the BLOCKS screen is where we add scripts and program objects.

Variables first - Click on "variables", you get this flyout:

addVariables

Notice GLOBALS and LOCALS - nicely you can nominate your locals up front if you want, we will be using GLOBALS only in this project, add one (we can clone blocks easily so will do that for the rest)

Then click "math", you get this flyout:

math

Grab a "0" for now, we can edit it later. Notice also the RANDOM call is in there. The "Logic" has true/false when you need it.

Define the following variables:

hiLoVariables Notes:
"mystery" is the number we will try to guess,
"hi" and "lo" are the guess boundaries,
"numguesses" is the number of guesses used by the user
"userguess" will be the users guess and
"gameon" is a flow control variable we will use in endgames later

You will notice that if we float our mouse pointer up to the initialise "name" window, you get a helpful flyout menu:

flyout

...useful if you need to USE the variable's value, or set it to something.

Now let's add EVENT HANDLERS