Game.cpp 497 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #include "lua.hpp"
  2. #include "Device.h"
  3. #include "Game.h"
  4. namespace crown
  5. {
  6. lua_State* state;
  7. void init()
  8. {
  9. state = luaL_newstate();
  10. luaL_openlibs(state);
  11. luaL_loadfile(state, "lua/lua/game.lua.script");
  12. lua_getglobal(state, "init");
  13. lua_pcall(state, 0, 0, 0);
  14. }
  15. void shutdown()
  16. {
  17. lua_getglobal(state, "shutdown");
  18. lua_pcall(state, 0, 0, 0);
  19. lua_close(state);
  20. }
  21. void frame(float dt)
  22. {
  23. lua_getglobal(state, "frame");
  24. lua_pushnumber(state, dt);
  25. lua_pcall(state, 1, 0, 0);
  26. }
  27. }