Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- main thread loop
- function love.run()
- if love.load then love.load(arg) end
- local dt = 0
- -- Main loop time.
- while true do
- if love.timer then
- love.timer.step()
- dt = love.timer.getDelta()
- end
- if love.update then love.update(dt) end -- will pass 0 if love.timer is disabled
- if love.graphics then
- love.graphics.clear()
- if love.draw then love.draw() end
- end
- if love.timer then love.timer.sleep(0.001) end
- if love.graphics then love.graphics.present() end
- end
- end
- -- update thread loop
- function sim:run()
- local dt = self.thread:demand("fps")
- local accumulator = 0
- local oldtime = love.timer.getMicroTime()
- while true do
- local curtime = love.timer.getMicroTime()
- local frametime = curtime-oldtime
- oldtime = curtime
- if frametime > 0.25 then print("crap", frametime) frametime = 0.25 end
- accumulator = accumulator + frametime
- while accumulator >= dt do
- accumulator = accumulator - dt
- -- Process events.
- for e,a,b,c in love.event.poll() do
- if e == "q" then
- if not love.quit or not love.quit() then
- if love.audio then
- love.audio.stop()
- end
- return
- end
- end
- self.handlers[e](a,b,c) -- made my own handlers based on ones in boot.lua
- end
- self:update(dt, accumulator)
- self:send()
- end
- love.timer.sleep(0.001) -- keeps CPU usage way down
- end
- end
Add Comment
Please, Sign In to add comment