diff options
author | chai <chaifix@163.com> | 2018-08-24 19:03:02 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2018-08-24 19:03:02 +0800 |
commit | e6e3c76c1f2829537d368501a74af0646f5559d4 (patch) | |
tree | 89162f336e26ee2281fe027cb567902917d548f6 | |
parent | 44f7285515c732b5ff1736fa4e206c9bb3309981 (diff) |
*update
-rw-r--r-- | bin/jin.exe | bin | 548352 -> 548864 bytes | |||
-rw-r--r-- | src/lua/modules/embed/boot.lua.h | 26 |
2 files changed, 13 insertions, 13 deletions
diff --git a/bin/jin.exe b/bin/jin.exe Binary files differindex 874ca50..c87da6e 100644 --- a/bin/jin.exe +++ b/bin/jin.exe diff --git a/src/lua/modules/embed/boot.lua.h b/src/lua/modules/embed/boot.lua.h index d84ca21..4f8ed94 100644 --- a/src/lua/modules/embed/boot.lua.h +++ b/src/lua/modules/embed/boot.lua.h @@ -14,10 +14,11 @@ if jin.filesystem.exist("config.lua") then end jin.config.width = jin.config.width or 576 jin.config.height = jin.config.height or 448 -jin.config.vsync = jin.config.vsync or false +jin.config.vsync = jin.config.vsync or true jin.config.title = jin.config.title or ("jin v" .. jin.version()) jin.config.resizable = jin.config.resizable or false jin.config.fullscreen = jin.config.fullscreen or false +jin.config.fps = jin.config.fps or 60 ------------------------------------------------------------------------- -- Initialize sub systems @@ -51,6 +52,7 @@ function jin.core.run() local dt = 0 local previous = jin.time.second() local current = previous + local SECOND_PER_FRAME = 1/jin.config.fps while jin.core.running() do for _, e in pairs(jin.event.poll()) do if e.type == "keydown" then @@ -60,25 +62,23 @@ function jin.core.run() 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() + 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() - jin.graphics.setColor() - jin.graphics.setFont() call(jin.core.onDraw) jin.graphics.present() - end - + end if jin.time then jin.time.sleep(0.001) - end + end end end |