-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTimer.cpp
More file actions
68 lines (57 loc) · 975 Bytes
/
Copy pathTimer.cpp
File metadata and controls
68 lines (57 loc) · 975 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#include "Timer.h"
#include "GeneralFunc.h"
Timer::Timer()
{
start_time=0;
pause_time=0;
is_pause_=false;
is_start_=false;
}
Timer::~Timer()
{
}
void Timer::Start()
{
is_start_=true;
is_pause_=false;
start_time=SDL_GetTicks();
}
void Timer::Stop()
{
is_start_=false;
is_pause_=false;
}
void Timer::Pause()
{
if(is_start_==true && is_pause_==false)
{
is_pause_=true;
pause_time=SDL_GetTicks()- start_time;
}
}
void Timer::Resume()
{
if(is_pause_==true)
{
is_pause_=true;
start_time=SDL_GetTicks()- pause_time;
pause_time=0;
}
}
int Timer::Get_ticks()
{
if(is_start_==true)
{
if(is_pause_==true) return pause_time;
else return SDL_GetTicks()-start_time;
}
return 0;
}
bool Timer::Is_pause()
{
return is_pause_;
}
bool Timer::Is_start()
{
return is_start_;
}