|
|
@@ -1,12 +1,46 @@
|
|
|
-#include <iostream>
|
|
|
+#include "lua.hpp"
|
|
|
#include "Crown.h"
|
|
|
-#include <unistd.h>
|
|
|
+#include "Game.h"
|
|
|
|
|
|
-using namespace crown;
|
|
|
|
|
|
-int main(int argc, char** argv)
|
|
|
+namespace crown
|
|
|
{
|
|
|
|
|
|
+lua_State* state;
|
|
|
+int z;
|
|
|
|
|
|
- return 0;
|
|
|
+void init()
|
|
|
+{
|
|
|
+ state = luaL_newstate();
|
|
|
+ luaL_openlibs(state);
|
|
|
+
|
|
|
+ if (luaL_loadfile(state, "lua/lua/game.lua.script") || lua_pcall(state, 0, 0, 0))
|
|
|
+ {
|
|
|
+ os::printf("error: %s", lua_tostring(state, -1));
|
|
|
+ }
|
|
|
+
|
|
|
+ lua_getglobal(state, "init");
|
|
|
+
|
|
|
+ lua_pcall(state, 0, 0, 0);
|
|
|
+}
|
|
|
+
|
|
|
+void shutdown()
|
|
|
+{
|
|
|
+ lua_getglobal(state, "shutdown");
|
|
|
+
|
|
|
+ lua_pcall(state, 0, 0, 0);
|
|
|
+
|
|
|
+ lua_close(state);
|
|
|
+}
|
|
|
+
|
|
|
+void frame(float dt)
|
|
|
+{
|
|
|
+ lua_getglobal(state, "frame");
|
|
|
+
|
|
|
+ lua_pushnumber(state, dt);
|
|
|
+
|
|
|
+ lua_pcall(state, 1, 0, 0);
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+}
|