I’m using Love2D to create a small game for my friends and I but, I’m having a problem:
I want to calculate elapsed time, independent from the framerate. I’m trying this but slight error adds up and eventually a ‘second’ passes in a 1/100th of a second.
local last_time = os.time()
function timeofday_update()
world_time = world_time + os.time() - last_time
end
Why not mark the time at the beginning of the program, or beginning of whenever (starting_time = os.time()), and then ‘current elapsed time’ is just os.time() – starting_time. No accumulation necessary…