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 {
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;