Simplest way to setup a timer ?

Blitz3D Forums/Blitz3D Beginners Area/Simplest way to setup a timer ?

StOrM3(Posted 2004) [#1]
Okay,

I need something very organized like off in its own functions, to setup a timer that counts down from a value like 130 for level 1, 120 level 2, 110 level 3 etc.. and also, I need seperate functions to update the timer values, which will most likely have to be global variables, since I need access to these values in my main UpdateHUD, and ShowHUD functions, which show the timer value, the points, the level, lives left, current puzzle order for the level.

Now you see why it being seperated out by itself, and so organized is so important, as there is lots of code and everything is perfect, don't want to inadvertantly introduce bugs in which at this point would be very very hard to find.

Thanks for any suggestions,

Ken


Rob Farley(Posted 2004) [#2]
maxsecs = 40 ;seconds
time=MilliSecs()

Repeat
timeleft = (maxsecs*1000)-(MilliSecs()-time)
Cls
Text 0,0,timeleft
Until KeyHit(1)


eBusiness(Posted 2004) [#3]
This is really too simple for a seperate function
endtime should be global

To reset the timer
endtime=Millisecs()+130000

To diplay the timer
Print (endtime-Millisec())/1000

To check the timer
If endtime<Millisecs() Then
;do the thing you need when timer reach 0
End If