Limit UPS to 1000

This commit is contained in:
Rin 2021-08-20 21:38:58 +01:00
parent 49b39259e5
commit 8bdd067978
2 changed files with 18 additions and 11 deletions

View File

@ -1 +1 @@
version = "v0.3-beta6-nrs" version = "v0.3-beta6"

View File

@ -291,6 +291,7 @@ function love.resize(w, h)
end end
local TARGET_FPS = 60 local TARGET_FPS = 60
local TARGET_UPS = 1000
--[[ --[[
-- OLD RUN CODE BELOW -- OLD RUN CODE BELOW
@ -361,19 +362,29 @@ function love.run()
if love.timer then love.timer.step() end if love.timer then love.timer.step() end
local u_tacc = 0
local tacc = 0 local tacc = 0
local start_time = love.timer.getTime() local start_time = love.timer.getTime()
return function() return function()
local ut = love.timer.getTime()
runsystem.updatedelta = ut - start_time
if love.event then if love.event then
love.event.pump() u_tacc = u_tacc + runsystem.updatedelta
for n, a, b, c, d, e, f in love.event.poll() do
if n == 'quit' then if u_tacc >= 1 / TARGET_UPS then
if not love.quit or not love.quit() then runsystem.updatefps = 1 / u_tacc
return a or 0 u_tacc = 0
love.event.pump()
for n, a, b, c, d, e, f in love.event.poll() do
if n == 'quit' then
if not love.quit or not love.quit() then
return a or 0
end
end end
love.handlers[n](a, b, c, d, e, f)
end end
love.handlers[n](a, b, c, d, e, f)
end end
end end
@ -381,10 +392,6 @@ function love.run()
processBGMFadeout(love.timer.step()) processBGMFadeout(love.timer.step())
end end
local ut = love.timer.getTime()
runsystem.updatedelta = ut - start_time
runsystem.updatefps = 1 / (ut - start_time)
if scene and scene.update and love.timer then if scene and scene.update and love.timer then
local delta = ut - start_time local delta = ut - start_time
start_time = ut start_time = ut