Game Development Reference

In-Depth Information

w

kqplqp*patp9Pd]p#opkkhks*'Xj'c]iaOp]pqo7

_da_gC]iaKran$%7

y

ahoa

w

kqplqp*patp9Ukqckpep7

c]iaSkj9pnqa7

aj`C]ia$%7

y

y

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

an example:

_kilqpanoCqaoo9$-,,+.%7

Hey, can you see where you're going with this? I'm not going to spoil your fun of figuring out the

rest!