summary refs log tree commit diff stats
path: root/src/timer.h
blob: 0809610caf96650eed66b5b071ad3017bbf351ee (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
#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;
    }
  }

private:

  int dt_;
  int acc_ = 0;
};

#endif /* end of include guard: TIMER_H_45E2F1F9 */