-
Notifications
You must be signed in to change notification settings - Fork 1
/
clock.h
49 lines (43 loc) · 1.05 KB
/
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
48
49
#ifndef CLOCK__H
#define CLOCK__H
#include <SDL.h>
#include <string>
#include <iostream>
#include <fstream>
class Manager;
class Clock {
public:
static Clock& getInstance();
// getTicks returns number of ticks since SDL was init
unsigned getTicks() const;
private:
friend class Manager;
friend class Viewport;
// getElapsedTicks returns number of ticks since last call
unsigned getElapsedTicks();
Clock& operator++();
Clock operator++(int);
bool isStarted() const { return started; }
bool isPaused() const { return paused; }
unsigned getFrames() const { return frames; }
unsigned getSeconds() const { return getTicks()/1000; }
int getFps() const;
void start();
void pause();
void unpause();
void debug();
//void save(std::fstream& xmlfile) const;
//void restore(const std::string& filename);
bool started;
bool paused;
unsigned frames;
unsigned timeAtStart;
unsigned timeAtPause;
unsigned currTicks;
unsigned prevTicks;
unsigned ticks;
Clock();
Clock(const Clock&);
Clock&operator=(const Clock&);
};
#endif