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.

Code Snippets / The Ultimate Second-By-Second Timer! (DBP+DBC!!!)

Author
Message
Xenocythe
19
Years of Service
User Offline
Joined: 26th May 2005
Location: You Essay.
Posted: 22nd Jul 2005 00:43
Count Down...


Or count up!


These snippets are free to use. (Both made by me)

Any comments?

Enjoy Life while your still alive.
Enjoy a recees anytime!
BatVink
Moderator
22
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 22nd Jul 2005 02:09 Edited at: 22nd Jul 2005 02:10
You need to account for the time it takes for your code to execute. You're also out by a second because you decrement before you sleep.

To keep track of real time, you should pick a point in time (timer()), and always refer back to it. You can't guarantee that your program loop is exactly 1 second, or that it will be constant in a complex program. On my PC, it was out by 70 milliseconds over the period of a minute.

Watch out for the next newsletter, there is a tutorial that covers timing

BatVink
Ooska
20
Years of Service
User Offline
Joined: 29th Aug 2004
Location:
Posted: 29th Aug 2005 05:45
(off topic)
Hey Xenocythe, does your name correspond with the Ender's Game series? (xenocide)

Weird = Unique. Unique = Human.
Im human.
Xenocythe
19
Years of Service
User Offline
Joined: 26th May 2005
Location: You Essay.
Posted: 30th Aug 2005 23:17
Holy cow, this old topic? I did this like what... when my forum name was GreenFox?

And no, I don't think so ooska

Login to post a reply

Server time is: 2025-05-16 11:23:03
Your offset time is: 2025-05-16 11:23:03