Shadowblitz16 wrote: ↑Fri Mar 22, 2019 12:14 am
I would like to know how to safeguard against gigantic deltas.
You can manually throttle thread update rate instead of using OS sleep function by spinning the CPU instead. That way you will have very precise and reliable control over the frame timing. The downside is that it stresses the CPU core to 100% at all times. The OS gives no guarantees that the program will wake up after sleep in exactly specified amount of time. It could wake up sooner than specified, or much later.
Instead of using love.timer.sleep you'd run an infinite loop that checks if it's time to update yet.
function love.load()
fps=60
end
function love.draw(dt)
love.timer.sleep((1/fps)-dt)
--other stuff
end
It works if you don't have any code you want to run, otherwise you need to calculate how much time that took, and subtract that as well, not just whatever dt was... also, you replied to a year old thread.
Me and my stuff True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.