Array creation

BlitzMax Forums/BlitzMax Programming/Array creation

Raz(Posted 2006) [#1]
Hey,

I would like to store the level information for my game in an array. Each level has 9 variables, and in total I would like to store information for 50 levels.

To do this for 3 levels...
Global LevelArray[][] = [ [0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0] ]


I know this is probably deadly obvious, but how do I easily do it for 50 levels (without a reeeeeeally long command)
ta!


H&K(Posted 2006) [#2]
use .. (It means continue on next line)
You still have a really long command, but now its over lots of lines

But someone will say load it in from a text file. Bound to.


Raz(Posted 2006) [#3]
ahh wow, ok cool thanks, bit suprised that that's the way of doing it!


H&K(Posted 2006) [#4]
Hang on They are not All zero are they?


Raz(Posted 2006) [#5]
to start with they are (i was under the impression its good practice to "format" an array before use)

I was half expecting to be able to do it with a for loop (like you can easily if its a normal 1d array), but i think im missing something!


H&K(Posted 2006) [#6]
Right, if all the elements are going to be the same size, then allocate

as: Array:int [,] = New Int[50,9]

Then for f and for g
loop 50 F
Loop 9 G
Array[f,g] = 0
next,next


The .. thing was when I thought you were actually entering data into the array


Raz(Posted 2006) [#7]
ahh there we go, thank you:)