Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Kheteris

Timer

This topic is 5391 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

How does one use time to implement different actions? Like I want the x variable to be 1, but after 25 seconds I want it to be 25. I know there''s a time.h header file, but I only know how to generate random ints with it... So, how do I get a timer to count?

Share this post


Link to post
Share on other sites
Advertisement
You don''t get a timer to count.

I use timeGetTime() to look up the current system time and save it to a variable then look up how mutch time has passed by substracting that variable from the current timeGetTime(). You can make a simple if statement:

if (timeGetTime() - OldTime > 25000)
{
//this will happen 25000 milisecs after you got OldTime
}

Share this post


Link to post
Share on other sites
quote:
Original post by Kheteris
How does one use time to implement different actions?

Like I want the x variable to be 1, but after 25 seconds I want it to be 25.

I know there''s a time.h header file, but I only know how to generate random ints with it...

So, how do I get a timer to count?


Hmm - sounds like you''re using the timer.h I posted a long time ago on these boards (if you''re not, you can always take it from the MySQL tutorial code, linked to on Nehe''s front page). If that is the case, just call TTimer:ush() when you want to reset the timer to zero (such as at the beginning of program execution) and test for TTimer:op() whenever you like to get the number of milliseconds that have passed since last calling Timer:ush().

Or you could use Marty''s code.





Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!