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?
...
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
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.
Game:run? it looks like you are using a gamestate lib. Your gamestate lib won't handle :run(), since there can only be one infinite outer loop. Instead overload love.run directly.
Oops, I didn't tell where Game:run is called, did I? It's basically called in love.run, but I guess I need to upload my LOVE then (small pun there). Edit: And... Game:run is in game.lua which is called by love.run in main.lua.
Yes, it's vsync; if you have it enabled or you're not using threads, you can't have the game loop run faster than that; you can try turning off vsync and manually adjusting how fast you update and draw, using deltatime.
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.
Damn, I only could adjust the FPS at around 1-60, huh? So even though I don't use anything that block the while loop, V-Sync could still block it. Thanks!
I mean, without vsync, you can get about 1000 fps, with the default love.run (love.timer.sleep(0.001) limits it to that), with vsync on, i believe love.graphics.present does the blocking (which you need, and can't avoid).
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.