local function call(func, ...) if func then return func(...) end end function jin.core.run() call(jin.core.onLoad) local dt = 0 local previous = jin.time.second() local current = previous -- TODO: 重写,事件处理事件应该高频率调用 while jin.core.running() do for _, e in pairs(jin.event.poll()) do if e.type == "keydown" then jin.keyboard.set(e.key, true) elseif e.type == "keyup" then jin.keyboard.set(e.key, false) end call(jin.core.onEvent, e) end previous = current current = jin.time.second() dt = current - previous call(jin.core.onUpdate, dt) if jin.graphics then jin.graphics.unbindCanvas() jin.graphics.clear() jin.graphics.setColor() jin.graphics.setFont() call(jin.core.onDraw) jin.graphics.present() end if jin.time then jin.time.sleep(0.001) end end end