blob: b77251b8739d9d6497e97d180cda9e851344f8da (
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
|
#include "timer.h"
Clock::Clock() {
reset();
running = false;
}
void Clock::reset() {
base = 0;
clock.Reset();
}
void Clock::start() {
running = true;
clock.Reset();
}
void Clock::stop() {
if(!running) return;
running = false;
base += clock.GetElapsedTime();
}
float Clock::elapsed() const {
if(running) {
return base + clock.GetElapsedTime();
} else {
return base;
}
}
Timer::Timer(const Clock& clock_) : clock(clock_) {
reset();
}
void Timer::reset() {
starttime = clock.elapsed();
}
float Timer::elapsed() const {
return clock.elapsed() - starttime;
}
|