getFps() reports fps wrong for ~1 sec after pausing

I'm using a system where my players speed is based on frame rate so the player always moves smoothly. It gets multiplied by a Delta variable (1/playdate.getFps()). After pausing for roughly a second the Delta variable reports negative.

To reproduce:
Inside playdate.update() print getFps(). After pausing and resuming the value will be off.

The getFps() function is calculated over many frames, so it won't always be exactly accurate. It depends a lot on what your game is doing.

We could probably improve things a little by taking into account when the device is paused (I'll file an issue on that), but I wonder if using display.setRefreshRate() might be a more reliable option for what you're doing?

Sadly, my game is very fast so I've gotta keep it running at 50fps so collisions and all work. getFps() is the only way it would work besides calculating it myself. Thanks for filing another issue!

For my delta time values I call playdate.getElapsedTime() followed by playdate.resetElapsedTime() at the start of each frame (i.e. in playdate.update), storing the result of getElapsedTime in a global variable so my movement code can reference it. I also call playdate.resetElapsedTime() when unpausing to avoid having a large delta.

That keeps the movement accurate down to the individual frame. Would that work for you or is there a reason you need an average over multiple frames?


Oh that'd work perfectly! Thank you!