X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fapp%2FIntervalTimer.hpp;h=5240f5d3f60a419e8593b5e883dab9fd5c8e8d1c;hb=38a4cffc0b6aa58e49d24c06aad7bee14cb6515d;hp=bcf1baef29e290fafbe90079d4daabc05052914b;hpb=3f35e70a6b66daf2ffd59590e98e2dd11e6eaabb;p=blank.git diff --git a/src/app/IntervalTimer.hpp b/src/app/IntervalTimer.hpp index bcf1bae..5240f5d 100644 --- a/src/app/IntervalTimer.hpp +++ b/src/app/IntervalTimer.hpp @@ -13,7 +13,7 @@ class IntervalTimer { public: /// Create a timer that hits every interval_ms milliseconds. /// Initial state is stopped. - explicit IntervalTimer(int interval_ms) noexcept + explicit IntervalTimer(int interval_ms = 0) noexcept : intv(interval_ms) { } void Start() noexcept { @@ -35,14 +35,20 @@ public: return Running() && value % intv < last_dt; } bool HitOnce() const noexcept { - return value >= intv; + return Running() && value >= intv; } int Elapsed() const noexcept { return value; } + int Interval() const noexcept { + return intv; + } int Iteration() const noexcept { return value / intv; } + void PopIteration() noexcept { + value -= intv; + } void Update(int dt) noexcept { value += dt * speed;