diff --git a/public/blah/time.cpp b/public/blah/time.cpp index d3f5128..12215c3 100644 --- a/public/blah/time.cpp +++ b/public/blah/time.cpp @@ -23,9 +23,9 @@ void Time::pause_for(float time) pause_timer = time; } -bool Time::on_interval(float time, float delta, float interval, float offset) +bool Time::on_interval(float interval, float offset) { - return floor((time - offset - delta) / interval) < floor((time - offset) / interval); + return Time::on_interval(Time::elapsed, Time::delta, interval, offset); } bool Time::on_interval(float delta, float interval, float offset) @@ -33,9 +33,9 @@ bool Time::on_interval(float delta, float interval, float offset) return Time::on_interval(Time::elapsed, delta, interval, offset); } -bool Time::on_interval(float interval, float offset) +bool Time::on_interval(float time, float delta, float interval, float offset) { - return Time::on_interval(Time::elapsed, Time::delta, interval, offset); + return floor((time - offset - delta) / interval) < floor((time - offset) / interval); } bool Time::on_time(float time, float timestamp) @@ -43,12 +43,12 @@ bool Time::on_time(float time, float timestamp) return time >= timestamp && time - Time::delta < timestamp; } -bool Time::between_interval(float time, float interval, float offset) -{ - return modf(time - offset, interval * 2) >= interval; -} - bool Time::between_interval(float interval, float offset) { return between_interval(Time::elapsed, interval, offset); } + +bool Time::between_interval(float time, float interval, float offset) +{ + return modf(time - offset, interval * 2) >= interval; +} diff --git a/public/blah/time.h b/public/blah/time.h index 8737b54..e17a3be 100644 --- a/public/blah/time.h +++ b/public/blah/time.h @@ -23,22 +23,22 @@ namespace Blah // pauses the entire application for the given time static void pause_for(float time); - // returns true on the given time interval - static bool on_interval(float time, float delta, float interval, float offset = 0); - - // returns true on the given time interval - static bool on_interval(float delta, float interval, float offset = 0); - // returns true on the given time interval static bool on_interval(float interval, float offset = 0); + // returns true on the given time interval + static bool on_interval(float delta, float interval, float offset); + + // returns true on the given time interval + static bool on_interval(float time, float delta, float interval, float offset); + // returns true when the given timestamp is passed static bool on_time(float time, float timestamp); // returns true between time intervals - static bool between_interval(float time, float interval, float offset = 0); + static bool between_interval(float interval, float offset = 0); // returns true between time intervals - static bool between_interval(float interval, float offset = 0); + static bool between_interval(float time, float interval, float offset); }; } \ No newline at end of file