aboutsummaryrefslogtreecommitdiff
path: root/src/lua/modules/embed/boot.lua.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/lua/modules/embed/boot.lua.h')
-rw-r--r--src/lua/modules/embed/boot.lua.h26
1 files changed, 13 insertions, 13 deletions
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