diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/libjin/Core/Game.cpp | 6 | ||||
-rw-r--r-- | src/libjin/Core/Game.h | 2 | ||||
-rw-r--r-- | src/libjin/core/game.cpp | 6 | ||||
-rw-r--r-- | src/libjin/core/game.h | 2 | ||||
-rw-r--r-- | src/libjin/modules.h | 12 | ||||
-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 | ||||
-rw-r--r-- | src/main.cpp | 4 |
10 files changed, 52 insertions, 58 deletions
diff --git a/src/libjin/Core/Game.cpp b/src/libjin/Core/Game.cpp index 929cc07..c5dd5a5 100644 --- a/src/libjin/Core/Game.cpp +++ b/src/libjin/Core/Game.cpp @@ -26,7 +26,7 @@ namespace core _running = true; Event e; int previous = getMilliSecond(); - float dt = MS_PER_UPDATE / 1000.0f; + int dt = MS_PER_UPDATE; while (_running) { while (jin::input::pollEvent(&e)) @@ -38,13 +38,13 @@ namespace core SAFECALL(_onDraw); wnd->swapBuffers(); const int current = getMilliSecond(); - dt = (current - previous) / 1000.0f; + dt = current - previous; const int wait = MS_PER_UPDATE - (current - previous); previous += MS_PER_UPDATE; if (wait > 0) { sleep(wait); - dt = MS_PER_UPDATE / 1000.0f; + dt = MS_PER_UPDATE; } else previous = current; diff --git a/src/libjin/Core/Game.h b/src/libjin/Core/Game.h index 9359487..31f32d8 100644 --- a/src/libjin/Core/Game.h +++ b/src/libjin/Core/Game.h @@ -18,7 +18,7 @@ namespace core typedef void(*onLoad)(); typedef void(*onEvent)(jin::input::Event* e); - typedef void(*onUpdate)(float dt); + typedef void(*onUpdate)(int dt); typedef void(*onDraw)(); struct Setting : SettingBase diff --git a/src/libjin/core/game.cpp b/src/libjin/core/game.cpp index 929cc07..c5dd5a5 100644 --- a/src/libjin/core/game.cpp +++ b/src/libjin/core/game.cpp @@ -26,7 +26,7 @@ namespace core _running = true; Event e; int previous = getMilliSecond(); - float dt = MS_PER_UPDATE / 1000.0f; + int dt = MS_PER_UPDATE; while (_running) { while (jin::input::pollEvent(&e)) @@ -38,13 +38,13 @@ namespace core SAFECALL(_onDraw); wnd->swapBuffers(); const int current = getMilliSecond(); - dt = (current - previous) / 1000.0f; + dt = current - previous; const int wait = MS_PER_UPDATE - (current - previous); previous += MS_PER_UPDATE; if (wait > 0) { sleep(wait); - dt = MS_PER_UPDATE / 1000.0f; + dt = MS_PER_UPDATE; } else previous = current; diff --git a/src/libjin/core/game.h b/src/libjin/core/game.h index 9359487..31f32d8 100644 --- a/src/libjin/core/game.h +++ b/src/libjin/core/game.h @@ -18,7 +18,7 @@ namespace core typedef void(*onLoad)(); typedef void(*onEvent)(jin::input::Event* e); - typedef void(*onUpdate)(float dt); + typedef void(*onUpdate)(int dt); typedef void(*onDraw)(); struct Setting : SettingBase diff --git a/src/libjin/modules.h b/src/libjin/modules.h index 2e8e36f..171c691 100644 --- a/src/libjin/modules.h +++ b/src/libjin/modules.h @@ -6,7 +6,7 @@ #define JIN_MODULES_AUDIO 1 #define JIN_AUDIO_SDLAUDIO 1 -#define JIN_AUDIO_OPENAL 0 +#define JIN_AUDIO_OPENAL 1 #define JIN_MODULES_RENDER 1 @@ -21,22 +21,22 @@ #define JIN_MODULES_NET 1 -#define JIN_MODULES_PHYSICS 0 +#define JIN_MODULES_PHYSICS 1 #define JIN_PHYSICS_BOX2D 1 #define JIN_PHYSICS_NEWTON 1 -#define JIN_MODULES_TILEMAP 0 +#define JIN_MODULES_TILEMAP 1 -#define JIN_MODULES_UI 0 +#define JIN_MODULES_UI 1 -#define JIN_MODULES_TOOLS 0 +#define JIN_MODULES_TOOLS 1 #define JIN_TOOLS_COMPONENT 1 #define JIN_TOOLS_EVENTMSGCENTER 1 #define JIN_TOOLS_XML 1 #define JIN_TOOLS_CSV 1 #define JIN_TOOLS_JSON 1 -#define JIN_MODULES_THREAD 0 +#define JIN_MODULES_THREAD 1 #define JIN_MODULES_TIME 1 #define JIN_TIME_SDL 1 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} }; diff --git a/src/main.cpp b/src/main.cpp index 256f39d..50d4ef0 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -10,6 +10,7 @@ #include "libjin/jin.h" +#include <iostream> #include <Windows.h> int main(int argc, char* argv[]) @@ -43,6 +44,9 @@ int main(int argc, char* argv[]) #undef BUFFER_SIZE luax_setfield_string(L, "_dir", buffer); + short a = -9; + std::cout << (a << 8); + // boot jin::lua::boot(L); |