Arrays in LiveCode are "associative tables" so you are not restricted to numerical indexing. However, numerical indexing of 10 rows with 10 columns each is a perfect use case here.NRobb2 wrote:Basically I have created the board currently by using lots of image fields, and setting their location 1 by 1 in the code. However, I need to have used a 2D array somewhere in my project for it to be at Advanced Higher, and we have not yet been taught 2D arrays so I have very little ideas as to where this could be included within snakes and ladders.
Space 1 is the square on row 1, column 1. You can refer to it in an array of your choosing with numerical indexing thus:
tBoardLocA[1][1]
Space 47 is the square on row 4, column 4 (oddly enough... Because the board numbers go back and forth in snakes and ladders). However, depending on what you are storing in the array (eg the space location) you could possibly ignore that and just as easily say it is array reference tBoardLocA[4][7].
If you
Code: Select all
put "200,300" into tBoardLocA[4][7]
Code: Select all
move image "player1.PNG" to tBoardLocA[4][7] in 3 seconds
Having said all that, although a grid of 10 x 10 is a perfect use case for a 2d array, I think I would do it differently in this situation, but there is no reason you can't.