Types from BB3D to BMax
BlitzMax Forums/BlitzMax Beginners Area/Types from BB3D to BMax
| ||
Can anybody help me here...I need a simple solution to this problem, and I know that there are probably 100s of solutions to this. The BB3D Code... Type ball Field x End Type For a=1 To 5 b.ball=New ball b\x=Rand(1,10) Next For b.ball = Each ball Print b\x Next WaitKey ...Can anybody transfer this to Max code with the least fuss possible? Last edited 2011 |
| ||
Strict Type ball Field x:Float '(or :Int, or :Double) End Type Local b:ball Local myList:TList = New TList For Local a:Int = 1 To 5 b = New ball b.x=Rand(1,10) myList.AddLast(b) Next For b = EachIn myList Print b.x Next WaitKey |
| ||
Thanks GFK!! Much appreciated. :) |
| ||
Another way:Strict Type ball Field x:Float '(or :Int, or :Double) Method New() Self.x = Rand(1,10) End Method End Type Local myList:TList = New TList For Local a:Int = 1 To 5 myList.AddLast(New ball) Next For Local b:ball = EachIn myList Print b.x Next WaitKey Last edited 2011 |
| ||
Strict Type ball Global MyList:TList = New TList Field x:Float '(or :Int, or :Double) Method New() Self.x = Rand(1,10) Self.Mylist.AddLast(Self) End Method End Type For Local a:Int = 1 To 5 New ball Next For Local b:ball = EachIn Ball.myList Print b.x Next WaitKey NB neither of us have bothered with Deleting/Removing the Balls from the list, but you get the idea |
| ||
Slowly but surely starting to clear in my head. Thanks guys. |
| ||
The advantage of this way is you can have multiple seperate lists should you need to. |