TimeFrame()
Provides the appropriate frame based on time given (as duration).
The implementation of time is highly dependent on the language and
environment, but any conventional method should do.
If better suited, this function can be re-implemented for engine runtimes.
function TimeFrame(
time: Time,
animation: Animation,
reverse: Bool,
isLoop: Bool,
): Int {
const elapsed: Float = time.asMillis() / 1e3;
const frametime: Float = 1.0 / animation.fps;
let frame: Int = elapsed / frametime;
frame = formatFrame(frame, animation, reverse, isLoop);
return frame;
}