diff --git a/multi/compat/love2d.lua b/multi/compat/love2d.lua index cc4015d..33451c0 100644 --- a/multi/compat/love2d.lua +++ b/multi/compat/love2d.lua @@ -33,43 +33,50 @@ function love.run() if love.load then love.load(arg) end if love.timer then love.timer.step() end local dt = 0 - while true do - -- Process events. - if love.event then - love.event.pump() - for e,a,b,c,d in love.event.poll() do - if e == "quit" then - if not love.quit or not love.quit() then - if love.audio then - love.audio.stop() + local breakme=false + multi:newThread("MAIN-RUN",function() + while true do + -- Process events. + if love.event then + love.event.pump() + for name, a,b,c,d,e,f in love.event.poll() do + if name == "quit" then + if not love.quit or not love.quit() then + breakme=true + thread.kill() + break end - return end + love.handlers[name](a,b,c,d,e,f) end - love.handlers[e](a,b,c,d) end + if love.timer then + love.timer.step() + dt = love.timer.getDelta() + end + if love.update then love.update(dt) end + if love.window and love.graphics and love.window.isCreated() then + love.graphics.clear() + love.graphics.origin() + if love.draw then love.draw() end + multi.dManager() + love.graphics.setColor(255,255,255,255) + if multi.draw then multi.draw() end + love.graphics.present() + end + thread.sleep() end - if love.timer then - love.timer.step() - dt = love.timer.getDelta() - end - if love.update then love.update(dt) end + end) + while not breakme do + love.timer.sleep(.005) + multi:uManager(dt) if multi.boost then for i=1,multi.boost-1 do multi:uManager(dt) end end - multi:uManager(dt) - if love.window and love.graphics and love.window.isCreated() then - love.graphics.clear() - love.graphics.origin() - if love.draw then love.draw() end - multi.dManager() - love.graphics.setColor(255,255,255,255) - if multi.draw then multi.draw() end - love.graphics.present() - end end + return end multi.drawF={} function multi:dManager() @@ -81,34 +88,34 @@ function multi:onDraw(func,i) i=i or 1 table.insert(self.drawF,i,func) end -function multi:lManager() - if love.event then - love.event.pump() - for e,a,b,c,d in love.event.poll() do - if e == "quit" then - if not love.quit or not love.quit() then - if love.audio then - love.audio.stop() - end - return nil - end - end - love.handlers[e](a,b,c,d) - end - end - if love.timer then - love.timer.step() - dt = love.timer.getDelta() - end - if love.update then love.update(dt) end - multi:uManager(dt) - if love.window and love.graphics and love.window.isCreated() then - love.graphics.clear() - love.graphics.origin() - if love.draw then love.draw() end - multi.dManager() - love.graphics.setColor(255,255,255,255) - if multi.draw then multi.draw() end - love.graphics.present() - end -end +--~ function multi:lManager() +--~ if love.event then +--~ love.event.pump() +--~ for e,a,b,c,d in love.event.poll() do +--~ if e == "quit" then +--~ if not love.quit or not love.quit() then +--~ if love.audio then +--~ love.audio.stop() +--~ end +--~ return nil +--~ end +--~ end +--~ love.handlers[e](a,b,c,d) +--~ end +--~ end +--~ if love.timer then +--~ love.timer.step() +--~ dt = love.timer.getDelta() +--~ end +--~ if love.update then love.update(dt) end +--~ multi:uManager(dt) +--~ if love.window and love.graphics and love.window.isCreated() then +--~ love.graphics.clear() +--~ love.graphics.origin() +--~ if love.draw then love.draw() end +--~ multi.dManager() +--~ love.graphics.setColor(255,255,255,255) +--~ if multi.draw then multi.draw() end +--~ love.graphics.present() +--~ end +--~ end