blob: 65d5a50d72c08d3b2b6341f96c784265f0a0b348 (
plain) (
blame)
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
|
#ifndef TIMER_H_45E2F1F9
#define TIMER_H_45E2F1F9
class Timer {
public:
Timer(int dt) : dt_(dt) {}
void accumulate(int t) {
acc_ += t;
}
bool step() {
if (acc_ > dt_) {
acc_ -= dt_;
return true;
} else {
return false;
}
}
void reset() {
acc_ = 0;
}
int getDt() const { return dt_; }
private:
int dt_;
int acc_ = 0;
};
#endif /* end of include guard: TIMER_H_45E2F1F9 */
|