Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifndef _ZTIMER_H
- #define _ZTIMER_H
- #include <list>
- using namespace std;
- typedef void(ZGameTimerEventCallback)(void* pParam);
- class ZTimerEvent;
- // ¾ÕÀ¸·Î °ÔÀÓÆ½, ŸÀÌ¸Ó °ü·ÃÀº ¿©±â¼ °ü¸®Çϵµ·Ï ÇÏÀÚ
- class ZTimer
- {
- private:
- bool m_bInitialized;
- unsigned long int m_nLastTime;
- unsigned long int m_nNowTime;
- list<ZTimerEvent*> m_EventList;
- // ŸÀÌ¸Ó °»½Å¿ë º¯¼öµé : ¸Þ¸ð¸®ÇÙÀ¸·Î º¯Á¶ÇÏ¸é ½ºÇǵåÇÙÀÌ °¡´ÉÇÏ´Ù ±×·¡¼ ÈüÇÒ´çÇϰí ÁÖ±âÀûÀ¸·Î À§Ä¡¸¦ ¿Å±ä´Ù
- BOOL* m_pbUsingQPF;
- LONGLONG* m_pllQPFTicksPerSec;
- LONGLONG* m_pllLastElapsedTime;
- DWORD* m_pThistime;
- DWORD* m_pLasttime;
- DWORD* m_pElapsed;
- void UpdateEvents();
- void ShiftFugitiveValues();
- public:
- ZTimer();
- virtual ~ZTimer();
- float UpdateFrame();
- void ResetFrame();
- // ŸÀÌ¸Ó À̺¥Æ® °ü·Ã
- void SetTimerEvent(unsigned long int nElapsedTime, ZGameTimerEventCallback* fnTimerEventCallback, void* pParam, bool bTimerOnce=false);
- void ClearTimerEvent(ZGameTimerEventCallback* fnTimerEventCallback);
- unsigned long int GetNowTick() { return m_nNowTime; }
- };
- class ZUpdateTimer
- {
- private:
- float m_fUpdateTime;
- float m_fElapsedTime;
- public:
- ZUpdateTimer(float fUpdateTime) : m_fUpdateTime(fUpdateTime), m_fElapsedTime(0.0f) { }
- ZUpdateTimer() : m_fUpdateTime(0.0f), m_fElapsedTime(0.0f) { }
- bool Update(float fDelta)
- {
- m_fElapsedTime += fDelta;
- if (m_fElapsedTime < m_fUpdateTime) return false;
- m_fElapsedTime = 0.0f;
- return true;
- }
- void Init(float fUpdateTime) { m_fUpdateTime = fUpdateTime; m_fElapsedTime = 0.0f; }
- void Force() { m_fElapsedTime = m_fUpdateTime; }
- void SetUpdateTime(float fUpdateTime) { m_fUpdateTime = fUpdateTime; }
- float GetUpdateTime() const { return m_fUpdateTime; }
- };
- #endif
Advertisement
Add Comment
Please, Sign In to add comment