Game Development Reference
In-Depth Information
Two-dimensional arrays
A two-dimensional array is an array that holds data in two columns.
Two-dimensional arrays allow for two index numbers to be used, meaning more data cat-
egorization within them.
To initialize a two-dimensional array; type its name, then an open square bracket, the first
index number, a coma, the second index number, a closing square bracket, and then its
value.
The following is a sample of a one-dimensional array being initialized:
The second index number can be seen as a second column in a spreadsheet. Two-dimen-
sional arrays are often used for inventories, where entry 0,0 could be the string apples and
0,1 could be the number of apples the player has.
To access this information, you would type the array name, as well as the index numbers,
for the value you wish to access.
Search WWH ::




Custom Search