-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTimer.cpp
More file actions
42 lines (34 loc) · 688 Bytes
/
Timer.cpp
File metadata and controls
42 lines (34 loc) · 688 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
// ----------------------------------------------------
// Timer.cpp
// Body for CPU Tick Timer class
// ----------------------------------------------------
#include "Timer.h"
// ---------------------------------------------
Timer::Timer()
{
Start();
}
// ---------------------------------------------
void Timer::Start()
{
running = true;
started_at = SDL_GetTicks();
}
// ---------------------------------------------
void Timer::Stop()
{
running = false;
stopped_at = SDL_GetTicks();
}
// ---------------------------------------------
Uint32 Timer::Read()
{
if(running == true)
{
return SDL_GetTicks() - started_at;
}
else
{
return stopped_at - started_at;
}
}