Skip to content

Instantly share code, notes, and snippets.

@vasumahesh1
Last active October 26, 2016 18:19
Show Gist options
  • Save vasumahesh1/65ba31d293f51f7b9b2672245874ea88 to your computer and use it in GitHub Desktop.
Save vasumahesh1/65ba31d293f51f7b9b2672245874ea88 to your computer and use it in GitHub Desktop.
Game Timer Header File
#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