Help Types

Blitz3D Forums/Blitz3D Beginners Area/Help Types

Christer(Posted 2008) [#1]
Ok I have a custom type called Player this type have 6 players. Let say i want the values of the 4.th player how do i do?
(without using After and Before)


Mortiis(Posted 2008) [#2]
You can use arrays in your custom types.

Dim alien_ID.alien(ALIEN_MAXCOUNT%)

alien_ID(1)=alienNew()

alien_ID(1)\x#=1.0

alienposx = alien_ID(1)\x#

myalien.alien = alien_ID(1)

;Alternative Blitz Array
Global alien_ID.alien[ALIEN_MAXCOUNT%]

alien_ID[1]=alienNew()

alien_ID[1]\x#=1.0

alienposx = alien_ID[1]\x#

myalien.alien = alien_ID[1]


Full version here http://www.hpquest.com/techlord/apps/AOBPwB3D/


Christer(Posted 2008) [#3]
i have tried with this:
Function CreateTile(number2,image2$,x2,y2,tile2)
ANTAL = ANTAL + 1
Dim newp.Tile(ANTAL)
newp.Tile(ANTAL) = New Tile
newp(ANTAL)\x# = x2*50
newp(ANTAL)\y# = y2*50
newp(ANTAL)\number = number2
newp(ANTAL)\image$ = image2$
newp(ANTAL)\tile = tile2
End Function

and later i try in code this:
Text 0,80,newp(StartNumber)\x#

Error: "Object dose not exist"
I have over 2000 tiles and it sould exist.. If i change StartNumber to 1 it wount work either please help...


Warner(Posted 2008) [#4]
If you re-dim an array, it's content gets cleared.
What you can do, is to create the tiles in CreateTile, and use another function, such as RescanTiles to assign an array to them.
Depending on how you want to use this, first you create all tiles using CreateTile, and after that, call RescanTiles once.
Note: code is not tested.