summary refs log tree commit diff stats
path: root/src/timer.h
diff options
context:
space:
mode:
authorKelly Rauchenberger <fefferburbia@gmail.com>2021-01-30 13:03:50 -0500
committerKelly Rauchenberger <fefferburbia@gmail.com>2021-01-30 13:03:50 -0500
commite3fcd5fc180b48e0710fbcbf6cfa94e906b8219c (patch)
tree61783526e178e7253b8704299bec31a190878790 /src/timer.h
parentf3166702d7dd30312b5a401f52941aad43ac51c3 (diff)
downloadtanetane-e3fcd5fc180b48e0710fbcbf6cfa94e906b8219c.tar.gz
tanetane-e3fcd5fc180b48e0710fbcbf6cfa94e906b8219c.tar.bz2
tanetane-e3fcd5fc180b48e0710fbcbf6cfa94e906b8219c.zip
Abstracted frame timing stuff
Diffstat (limited to 'src/timer.h')
-rw-r--r--src/timer.h28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/timer.h b/src/timer.h new file mode 100644 index 0000000..0809610 --- /dev/null +++ b/src/timer.h
@@ -0,0 +1,28 @@
1#ifndef TIMER_H_45E2F1F9
2#define TIMER_H_45E2F1F9
3
4class Timer {
5public:
6
7 Timer(int dt) : dt_(dt) {}
8
9 void accumulate(int t) {
10 acc_ += t;
11 }
12
13 bool step() {
14 if (acc_ > dt_) {
15 acc_ -= dt_;
16 return true;
17 } else {
18 return false;
19 }
20 }
21
22private:
23
24 int dt_;
25 int acc_ = 0;
26};
27
28#endif /* end of include guard: TIMER_H_45E2F1F9 */