diff options
author | chai <chaifix@163.com> | 2018-07-31 12:19:22 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2018-07-31 12:19:22 +0800 |
commit | a5bb008eb554daf26f55b5fe43b0fa12ffb15973 (patch) | |
tree | 1eac93471b855ef878d3fd6a4614cfacb1ea6464 /src/lua | |
parent | 7ac86950d3a89a996974e8406ee88e8f5f44187d (diff) |
*update
Diffstat (limited to 'src/lua')
-rw-r--r-- | src/lua/audio/luaopen_Source.cpp | 9 | ||||
-rw-r--r-- | src/lua/embed/boot.lua.h | 65 | ||||
-rw-r--r-- | src/lua/graphics/luaopen_Image.cpp | 2 | ||||
-rw-r--r-- | src/lua/graphics/luaopen_graphics.cpp | 2 |
4 files changed, 34 insertions, 44 deletions
diff --git a/src/lua/audio/luaopen_Source.cpp b/src/lua/audio/luaopen_Source.cpp index 0b8391a..d147e5e 100644 --- a/src/lua/audio/luaopen_Source.cpp +++ b/src/lua/audio/luaopen_Source.cpp @@ -84,7 +84,16 @@ namespace lua return 0; } + static int l_gc(lua_State* L) + { + SDLSource* src = checkSource(L); + src->stop(); + delete src; + return 0; + } + static const luaL_Reg f[] = { + { "__gc", l_gc }, { "play", l_play }, { "stop", l_stop }, { "pause", l_pause }, 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 diff --git a/src/lua/graphics/luaopen_Image.cpp b/src/lua/graphics/luaopen_Image.cpp index 5fc9aea..546e6b1 100644 --- a/src/lua/graphics/luaopen_Image.cpp +++ b/src/lua/graphics/luaopen_Image.cpp @@ -12,7 +12,7 @@ namespace lua static inline Texture* checkTexture(lua_State* L) { Proxy* proxy = (Proxy*)luax_checktype(L, 1, TYPE_IMAGE); - if (proxy != 0 && proxy != nullptr) + if (proxy != nullptr) return (Texture*)proxy->object; return nullptr; } diff --git a/src/lua/graphics/luaopen_graphics.cpp b/src/lua/graphics/luaopen_graphics.cpp index a394cc3..2aa68e8 100644 --- a/src/lua/graphics/luaopen_graphics.cpp +++ b/src/lua/graphics/luaopen_graphics.cpp @@ -500,7 +500,7 @@ namespace lua {"circle", l_drawCircle}, {"triangle", l_drawTriangle}, {"polygon", l_drawPolygon}, - // + // quit window {"destroy", l_destroy}, {0, 0} }; |