I've been trying to find a tutorial on this because I thought it must have been asked a lot, I got to this stage within a few minutes of downloading the Max demo - and several hours later i'm still at this stage...
The problem is the new lists feature, I understand the concept: Several lists of the same data type. I just cannot figure out the syntax and reading the manual and searching for other users problems hasn't cleared this up for me.
In this code I have a data type called unit, and I have a list called shipList, but these are not linked in any way.
I know 10 of the unit data type are created, but I cannot iterate through them in the mainLoop with eachIn because that is indexed via the TList and not the TType.
I'm baffled as to the syntax required to resolve this, help please :)
The problem is the new lists feature, I understand the concept: Several lists of the same data type. I just cannot figure out the syntax and reading the manual and searching for other users problems hasn't cleared this up for me.
In this code I have a data type called unit, and I have a list called shipList, but these are not linked in any way.
I know 10 of the unit data type are created, but I cannot iterate through them in the mainLoop with eachIn because that is indexed via the TList and not the TType.
I'm baffled as to the syntax required to resolve this, help please :)
Strict Graphics 640,480,0 Global AppTitle$="AAAAAAARRRRRRRRGGGGGGHHHHHHHHH WTF Lists..." Global backdrop=LoadImage ("Backdrop\backdrop1.jpg") Type unit Field o,ai Field x#,z#,f# End Type Global shipList:TList=CreateList() createPlayers(10) 'function MainLoop Local ship:unit While Not KeyDown(KEY_ESCAPE) For ship=EachIn shipList DebugLog("SHIP LOOP ACTIVE") Select ship.ai Case 0 control(ship) camera(ship) Case 1 ai(ship) Default End Select Next For ship=EachIn shipList moveShip(ship) Next Flip Cls Wend End 'end function Function LIVE_SHIPS_____________________________________________________________________________________________() End Function Function control(ship:unit) End Function Function ai(ship:unit) End Function Function moveShip(ship:unit) End Function Function LIVE_GENERAL_PURPOSE__________________________________________________________________________________() End Function Function camera(ship:unit) 'Centres display on Ship SetScale 5,5 DrawImage backdrop,-(ship.x + (GraphicsWidth()/2)) , -(ship.z + (GraphicsHeight()/2)) SetScale 1,1 End Function Function SETUP_________________________________________________________________________________________________() End Function Function createPlayers(qty=10) For Local n=1 To 10 Local ship:unit=New unit ship.o=LoadImage("Ship\7.png") If n>1 Then ship.ai=1 'Make First Ship the Human Player ship.x=Rnd(0) ship.z=Rnd(0) Next End Function
