quick question : is the instance attribute update_interval a constant value that is set up during Gosu::Window creation, or is that variable updated regarding the real FPS we are getting ?
I'm asking this because lot's of frameworks are passing the delta_time within the update method, and Gosu is not if I'm not wrong. And it would be really good to have such a value, corresponding to the really elapsed time between two frames.
Something like :
# so that we can use dt to calculate things, considering frame drop
is that update_interval aware of frame drop ? Doesn't seem so.
For sure I could use Gosu::milliseconds to calculate this difference, but I don't want to reinvent something that is already there :)
update_interval (both the constructor argument, and the r/w property) controls the target framerate of Gosu. However, because Gosu usually waits for a vsync each frame, higher values than 60 (or whatever your screen uses) don't work.
The vsync part is actually becoming a bit of an issue. When I first wrote Gosu, CRT screens started being replaced by TFT flatscreens which all had a 60 Hz refresh rate, and I hoped that 60 Hz would be *the* standard framerate for a long time. But I've now received issue reports on GitHub from users with 40 Hz(!) laptop screens, and many desktop screens are running at 75 Hz all the way up to 144 Hz. And some unlucky people probably run their computer at 30 Hz because their HDMI cable can't do 4K at 60 Hz etc... Gosu's model of always running at 60 FPS is sadly not flexible enough for the reality of today's screens.
If you want to work with delta time, I suggest you use a really small value for
update_interval, maybe 5, so that Gosu will max out the screen's Hz if possible. And then you measure the frame length yourself using
Gosu.milliseconds (from one
update call to the next), and move your objects accordingly.
So my simple question got a pretty complete answer ! Thanks, as always ! :)
Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill