Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- The following function is based on the MIT licensed code here: https://gist.github.com/Positive07/5e80f03cabd069087930d569c148241c
- -- Copyright (c) 2018 Arvid Gerstmann, Jake Besworth, Max, Pablo Mayobre, LÖVE Developers, Henry Fleminger Thomson
- function love.run()
- love.load(love.arg.parseGameArguments(arg))
- love.timer.step()
- local delta, lag = 0, 0
- return function()
- do -- Events
- love.event.pump()
- for name, a,b,c,d,e,f in love.event.poll() do
- if name == "quit" then
- if not love.quit() then
- return a or 0
- end
- end
- love.handles[name](a,b,c,d,e,f)
- end
- end
- do -- Update
- local start = love.timer.getTime()
- delta = love.timer.step()
- lag = math.min(lag + delta, constants.core.tickRate * constants.core.maxFrameSkip)
- local frames = math.floor(lag / constants.core.tickRate)
- lag = lag % constants.core.tickRate
- for _=1, frames do
- love.update(constants.core.tickRate)
- end
- end
- if love.graphics.isActive() then -- Rendering
- love.graphics.origin()
- love.graphics.clear(love.graphics.getBackgroundColor())
- love.draw()
- love.graphics.present()
- end
- if not settings.current.manualGarbageCollection.disable then -- Garbage collection
- local start = love.timer.getTime()
- for _=1, settings.current.manualGarbageCollection.steps do
- if love.timer.getTime() - start > settings.current.manualGarbageCollection.timeLimit then break end
- collectgarbage("step", 1)
- end
- if collectgarbage("count") / 1024 > settings.current.manualGarbageCollection.safetyMargin then
- collectgarbage("collect")
- end
- collectgarbage("stop")
- end
- love.timer.sleep(0.001)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement