aboutsummaryrefslogtreecommitdiff
path: root/src/lua/embed/boot.lua.h
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2018-07-31 12:19:22 +0800
committerchai <chaifix@163.com>2018-07-31 12:19:22 +0800
commita5bb008eb554daf26f55b5fe43b0fa12ffb15973 (patch)
tree1eac93471b855ef878d3fd6a4614cfacb1ea6464 /src/lua/embed/boot.lua.h
parent7ac86950d3a89a996974e8406ee88e8f5f44187d (diff)
*update
Diffstat (limited to 'src/lua/embed/boot.lua.h')
-rw-r--r--src/lua/embed/boot.lua.h65
1 files changed, 23 insertions, 42 deletions
diff --git a/src/lua/embed/boot.lua.h b/src/lua/embed/boot.lua.h
index 1ba613b..c73e9f9 100644
--- a/src/lua/embed/boot.lua.h
+++ b/src/lua/embed/boot.lua.h
@@ -31,60 +31,41 @@ local function safecall(func, ...)
end
function jin.core.run()
- local load = jin.core.load
- local running = jin.core.running
- local second = jin.time.second
- local sleep = jin.time.sleep
- local poll = jin.event.poll
- local unbind = jin.graphics.unbind
- local clear = jin.graphics.clear
- local color = jin.graphics.color
- local study = jin.graphics.study
- local onDraw = jin.core.onDraw
- local onUpdate = jin.core.onUpdate
- local onEvent = jin.core.onEvent
- local present = jin.graphics.present
- local setkey = jin.keyboard.set
- local dstatus = jin.debug.status
- local drender = jin.debug.render
-
- local fps = conf.fps
-
- safecall(load)
- local previous = second()
- local SEC_PER_UPDATE = 1 / fps
+ safecall(jin.core.load)
+ local previous = jin.time.second()
+ local SEC_PER_UPDATE = 1 / conf.fps
local dt = SEC_PER_UPDATE
- while(running()) do
- for _, e in pairs(poll()) do
+ while(jin.core.running()) do
+ for _, e in pairs(jin.event.poll()) do
if e.type == "keydown" then
- setkey(e.key, true)
+ jin.keyboard.set(e.key, true)
elseif e.type == "keyup" then
- setkey(e.key, false)
+ jin.keyboard.set(e.key, false)
end
- safecall(onEvent, e)
+ safecall(jin.core.onEvent, e)
end
- if not running() then
+ if not jin.core.running() then
break
end
- safecall(onUpdate, dt)
- -- bind to default render buffer
- unbind()
- clear()
- color()
- study()
- safecall(onDraw)
- -- render debug window
- if dstatus() then
- drender()
+
+ safecall(jin.core.onUpdate, dt)
+
+ jin.graphics.unbind()
+ jin.graphics.clear()
+ jin.graphics.color()
+ jin.graphics.study()
+ safecall(jin.core.onDraw)
+ if jin.debug.status() then
+ jin.debug.render()
end
- present()
- -- frame control
- local current = second()
+ jin.graphics.present()
+
+ local current = jin.time.second()
dt = current - previous
local wait = SEC_PER_UPDATE - dt
previous = previous + SEC_PER_UPDATE
if wait > 0 then
- sleep(wait)
+ jin.time.sleep(wait)
dt = SEC_PER_UPDATE
else
previous = current