blob: 8aaab0398a26999bfbcfd5aa865ee18ff6efeb0e (
plain)
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
50
51
|
#include "sdl/timer.hpp"
Timer::Timer()
{
startTicks = 0;
pausedTicks= 0;
paused = false;
started = false;
}
void Timer::Start()
{
started = true;
paused = false;
startTicks = SDL_GetTicks();
}
void Timer::Stop()
{
started =false;
paused = false;
}
void Timer::Pause()
{
if ((started == true) && (paused == false )){
paused = true;
pausedTicks = SDL_GetTicks() - startTicks;
}
}
void Timer::unPause()
{
if (paused){
paused = false;
startTicks = SDL_GetTicks() - pausedTicks;
pausedTicks = 0;
}
}
int Timer::getTicks()
{
if(started){
if (paused)
return pausedTicks;
else
return SDL_GetTicks() - startTicks;
}
else
return 0;
}
|