Jump to content
  • Advertisement

Archived

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

TheShadow

Timers

This topic is 5632 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

I am looking for a way to program a Timer class that i would just call it and give me the time elapsed since the last call... anybody give any hints? GetTickCount()?? i don''t know how to use any of those time stuff

Share this post


Link to post
Share on other sites
Advertisement
Maybe it would be nice to share it with us, then (I don''t need it, tho). It''s very easy to make, with gettickcount and threads...

Share this post


Link to post
Share on other sites

  
#ifndef TDTIMER_H //timer.h

#define TDTIMER_H

class CTimer {
public:
void Initialize(void);
unsigned long GetElapsedTime(void);

private:
unsigned long initTime;
unsigned long currentTime;
unsigned long lastCallTime;
unsigned long elapsedTime;
};

#endif




  
//timer.cpp

#include "timer.h"
#include "windows.h"



void CTimer::Initialize()
{
initTime = GetTickCount();
lastCallTime = initTime;
}
unsigned long CTimer::GetElapsedTime()
{
elapsedTime = GetTickCount() - lastCallTime;
return elapsedTime * 0.1; //Return in 100th of a second

}


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!