Customizing arrays with types ?

Blitz3D Forums/Blitz3D Beginners Area/Customizing arrays with types ?

Psycoach(Posted 2003) [#1]
Well, I am working on a game partly based on a minesweeper princip, where each of my cells have several caracteristics.

Until now, I have used several arrays to store the different properties of my cells (visible/unvisible, XValue, YValue...).

As a cell is always composed of the same properties, I thought it would be a good reason to try to make use of Blitz's 'type' possibilities.

The trouble is, I need to be able to address each cell individualy (among several reasons because of recursivity).

Is it possible to use something like :

Type CellProperties(100)
Field X
Field Y
Field Visibility
End Type

And if yes, are there restrictions to that ?
(I prefer to ask and know the contraints in advance, because if I use that, I'll have to re-write a very part of my code...)

Thank a lot in advance for any help ! :-)


Koriolis(Posted 2003) [#2]
You can't do i that way. Remove the "(100)" and the compiler will be happy. Then, to address your cells randomly, you can do an array of CellProperties:
Dim myCells.CellProperties(99); makes a global array of 100 CellProperties
For i = 0 to 99
    myCells(i) = New CellProperties
    myCells(i)\x = <something>
    <etc...>
Next

If you don't want to have your array global, then create a type that will hold your cells:
Type Level
    cells.CellProperties[99]
End Type
The rest is just the same (replacing '(' and ')' by '[' and ']')