Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / reliable timer?

Author
Message
demons breath
21
Years of Service
User Offline
Joined: 4th Oct 2003
Location: Surrey, UK
Posted: 22nd Dec 2004 16:20
How can you make a reliable timer which will show the time in seconds, minutes and milliseconds (and will still show the correct time no matter how slowly the program runs)?
I want to show the time on the screen of how long you have been playing for but I don't just want to do something like increase the time# variable at the end of each loop because that isn't accurate.

Am I the only one here who's really confused?
Oliver
22
Years of Service
User Offline
Joined: 24th Nov 2002
Location: Switzerland
Posted: 22nd Dec 2004 16:28
http://underwaredesign.com/prod_detail.php?rnd=453028933&id=20

Look at the very bottom of the page.
demons breath
21
Years of Service
User Offline
Joined: 4th Oct 2003
Location: Surrey, UK
Posted: 22nd Dec 2004 16:34 Edited at: 22nd Dec 2004 16:47
thanks Oliver

[edit] I downloaded it and implemented it and it works... now I just need to figure out how to reset it... it always starts at 12 seconds [img] [/img]

Am I the only one here who's really confused?
Ric
20
Years of Service
User Offline
Joined: 11th Jul 2004
Location: object position x
Posted: 22nd Dec 2004 18:55 Edited at: 22nd Dec 2004 18:58
I posted one in the code snippets forum recently (should be on the first or second page still) which you can reset.

<edit> In fact, here it is:




Oliver
22
Years of Service
User Offline
Joined: 24th Nov 2002
Location: Switzerland
Posted: 22nd Dec 2004 20:27
Hmm, it probly starts at 12 seconds because you start the clock at the begining of your program, then by the time everything is loaded its already 12 seconds on. Make sure you pur the command, which is something like starttime=timer(), just before the main loop.

I havent actually looked at the code, but i hope that makes some sense.

demons breath
21
Years of Service
User Offline
Joined: 4th Oct 2003
Location: Surrey, UK
Posted: 22nd Dec 2004 22:37
yeah i got it sorted as soon as i posted - i jus set ts (a value which is taken away from timer()) to the same value as timer() before the main game loop.

Thanks anyway Oliver & Ric

Am I the only one here who's really confused?

Login to post a reply

Server time is: 2024-11-27 16:51:38
Your offset time is: 2024-11-27 16:51:38