Timer...
Blitz3D Forums/Blitz3D Beginners Area/Timer...
| ||
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? |
| ||
... Text 347,565, 60-((Alarm-MilliSecs())/1000) ... |
| ||
http://www.blitzbasic.com/codearcs/codearcs.php?code=828 |
| ||
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. |
| ||
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). |
| ||
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 |