Hi
I'm a little bit lost whith the bmax tlink commands
(like addlast addfirst from blitz3D) Anybody can help
me ?
Original code (blitz3D) :
My blitzmax code :
I'm a little bit lost whith the bmax tlink commands
(like addlast addfirst from blitz3D) Anybody can help
me ?
Original code (blitz3D) :
Graphics 500,500,0,2 SetBuffer BackBuffer() SeedRnd MilliSecs() Type thingyT Field x%, y% Field width%, height% Field r%, g%, b% End Type ; create some random 'thingies'. For n = 1 To 50 this.thingyT = New thingyT this\width = Rand(30,100) this\height = Rand(30,100) this\x = Rand(0,500-this\width) this\y = Rand(0,500-this\height) this\r = Rand(20,255) this\g = Rand(20,255) this\b = Rand(20,255) Next While Not KeyHit(1) Cls If MouseHit(1) Then update_thingies() draw_thingies() Flip Wend End Function update_thingies() mx = MouseX() my = MouseY() this.thingyT = Last thingyT ; We need to check through the thingy list backwards so that ; a thingy overlapping another one is checked first. While this <> Null If (mx >= this\x) And (mx <= (this\x+this\width-1)) If (my >= this\y) And (my <= (this\y+this\height-1)) ; This thingy has been clicked on so make it top thingy. Insert this After Last thingyT Return EndIf EndIf this = Before this Wend End Function Function draw_thingies() For this.thingyT = Each thingyT Color this\r,this\g,this\b Rect this\x,this\y,this\width,this\height,True Color 255,255,255 Rect this\x,this\y,this\width,this\height,False Next End Function
My blitzmax code :
Graphics 640,480,0 Global thingyTList:TList=New TList Global ThisLink:TLink=thingyTList.FirstLink() Type thingyT Field x%, y% Field width%, height% Field r%, g%, b% Method New () thingyTList.AddLast Self End Method Function Create:thingyT() Local B:thingyT = New thingyT Return B End Function Function Draw() For Local this:thingyT = EachIn thingyTList SetColor this.r,this.g,this.b DrawRect this.x,this.y,this.width,this.height Next End Function 'Look the function update_thingies() in blitz3D code Function Refresh() Local Mx:Int=MouseX() Local My:Int=MouseY() ThisLink=thingyTList.LastLink() Local this:thingyT=thingyT(ThisLink.Value()) While this <> Null If (mx >= this.x) And (mx <= (this.x+this.width-1)) If (my >= this.y) And (my <= (this.y+this.height-1)) EndIf EndIf Wend End Function End Type For n = 1 To 50 Local this:thingyT=thingyT.Create() this.width = Rand(30,100) this.height = Rand(30,100) this.x = Rand(0,500-this.width) this.y = Rand(0,500-this.height) this.r = Rand(20,255) this.g = Rand(20,255) this.b = Rand(20,255) Next Repeat thingyT.Draw() If MouseHit(1) Then thingyT.Refresh() EndIf Flip Cls Until KeyDown(key_escape) End