mirror of
https://github.com/Keyslam-Group/Concord.git
synced 2025-09-03 21:03:54 -04:00
Fixed the love.run loop and moved it into its own file
This commit is contained in:
parent
333f43eff9
commit
7a5050b016
1 changed files with 7 additions and 51 deletions
|
@ -2,6 +2,12 @@ local PATH = (...):gsub('%.init$', '')
|
||||||
|
|
||||||
local Concord = {}
|
local Concord = {}
|
||||||
|
|
||||||
|
--- Initializes the library with some optional settings
|
||||||
|
-- @param settings Table of settings: {
|
||||||
|
-- useEvents Flag to overwrite love.run and use events. Defaults to false
|
||||||
|
-- }
|
||||||
|
-- @return Concord
|
||||||
|
}
|
||||||
function Concord.init(settings)
|
function Concord.init(settings)
|
||||||
Concord.entity = require(PATH..".entity")
|
Concord.entity = require(PATH..".entity")
|
||||||
Concord.component = require(PATH..".component")
|
Concord.component = require(PATH..".component")
|
||||||
|
@ -22,57 +28,7 @@ function Concord.init(settings)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
love.run = function()
|
love.run = require(PATH..".run")
|
||||||
if love.math then
|
|
||||||
love.math.setRandomSeed(os.time())
|
|
||||||
love.timer.step()
|
|
||||||
end
|
|
||||||
|
|
||||||
for _, instance in ipairs(Concord.instances) do
|
|
||||||
instance:emit("load", arg)
|
|
||||||
end
|
|
||||||
|
|
||||||
if love.timer then love.timer.step() end
|
|
||||||
|
|
||||||
local dt = 0
|
|
||||||
|
|
||||||
return function()
|
|
||||||
if love.event then
|
|
||||||
love.event.pump()
|
|
||||||
for name, a, b, c, d, e, f in love.event.poll() do
|
|
||||||
for _, instance in ipairs(Concord.instances) do
|
|
||||||
instance:emit(name, a, b, c, d, e, f)
|
|
||||||
end
|
|
||||||
|
|
||||||
if name == "quit" then
|
|
||||||
return a
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if love.timer then
|
|
||||||
love.timer.step()
|
|
||||||
dt = love.timer.getDelta()
|
|
||||||
end
|
|
||||||
|
|
||||||
for _, instance in ipairs(Concord.instances) do
|
|
||||||
instance:emit("update", dt)
|
|
||||||
end
|
|
||||||
|
|
||||||
if love.graphics and love.graphics.isActive() then
|
|
||||||
love.graphics.clear(love.graphics.getBackgroundColor())
|
|
||||||
love.graphics.origin()
|
|
||||||
|
|
||||||
for _, instance in ipairs(Concord.instances) do
|
|
||||||
instance:emit("draw")
|
|
||||||
end
|
|
||||||
|
|
||||||
love.graphics.present()
|
|
||||||
end
|
|
||||||
|
|
||||||
if love.timer then love.timer.sleep(0.001) end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return Concord
|
return Concord
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue