Game Development Reference
In-Depth Information
Figure 14.2
Examples of variables.
Understanding Constants
Constants are values that stay the same through the course of a program. If you
take a moment to consider things in real life, you can probably come up with
some quite easily. Here are some real-life and programming constants:
n The player
'
s name : The name of the player, in most cases, is unlikely to
change.
n NI number : National Insurance/security number. Or any type of number
given to you by the government, such as a driving license number or
social security number.
n Bank account number : The account number for your bank.
n Conversion value : Perhaps you want to convert grams into ounces, or
stones into pounds. You would store the values that you want to
convert by.
Some of these constants may change at some point in a person
s lifetime; for
example, you might want to change your bank, but programmers use constants
in a game when they know that the value won
'
'
t change. So if you know the
player won
t change their account number while playing as this particular
character, you can make the value a constant.
'
 
Search WWH ::




Custom Search