I was just playing with the GUI - but I think, you could create some kind of game using the idea. Go on if you want to develop something out of it, unfortunately I don't have the time to - other projects are more important ^^
SuperStrict SeedRnd MilliSecs() Global MainTimer:TTimer = CreateTimer(60) Global MainWindow:TGadget = CreateWindow("Buttonwars", 200, 200, 640, 480, Null, WINDOW_TITLEBAR) Local lbTemp:LivingButton For Local iLoop:Int = 1 To 50 lbTemp = LivingButton.Create("Muahar", Rand(0, 640), Rand(0, 480), 20, 40, MainWindow) lbTemp.fSpeed = Rnd(0.1, 1.0) lbTemp.bAngle = Rand(0, 3) Next Repeat LivingGadget.UpdateAll() WaitTimer(MainTimer) PollEvent() Until EventID() = EVENT_WINDOWCLOSE End Type LivingGadget Abstract Global listAll :TList = New TList Field gadObject :TGadget Field gadParent :TGadget Field sName :String 'Name Field fX :Float 'Position Field fY :Float Field fSpeed :Float 'Speed Field fWidth :Float 'Size Field fHeight :Float Field bAngle :Byte 'Angle. Actually, there's just 0, 1, 2 and 3 for 0°, 90°, 180° and 270° Field bIsDeleted:Byte 'Scheduled for Removal? Method New() listAll.AddLast Self End Method Method Remove:Byte() listAll.Remove Self FreeGadget(gadObject) gadObject = Null bIsDeleted = True Return True End Method Method GetEdgeCoords:Byte(fVarX:Float Var, fVarY:Float Var, fVarW:Float Var, fVarH:Float Var) Select bAngle Case 0 '0° fVarX = fX - (fWidth / 2.0) fVarY = fY - (fHeight / 2.0) fVarW = fWidth fVarH = fHeight Case 1 '90° fVarX = fX - (fHeight / 2.0) fVarY = fY - (fWidth / 2.0) fVarW = fHeight fVarH = fWidth Case 2 '180° fVarX = fX - (fWidth / 2.0) fVarY = fY - (fHeight / 2.0) fVarW = fWidth fVarH = fHeight Case 3 '270° fVarX = fX - (fHeight / 2.0) fVarY = fY - (fWidth / 2.0) fVarW = fHeight fVarH = fWidth End Select Return True End Method Method Update:Byte() Local fXTmp:Float Local fYTmp:Float Local fWTmp:Float Local fHTmp:Float Select bAngle Case 0 '0° fY:- fSpeed Case 1 '90° fX:+ fSpeed Case 2 '180° fY:+ fSpeed Case 3 '270° fX:- fSpeed End Select GetEdgeCoords(fXTmp, fYTmp, fWTmp, fHTmp) SetGadgetShape(gadObject, fXTmp, fYTmp, fWTmp, fHTmp) RedrawGadget(gadObject) Return True End Method Function UpdateAll:Byte() Local lgTemp:LivingGadget For lgTemp = EachIn listAll lgTemp.Update() Next Return True End Function End Type Type LivingButton Extends LivingGadget Field bMoveMode :Byte 'What movement-phase? Field fOrigWidth :Float 'Real Size Field fOrigHeight :Float Method GetEdgeCoords:Byte(fVarX:Float Var, fVarY:Float Var, fVarW:Float Var, fVarH:Float Var) Select bAngle Case 0 '0° fVarX = fX - (fOrigWidth / 2.0) fVarY = fY - (fOrigHeight / 2.0) fVarW = fWidth fVarH = fHeight Case 1 '90° fVarX = fX - (fOrigHeight / 2.0) fVarY = fY - (fOrigWidth / 2.0) fVarW = fHeight fVarH = fWidth Case 2 '180° fVarX = fX - (fOrigWidth / 2.0) fVarY = fY - (fOrigHeight / 2.0) fVarW = fWidth fVarH = fHeight Case 3 '270° fVarX = fX - (fOrigHeight / 2.0) fVarY = fY - (fOrigWidth / 2.0) fVarW = fHeight fVarH = fWidth End Select Return True End Method Method Update:Byte() Local fXTmp:Float Local fYTmp:Float Local fWTmp:Float Local fHTmp:Float Select bAngle Case 0 '0° If bMoveMode = 0 Then fHeight:- fSpeed If fHeight <= fOrigHeight / 2.0 Then fHeight = fOrigHeight / 2.0 bMoveMode = 1 End If ElseIf bMoveMode = 1 Then fHeight:+ fSpeed fY:- fSpeed If fHeight >= fOrigHeight Then fHeight = fOrigHeight bMoveMode = 0 End If End If Case 1 '90° If bMoveMode = 0 Then fHeight:- fSpeed fX:+ fSpeed If fHeight <= fOrigHeight / 2.0 Then fHeight = fOrigHeight / 2.0 bMoveMode = 1 End If ElseIf bMoveMode = 1 Then fHeight:+ fSpeed If fHeight >= fOrigHeight Then fHeight = fOrigHeight bMoveMode = 0 End If End If Case 2 '180° If bMoveMode = 0 Then fHeight:- fSpeed fY:+ fSpeed If fHeight <= fOrigHeight / 2.0 Then fHeight = fOrigHeight / 2.0 bMoveMode = 1 End If ElseIf bMoveMode = 1 Then fHeight:+ fSpeed If fHeight >= fOrigHeight Then fHeight = fOrigHeight bMoveMode = 0 End If End If Case 3 '270° If bMoveMode = 0 Then fHeight:- fSpeed If fHeight <= fOrigHeight / 2.0 Then fHeight = fOrigHeight / 2.0 bMoveMode = 1 End If ElseIf bMoveMode = 1 Then fHeight:+ fSpeed fX:- fSpeed If fHeight >= fOrigHeight Then fHeight = fOrigHeight bMoveMode = 0 End If End If End Select GetEdgeCoords(fXTmp, fYTmp, fWTmp, fHTmp) SetGadgetShape(gadObject, fXTmp, fYTmp, fWTmp, fHTmp) RedrawGadget(gadObject) Return True End Method Function Create:LivingButton(sParName:String, fParX:Float, fParY:Float, fParWidth:Float, fParHeight:Float, gadParParent:TGadget) If gadParParent = Null Then Return Null Local lbTemp:LivingButton = New LivingButton lbTemp.sName = sParName lbTemp.fX = fParX lbTemp.fY = fParY lbTemp.fWidth = fParWidth lbTemp.fHeight = fParHeight lbTemp.fOrigWidth = fParWidth lbTemp.fOrigHeight = fParHeight lbTemp.gadParent = gadParParent lbTemp.gadObject = CreateButton("", lbTemp.fX - (lbTemp.fWidth / 2.0), lbTemp.fY - (lbTemp.fHeight / 2.0), lbTemp.fWidth, lbTemp.fHeight, lbTemp.gadParent) Return lbTemp End Function End Type