mirror of
https://github.com/Keyslam-Group/Concord.git
synced 2025-09-02 20:33:54 -04:00
Fixed the love.run loop and moved it into its own file. Fixed examples
This commit is contained in:
parent
afe6573b18
commit
42213fcdf9
8 changed files with 208 additions and 3 deletions
55
concord/run.lua
Normal file
55
concord/run.lua
Normal file
|
@ -0,0 +1,55 @@
|
|||
local PATH = (...):gsub('%.[^%.]+$', '')
|
||||
|
||||
local Concord = require(PATH)
|
||||
|
||||
return function()
|
||||
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 or 0
|
||||
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
|
Loading…
Add table
Add a link
Reference in a new issue