In the old Blitz I was able to create a type inside of a type loop without problems, as long as it was in an external function. Whenever I try to do this with BlitzMax, it creates a recursive loop and the program freezes. What I'm trying to do is create a new type whose position is based off of an existing one in the same list. Is there a way to do this in Max?
Graphics 640, 480, 0, -1
Global objList:TList = New TList, o:Obj
Type Obj
Field X, Y
Method Render()
DrawRect X, Y, 1, 1
X:+1
CreateObj X, Y
End Method
End Type
Repeat
Cls
For o:Obj = EachIn ObjList; o.Render; Next
If MouseHit(1) Then CreateObj 320, 240
FlushMem; Flip
Until KeyDown(KEY_ESCAPE)
Function CreateObj(X, Y)
o:Obj = New Obj
o.X = X; o.Y = Y
objList.AddLast o
End Function
|