Limiting FPS by modifying love.run()
Posted: Mon Oct 15, 2018 12:11 am
I'm playing around with deliberately trying to limit the FPS of my game. I've modified love.run to do this, using an accumulator and updating every 1/30th of a second. I believe this should only draw to the screen once every 1/30th of a second, approximately.
For some reason, love.timer.getFPS() reports very high FPS (400+) even with vsync on. Why is this?
Code: Select all
...
if love.timer then dt = love.timer.step() end
accumulator = accumulator + dt
if accumulator >= tick_rate then
accumulator = 0
if love.update then love.update() end
if love.graphics and love.graphics.isActive() then
love.graphics.origin()
love.graphics.clear(love.graphics.getBackgroundColor())
if love.draw then love.draw() end
love.graphics.present()
end
end
if love.timer then love.timer.sleep(0.001) end