Supporting all display frame rates


I upgraded from a laptop with a 60Hz display to one with a 120Hz display, and suddenly Fracas 3 played at 2x speed. I instantly regretted hardcoding my game(s) to expect 60 frames per second. I remember folks making similar mistakes with CPU clock speeds, a million years ago. I wonder how many people have tried to play this game and thought “oh dang that’s way too fast”? Or too slow?

Anyhow, I switched to using the actual measured time between frames to decide how much to advance the world clock, instead of assuming every frame is 16 milliseconds.

It took a few tries to get right. I needed a little extra code to get it to work with pausing and stepping. And I didn’t bother with using the visibility API to check for tab freeze/unfreeze caused by tab switching etc. Hackily, I forced each frame to never be more than 2x the length of the previous one, which is robust and simple, even if it’s not absolutely perfect.


If you actually want the game to be faster or slower, you can tweak the speed in the settings menu:

Files

fracas3.zip Play in browser
Feb 23, 2023

Leave a comment

Log in with itch.io to leave a comment.