Last active
October 26, 2016 18:19
-
-
Save vasumahesh1/65ba31d293f51f7b9b2672245874ea88 to your computer and use it in GitHub Desktop.
Game Timer Header File
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma once | |
#include "Common.h" | |
#include "boost/function.hpp" | |
using namespace std; | |
namespace Azura | |
{ | |
typedef boost::function<void()> AzuraBasicCallback; | |
enum AzuraTimerType | |
{ | |
Stopwatch, | |
Countdown | |
}; | |
class Timer | |
{ | |
public: | |
Timer(); | |
Timer(AzuraTimerType type); | |
double TotalTime() const; | |
double DeltaTime() const; | |
void Reset(); | |
void Start(); | |
void Stop(); | |
// Countdown Specific Funcs | |
void SetLimit(double countdownLimit); | |
void OnCountdownEnd(AzuraBasicCallback callback); | |
void OnCountdownEnd(void(*callback)()); | |
// General | |
void Tick(void (*callback)()); | |
void Tick(AzuraBasicCallback callback); | |
private: | |
double mSecondsPerTick; | |
double mDeltaTime; | |
AzuraTimerType mType; | |
void init(); | |
void processTick(); | |
void processCountdown(); | |
AzuraBasicCallback mEventCountdownEnd; | |
__int64 getCurrentTime(); | |
double mCountdownLimit; | |
double mCurrCountdown; | |
__int64 mBaseTime; | |
__int64 mPausedTime; | |
__int64 mStopTime; | |
__int64 mPrevTime; | |
__int64 mCurrTime; | |
bool mStopped; | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment