Using own's FPS handler, but FPS still 60?
Posted: Wed Jun 14, 2017 10:17 am
I replaced LOVE's internal code (which is love.run) with my own, but FPS still 60. Is it V-Sync in effect? Because I wonder if I could set the FPS more than 60, like 120. But I guess I'm asking something that has been asked like million times, right?
No sleep, no step... just nothing. I wanted to follow wiki's sample, but I wanted to see what would happen if I use mine. If you're wondering, I followed SFML's code to handle FPS. Also if you need the LOVE file, I'll give it to you.
Code: Select all
...
Game.TimePerFrame = 1 / 30
...
function Game:run()
lmath.setRandomSeed(os.time())
local currentTime, previousTime = ltimer.getTime(), ltimer.getTime()
local timeSinceLastUpdate = 0
while lwindow.isOpen() do
local deltaTime = currentTime - previousTime
previousTime = currentTime
currentTime = ltimer.getTime()
timeSinceLastUpdate = timeSinceLastUpdate + deltaTime
print(deltaTime) -- around 0.016666666666666666667 or 1 / 60
while timeSinceLastUpdate > self.TimePerFrame do
timeSinceLastUpdate = timeSinceLastUpdate - self.TimePerFrame
self:_handleEvent()
self:_update(self.TimePerFrame)
if self._stateStack:isEmpty() then
lwindow.close()
end
end
self:_draw()
end
end