Author |
Message |
tianxiao
|
Posted: Tue Jan 13, 2009 12:23 pm Post subject: How do you set up a timer in turing? I wanna run a game and see how long a person takes to complete it. |
|
|
How do you set up a timer in turing? I wanna run a game and see how long a person takes to complete it. So starting from the time the program starts running till the game ends. How do i make that timer? |
|
|
|
|
|
Sponsor Sponsor
|
|
|
copthesaint
|
Posted: Tue Jan 13, 2009 12:32 pm Post subject: RE:How do you set up a timer in turing? I wanna run a game and see how long a person takes to complete it. |
|
|
First make 2 vars the timer for when to start and 1 for finish
code: | var timerI,timerF : int
timerI := Time.Sec
loop
timerF := Time.Sec
put (timerF-timerI)
if timerI + 10 < timerF then
quit
end if
View.Update
cls
end loop |
|
|
|
|
|
|
Zren
|
Posted: Tue Jan 13, 2009 12:44 pm Post subject: Re: How do you set up a timer in turing? I wanna run a game and see how long a person takes to complete it. |
|
|
Edit: Monkeys, copthesaint types fast, :/
Look up the Time. module for more things like Days and Years...
Time.Sec returns the seconds it's been since...uh jan __ 1970 at midnight.
This isn't really usefull by itself...BUT if we took to times and compared them (TimeB -TimeA) then we'd have the difference in time or Δt. For our use TimeA would be when the game starts, and TimeB would be when the game ends. |
|
|
|
|
|
The_Bean
|
Posted: Tue Jan 13, 2009 1:22 pm Post subject: Re: How do you set up a timer in turing? I wanna run a game and see how long a person takes to complete it. |
|
|
Or you could simply use Time.Elapsed which returns the number of milliseconds since the program started. |
|
|
|
|
|
copthesaint
|
Posted: Tue Jan 13, 2009 3:11 pm Post subject: RE:How do you set up a timer in turing? I wanna run a game and see how long a person takes to complete it. |
|
|
The bean if you use that then the program will have different time limits each game esspecially is you have a menu
the way I did is good for effects and timers. |
|
|
|
|
|
The_Bean
|
Posted: Tue Jan 13, 2009 5:41 pm Post subject: Re: How do you set up a timer in turing? I wanna run a game and see how long a person takes to complete it. |
|
|
Actually no it won't.
Your getting that start time saving it as a variable and subtracting it from the current time. Do the exact same thing with Time.Elapsed and you will get the exact same amount of time.
The major difference is that Time.Elapsed deals in milliseconds, so you have more accuracy.
A program that draws a black box every other 1.25 seconds.
Time.Sec is an integer so your limited to 1,2,3... seconds so you can't get 1.25 like you can with Time.Elapsed |
|
|
|
|
|
|