coffee icon indicating copy to clipboard operation
coffee copied to clipboard

add `should_draw` to Game trait

Open JeanMertz opened this issue 4 years ago • 1 comments

I tried to implement an FPS limit solution in my game by returning early from Game::draw if the minimum time between frames wasn't met yet, but noticed that this broke horribly due to Coffee still doing a lot of pre-/post-processing on every draw call.

By exposing Game::should_draw, the game can decide when Coffee should trigger another draw. The default return value is true, which results in the same behaviour as before this change.

I haven't dug too deep into Coffee yet, but I believe timer.update() should still always run? At least anecdotally, for me, this change behaves as expected.

JeanMertz avatar May 18 '20 08:05 JeanMertz

Further testing exposed that this change isn't behaving as expected. It appears the input state is not cleared if the draw call is skipped, which causes the interact method to receive duplicate input events.

I'm not sure where/how this happens, but this PR isn't merge-able as is.

JeanMertz avatar May 19 '20 22:05 JeanMertz