Game Development Reference
You can take this system one step further and add a third or more possible choices by throwing an
additional ahoaeb statement into the mix. Have a look at how this works:
This eb+ahoa statement checks each of the conditions in turn. If the first is b]hoa, it skips to the sec-
ond. If the second is also b]hoa, the final directive in the ahoa block statement is run as the default
This format is perfect for the number guessing game, because you need the program it to check for
three possible conditions:
If the player's guess is less than the mystery number
If the player's guess is greater than the mystery number
If the player correctly guesses the mystery number
To implement this decision making in the program, you need to first find a way of getting the number
from the input text field on the stage into the program so that it can be processed. It is pretty easy
You need to create a new variable called _qnnajpCqaoo to store the number the player enters
in the input text field. You'll use this new variable to convert the text from the input text field
from a string to a number so an eb+ahoa statement can process it.
You need to add an event listener to the cqaoo>qppkj object and then create an event handler
called kjCqaoo>qppkj?he_g that is called when the button is clicked. This is exactly the same as
what you did in the previous two chapters to program the buttons.
You need to create an eb+ahoa block statement inside the kjCqaoo>qppkj?he_g method to
check for the three conditions listed previously.
Let's get to work!
1. Add the following code to your program: