-
Notifications
You must be signed in to change notification settings - Fork 0
/
clock.h
47 lines (36 loc) · 899 Bytes
/
clock.h
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
41
42
43
44
45
46
47
#include <SDL.h>
#include <string>
class Engine;
class Clock {
public:
static Clock& getInstance();
unsigned int getTicks() const;
private:
friend class Engine;
friend class HUD;
bool started;
bool paused;
const bool FRAME_CAP_ON;
const Uint32 PERIOD;
unsigned int frames;
unsigned int timeAtStart;
unsigned int timeAtPause;
unsigned int currTicks;
unsigned int prevTicks;
unsigned int ticks;
unsigned int getElapsedTicks();
void incrFrame();
void toggleSloMo();
bool isStarted() const { return started; }
bool isPaused() const { return paused; }
unsigned int getFrames() const { return frames; }
unsigned int getSeconds() const { return getTicks()/1000; }
unsigned int capFrameRate() const;
int getFps() const;
void startClock();
void pause();
void unpause();
Clock();
Clock(const Clock&);
Clock&operator=(const Clock&);
};