Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

9. Game #8, Treasure Chest > Creating 2D arrays

Creating 2D arrays

In this game, we want to store the tile map information inside a two-dimensional array. If you don't know what a 2D array is, imagine a table. The first dimension is represented by the rows and the second dimension by the columns. A 1D array is comparable with a table with just one column and several rows.

Here are two illustrations that show the difference:

Creating 2D arrays

In the preceding image, you see an array with one dimension. It has just one column and the data is stored in a sequence, row after row. The following image shows an array with two dimensions. The difference here is that the second dimension is achieved by another column. You have two slots per row to store data. Actually, you will have as many slots per row as you define.


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial