Hi, I'm using something like this in my apps:
The main advantage of this is you don't have to worry about the update.
SuperStrict Type TCountDown Global Timer:TTimer = CreateTimer(100) Field Time:Int 'Time in millisecs Field BackTime:Int Method New() AddHook EmitEventHook,DownHook,Self End Method Function Create:TCountDown(Time:Int = 10000) Local C:TCountDown = New TCountDown C.Time = Time C.BackTime = Time Return C End Function Function DownHook:Object( id:Int , data:Object , context:Object ) Local CD:TCountDown = TCountDown(context) If CD <> Null Then CD.Update() End If Return data End Function Method Update() BackTime:- 10 If BackTime < 0 Then BackTime = 0 End Method Method GetTime:Int() Return BackTime End Method Method GetSeconds:Float() Return Float(BackTime) / 1000 End Method Method Reset() BackTime = Time End Method End Type Graphics 800,600,0,-1 Local CD:TCountDown[10] For Local I:Int = 0 To 9 CD[I] = TCountDown.Create(Rand(5000 , 20000) ) Next While Not KeyHit(KEY_ESCAPE) Cls For Local I:Int = 0 To 9 DrawText CD[I].GetSeconds() + " : " + CD[I].GetTime() , 20 , 20 + I * 20 If CD[I].GetTime() = 0 Then CD[I].Reset() Next Flip Wend
The main advantage of this is you don't have to worry about the update.