Game Development Reference
5. Save the I]ej*]o file and test the program. You should now be able to enter your guesses by
pressing the Enter key on the keyboard.
Don't worry if you don't understand all the new code just yet; all will be revealed in the next chapter!
Turning the tables
A more advanced project that's fun to try is to change the game so that the computer needs to guess
a number that you're thinking of. This will be a completely new program, but you currently have all
the skills you need to make it work.
Want to give it a try? Here's a hint: to get this game working, you'll need to use a division operator .
You've already seen the multiplication operator:
You used the multiplication operator to multiply the random number by 100. The division operator
looks like this:
It's a simple forward slash. You can use it in any directive to divide two numbers:
This example gives a result of 50. You can then assign this calculation to variable in a directive. Here's
Hey, can you see where you're going with this? I'm not going to spoil your fun of figuring out the