Monday, September 7, 2009

2D arrays

About 2D arrays  

There is a game that is called Tic Tac Toe. It is a great game to understand how 2D arrays work. If you don't know what an array is, I would suggest searching for it online and doing some background work, or looking at my previous post about a 1D array. Basically a 2d array is just a group of items that are arranged in rows and columns. An example of an application that uses 2d arrays is Microsoft Excel. You have items that are in a row and column. Another example is Tic Tac Toe. That is a 3 X 3 array. That means that there are three rows and three columns. The thing to remember is that rows are first and columns are second. So in a 3 X 3 array, just say you have buttons (see picture). To set the name of the top right item, type:
button[0][2]="green arrow";






Another example is the starburst candy, which is a continuation from the last post (can't you see I love candy?)




Always remember to start counting at Zero, not 1.
If you have any questions, just email me at joseph@uthinksmart.com


No comments:

Post a Comment