Timer Creation

BlitzPlus Forums/BlitzPlus Beginners Area/Timer Creation

SuperSonic7(Posted 2008) [#1]
I'm trying to create a timer that counts down from 60 seconds, then when it reaches zero the game ends.

counter is self-explanitory and seconds is used as the variable to print on-screen. When tested the seconds meter does not desend. If anyone can help me fix this code or suggest a better formula please do so.


Ked(Posted 2008) [#2]
Is this what you mean?
Graphics 800,600,32,2
SetBuffer BackBuffer()

Global timer,count=1000,seconds=60

Function CreateTimer_()
	timer=MilliSecs()
End Function

Function UpdateTimer_()
	If MilliSecs() > timer+count
		seconds=seconds-1
		timer=MilliSecs()
	EndIf
	
	If seconds=0 Then Notify "COMPLETE!":End
End Function

CreateTimer_()

Repeat
	If KeyHit(1)
		End
	EndIf
	
	Cls
	
	Text 10,10,seconds
	
	Flip
	
	UpdateTimer_()
Forever



SuperSonic7(Posted 2008) [#3]
Not exactly what I wanted, but in the right direction, I can fix it from here. Thanks!