suppose you wanted to change a list of numbers at frequent intervals, for example the armour left to battle units one to fifty, you could write your game code like this
impact=object hit (bullet,0)
if impact=object1shield
dec object1shield
endif
if impact=object2shield
dec object2shield
endif
.
.
.
.
etc up to
if impact=object50shield
dec object50shield
endif
takes a fair while to type in, now if you use arrays all you tell the computer is that you want to use a variable with a number attached, the number is effectivley part of the variable name, you do it like this
objectshield(4)=12
the tricky bit is that the 4 in the example can be replaced by a variable: eg
objectshield(var)
as long as the variable is within the range of numbers you told the computer to use with the dim statement then you can call them as you wish, using a simple array like this you can do the above code in a few lines
dim objectshield(50)
for i=1 to 50
if object hit(objectshield(i),0)
dec objectshield(i)
endif
next i
that would create and check fifty object numbers for impacts, just like the first code but way easier, you do not have to use them for simple things like that, you can make arrays in 2D
dim twodimensions(100,100)
would make ten thousand numbers placed in a grid 100 across and 100 down, to set the number just use the x and y like this
twodimensions(49,52)=55
this makes a number near the middle of the grid 55, it doesn`t change any of the others, you can make a simple mines game with just that array, make some of the locations 1 and leave the rest at zero, then ask the user where they want to stand
, check that position and then blow them up if it`s set to one.
you can have lots of dimensions eg
dim confusing(20,10,22,44,32,78,9)
but I normaly never go over 3 dimensions: eg:
dim localspace(100,100,100) <<<this uses nearly four million bytes (4mb)
remember that multidimensional arrays eat memory at a progresivly faster rate the deeper you make them, and for integers you need four bytes per number, you can use up memory fast with an array, for example that multi dimensional array example I posted above needs about 16 gig
.
Mentor.
PC1: P4 3ghz, 1gig mem, 2x160gig hd`s, Radeon 9800pro w cooler (3rd gfx card), 6 way speakers.
PC2: AMD 2ghz, 512mb ram, FX5200 ultra, 16 bit SB.
Mini ATX cases suck.