1 #ifndef BLANK_APP_INTERVALTIMER_HPP
2 #define BLANK_APP_INTERVALTIMER_HPP
7 /// Timer that hits every n milliseconds. Resolution is that of the
8 /// delta values passed to Update(), minimum 1ms.
9 /// Also tracks the number of iterations as well as milliseconds
14 /// Create a timer that hits every interval_ms milliseconds.
15 /// Initial state is stopped.
16 explicit IntervalTimer(int interval_ms = 0) noexcept
17 : intv(interval_ms) { }
19 void Start() noexcept {
22 void Stop() noexcept {
26 void Reset() noexcept {
30 bool Running() const noexcept {
33 /// true if an interval boundary was passed by the last call to Update()
34 bool Hit() const noexcept {
35 return Running() && value % intv < last_dt;
37 bool HitOnce() const noexcept {
38 return Running() && value >= intv;
40 int Elapsed() const noexcept {
43 int Interval() const noexcept {
46 int Iteration() const noexcept {
49 void PopIteration() noexcept {
53 void Update(int dt) noexcept {