-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGameTimer.h
More file actions
40 lines (34 loc) · 1.06 KB
/
GameTimer.h
File metadata and controls
40 lines (34 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#pragma once
#include <SDL2/SDL.h>
#include "UtilityLibraryDefine.h"
class GameTimer {
public:
struct DeltaTimeInfo;
UTILITY_API GameTimer();
UTILITY_API void Start ();
UTILITY_API void Stop ();
UTILITY_API void Pause ();
UTILITY_API void UnPause ();
UTILITY_API void Tick ();
UTILITY_API double Restart ();
UTILITY_API float GetTimeAsFloat () const;
UTILITY_API double GetTimeAsDouble () const;
UTILITY_API float GetDeltaAsFloat () const;
UTILITY_API double GetDeltaAsDouble() const;
UTILITY_API DeltaTimeInfo GetDeltaTimeInfo() const;
UTILITY_API Uint64 GetDeltaTicks () const;
UTILITY_API Uint64 GetTicksPerSec () const;
struct DeltaTimeInfo {
Uint64 DeltaTicks;
Uint64 TicksPerSec;
float DeltaTime;
DeltaTimeInfo( Uint64 deltaTicks, Uint64 ticksPerSec, float deltaTime )
: DeltaTicks( deltaTicks ), TicksPerSec( ticksPerSec ), DeltaTime( deltaTime ) {}
};
private:
Uint64 m_StartTicks, m_PausedTicks, m_LastCheckedTicks;
Uint64 m_TicksPerSec;
Uint64 m_DeltaTicks;
bool m_Started, m_Paused;
double m_DeltaTime;
};