fixed Time::on_interval overloading conflicts

This commit is contained in:
Noel Berry 2020-09-19 11:55:18 -07:00
parent 86e15adf0f
commit f599df02cc
2 changed files with 17 additions and 17 deletions

View File

@ -23,9 +23,9 @@ void Time::pause_for(float time)
pause_timer = 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) 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); 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) 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; 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) bool Time::between_interval(float interval, float offset)
{ {
return between_interval(Time::elapsed, interval, 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;
}

View File

@ -23,22 +23,22 @@ namespace Blah
// pauses the entire application for the given time // pauses the entire application for the given time
static void pause_for(float 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 // returns true on the given time interval
static bool on_interval(float interval, float offset = 0); 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 // returns true when the given timestamp is passed
static bool on_time(float time, float timestamp); static bool on_time(float time, float timestamp);
// returns true between time intervals // 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 // returns true between time intervals
static bool between_interval(float interval, float offset = 0); static bool between_interval(float time, float interval, float offset);
}; };
} }