-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtimer.hh
More file actions
45 lines (32 loc) · 744 Bytes
/
Copy pathtimer.hh
File metadata and controls
45 lines (32 loc) · 744 Bytes
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
#ifndef _GRAVITY_TIMER_HH_
#define _GRAVITY_TIMER_HH_
#include <SDL2/SDL.h>
#include <functional>
#include <vector>
using namespace std;
class Timer {
protected:
typedef function<void (float elapsed)> timer_callback;
Uint32 startTime;
float timeout;
bool periodic;
Uint32 pauseTime;
bool paused;
bool expired;
timer_callback callback;
static vector<Timer*> timers;
public:
Timer(timer_callback callback);
virtual ~Timer();
void Set(float timeout, bool periodic=false);
void Check();
void Pause();
void Unpause();
bool TogglePause();
bool IsPaused();
static void CheckAll();
static void PauseAll();
static void UnpauseAll();
static void TogglePauseAll();
};
#endif /* _GRAVITY_TIMER_HH_ */