Timer...

Blitz3D Forums/Blitz3D Beginners Area/Timer...

po(Posted 2004) [#1]
Gfk showed me how to do a simple timer that counts down from 60 or whaterver number, and I have been trying to figure out how to make a timer that counts up. Heres the timer that goes down:
Alarm% = MilliSecs() + 60000

while not keyhit(1)

Text 347,565, ((Alarm-MilliSecs())/1000)

wend 


I have tried to make it go up, but then it just turned in to something like: 7634 and went up from there. How do you make it go up from 0?


soja(Posted 2004) [#2]
...
Text 347,565, 60-((Alarm-MilliSecs())/1000)
...



Rob Farley(Posted 2004) [#3]
http://www.blitzbasic.com/codearcs/codearcs.php?code=828


po(Posted 2004) [#4]
Thanks soja and Rob.
soja: The timer works fine, and now I want to know how to use alarm as a vaiable somehow like:
If alarm>200 :Goto death:Endif

.death

Text 200,10,"Time: "+alarm


Can I use it something like that? In the text after .death, I want it to display how long you lasted in the game, so I do not want the timer to be going up or anything. Can I do this?

Rob: My game is very simple, and all I really need is the code soja and Gfk gave me. Thanks anyways.


WolRon(Posted 2004) [#5]
Not exactly. Millisecs() command returns ANY number between 0 and 2 billion (I think). You have to keep track of it yourself.

In your example you are storing the value returned by Millisecs() in Alarm. This is probably OK while your game loop is running but once it ends you may want to use a seperate variable to store the time that passed (because Millisecs() will keep incrementing).


soja(Posted 2004) [#6]
Well, the simple thing would be to keep track of the time you're displaying in a variable, like this:

time% = 60-((Alarm-MilliSecs())/1000)
Text 347,565, time
If time > 200 Then Goto death