Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 How do you set up a timer in turing? I wanna run a game and see how long a person takes to complete it.
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
tianxiao




PostPosted: 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
Sponsor
sponsor
copthesaint




PostPosted: 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




PostPosted: 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.

code:
var t := Time.Sec


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




PostPosted: 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




PostPosted: 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




PostPosted: 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.
Turing:

View.Set ("offscreenonly")
var timeStart : int
timeStart := Time.Elapsed
loop
    cls
    if ((timeStart - Time.Elapsed) div 1250) rem 2 = 0 then
        Draw.FillBox (0, 0, maxx, maxy, 7)
    end if
    View.Update
end loop

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
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 6 Posts ]
Jump to:   


Style:  
Search: