Game Development Reference
Fig 1.25 A conceptualization of the
memory allocation, which occurs from
Listing 1.9 .
One thing to note from Listing 1.9 is the way characters and strings are given
values. A single character is enclosed in single quotes and a string in double
quotes. The reason being that if they were not, the compiler would consider
them to be other variable names.
This brings us to another matter about naming variables. Variables can be
named anything you like, keeping in mind the following. Variable names
must start with a letter or number (e.g., myNumber, x, 7number,
cannot contain spaces (e.g., my Number)
cannot be the same as a reserved word [these are the key words used
in the programming language (e.g., var, for, function, transform)]
cannot be the same as another variable unless it's in a different
function (e.g., var x:int = 10; var x: char = 't' )
Also keep in mind that variable names can make your code more readable
and can reduce the need for comments. For example,
x = 10;
is ambiguous, whereas
accountBalance = 10;
has more meaning.
You will notice the use of capital letters in some of the variable names
shown beforehand. This is just one convention of using several words in the