Hmmm....looked at it a bit closer, and it seems create timer is not what I want. From what I can figure out it seems WaitTimer() will actually stop the progress of the program. What I want to do is keep the main loop updating, but only do something every n-th millisecond.
Here is what I wound up doing, which I'm quite happy with. (migh want to change the name of the Type as I think it's the same name as CreateTimer uses.
All I then need to do in my code is create the timer like so....
And then if I want to check if it's running I can do...
Works very nicely in the Blackjack game I'm working on. :)
Here is what I wound up doing, which I'm quite happy with. (migh want to change the name of the Type as I think it's the same name as CreateTimer uses.
' Timer function. Use [ If Time.Tick() Then something... ] Type TTimer Field Start:Int ' Start time. Field Ticks:Int ' The number of times the timer has clicked. Field Wait:Int ' Number of millisecs to wait between ticks. ' Returns true if the timer ticks. Add's one to Tick count. Method Tick:Int() If MilliSecs() > Start + Wait Ticks:+1 Start = MilliSecs() Return 1 Else Return 0 End If End Method ' Creates a timer. Takes time to wait between ticks as input. Function Create:TTimer( inWait:Int = 60 ) Local Time:TTimer = New TTimer Time.Start = MilliSecs() Time.Ticks = 0 Time.Wait = inWait Return Time End Function End Type
All I then need to do in my code is create the timer like so....
Global Timer:TTimer = TTimer.Create( 300 )
And then if I want to check if it's running I can do...
If Timer.Tick() Then ' Do something
Works very nicely in the Blackjack game I'm working on. :)