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.

Dark GDK / Wait Timer

Author
Message
Qeshmjaa
10
Years of Service
User Offline
Joined: 15th Mar 2014
Location:
Posted: 15th Mar 2014 00:11
Hello guys, im new to DarkGDK, and I'm sure a lot of you will
have the answear to my question.

I need to wait 2 seconds before doing an action?!
ehmm do I need dbTimer() ?? and if yes, could you guys
please give me a simple "Code Example" thank you.

lol albanians in da house <3
Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 15th Mar 2014 21:10
You can use dbTimer, or clock (include time.h); they both return the same thing (a millisecond counter).

Simply waiting for two seconds, you would check dbTimer() / clock(), store its value to a variable and wait until dbTimer() / clock() returns a value that is equal to or greater than the stored time stamp + 2000 milliseconds.
Something like this:

Of course you probably will want to do other things in that while loop, or else your program will just freeze until the two seconds have passed. It is also a busy wait so it will be more accurate at the cost of using your CPU to the max - if very exact timing isn't necessary you should call Sleep(1) in the loop to allow other processes to use the CPU while your program is just waiting.


"Why do programmers get Halloween and Christmas mixed up?"

Login to post a reply

Server time is: 2024-04-18 08:36:14
Your offset time is: 2024-04-18 08:36:14