< Previous | Contents | Next >

Using Multidimensional Arrays

As youve seen, sequences are great for games. You can use them in the form of a string to store a players name, or you can use them in the form of an array to store a list of items in an RPG. But sometimes part of a game cries out for more than a linear list of things. Sometimes part of a game literally requires more dimension. For example, while you could represent a chessboard with a 64-element array, it really is much more intuitive to work with it as a two- dimensional entity of 8 8 elements. Fortunately, you can create an array of two or three (or even more) dimensions to best fit your games needs.


 

Introducing the Tic-Tac-Toe Board ProgramCreating Multidimensional ArraysIndexing Multidimensional Arrays