diff options
Diffstat (limited to 'src/lua/modules/embed/boot.lua.h')
-rw-r--r-- | src/lua/modules/embed/boot.lua.h | 42 |
1 files changed, 17 insertions, 25 deletions
diff --git a/src/lua/modules/embed/boot.lua.h b/src/lua/modules/embed/boot.lua.h index 4f8ed94..cc71102 100644 --- a/src/lua/modules/embed/boot.lua.h +++ b/src/lua/modules/embed/boot.lua.h @@ -37,16 +37,6 @@ local function call(func, ...) end end -jin.core.setHandler = function(handler) - if handler == nil then - return - end - jin.core.onLoad = handler.onLoad - jin.core.onEvent = handler.onEvent - jin.core.onUpdate = handler.onUpdate - jin.core.onDraw = handler.onDraw -end - function jin.core.run() call(jin.core.onLoad) local dt = 0 @@ -64,21 +54,12 @@ function jin.core.run() end previous = current current = jin.time.second() - dt = dt + current - previous - local refresh = false - while dt > SECOND_PER_FRAME do - call(jin.core.onUpdate, SECOND_PER_FRAME) - dt = dt - SECOND_PER_FRAME - refresh = true - end - if refresh and jin.graphics then - jin.graphics.clear() - call(jin.core.onDraw) - jin.graphics.present() - end - if jin.time then - jin.time.sleep(0.001) - end + dt = current - previous + call(jin.core.onUpdate, dt) + call(jin.graphics.clear) + call(jin.core.onDraw) + call(jin.graphics.present) + call(jin.time.sleep, 0.001) end end @@ -86,6 +67,16 @@ end -- No game handler ------------------------------------------------------------------------- +jin.core.setHandler = function(handler) + if handler == nil then + return + end + jin.core.onLoad = handler.onLoad + jin.core.onEvent = handler.onEvent + jin.core.onUpdate = handler.onUpdate + jin.core.onDraw = handler.onDraw +end + jin.nogame = { cs = 64, sw = jin.graphics.getWidth(), @@ -108,6 +99,7 @@ jin.nogame = { end end, onUpdate = function(dt) + print(dt) local nogame = jin.nogame nogame.t = nogame.t + dt * nogame.speed if nogame.t > nogame.ww2 then |