it a try in MrPigeon.legacy
@@ -13,6 +13,7 @@ | |||||
#endif | #endif | ||||
#include "core.h" | #include "core.h" | ||||
#include "lolgl.h" | #include "lolgl.h" | ||||
#if defined __CELLOS_LV2__ | #if defined __CELLOS_LV2__ | ||||
@@ -68,6 +69,8 @@ class ApplicationData | |||||
Application::Application(char const *name, ivec2 resolution, float framerate) | Application::Application(char const *name, ivec2 resolution, float framerate) | ||||
{ | { | ||||
data = new ApplicationData(name, resolution, framerate); | data = new ApplicationData(name, resolution, framerate); | ||||
g_world.ExecLua("lua/init.lua"); | |||||
} | } | ||||
bool Application::MustTick() | bool Application::MustTick() | ||||
@@ -18,6 +18,8 @@ | |||||
#include "core.h" | #include "core.h" | ||||
#include "lua/lua.hpp" | |||||
namespace lol | namespace lol | ||||
{ | { | ||||
@@ -29,51 +31,42 @@ class WorldData | |||||
{ | { | ||||
friend class World; | friend class World; | ||||
private: | |||||
int width, height; | |||||
lua_State *m_lua_state; | |||||
}; | }; | ||||
static WorldData g_world_data; | |||||
World g_world; | |||||
/* | /* | ||||
* Public World class | * Public World class | ||||
*/ | */ | ||||
World::World() | World::World() | ||||
: data(new WorldData()) | |||||
{ | { | ||||
data->width = 0; | |||||
data->height = 0; | |||||
m_drawgroup = DRAWGROUP_BEFORE; | |||||
g_world_data.m_lua_state = luaL_newstate(); | |||||
luaL_openlibs(g_world_data.m_lua_state); | |||||
} | } | ||||
World::~World() | World::~World() | ||||
{ | { | ||||
delete data; | |||||
lua_close(g_world_data.m_lua_state); | |||||
} | } | ||||
char const *World::GetName() | |||||
bool World::ExecLua(String const &lua) | |||||
{ | { | ||||
return "<world>"; | |||||
} | |||||
Array<String> pathlist = System::GetPathList(lua); | |||||
for (int i = 0; i < pathlist.Count(); ++i) | |||||
{ | |||||
luaL_dofile(g_world_data.m_lua_state, pathlist[i].C()); | |||||
} | |||||
void World::TickGame(float seconds) | |||||
{ | |||||
Entity::TickGame(seconds); | |||||
} | |||||
void World::TickDraw(float seconds) | |||||
{ | |||||
Entity::TickDraw(seconds); | |||||
} | |||||
int World::GetWidth() | |||||
{ | |||||
return data->width * 32; | |||||
return true; | |||||
} | } | ||||
int World::GetHeight() | |||||
double World::GetLuaNumber(String const &var) | |||||
{ | { | ||||
return data->height * 32; | |||||
lua_getglobal(g_world_data.m_lua_state, var.C()); | |||||
return lua_tonumber(g_world_data.m_lua_state, -1); | |||||
} | } | ||||
} /* namespace lol */ | } /* namespace lol */ | ||||
@@ -16,34 +16,22 @@ | |||||
#if !defined __LOL_WORLD_H__ | #if !defined __LOL_WORLD_H__ | ||||
#define __LOL_WORLD_H__ | #define __LOL_WORLD_H__ | ||||
#include "entity.h" | |||||
namespace lol | namespace lol | ||||
{ | { | ||||
class WorldData; | |||||
class World : public Entity | |||||
class World | |||||
{ | { | ||||
public: | public: | ||||
World(); | |||||
virtual ~World(); | |||||
protected: | |||||
/* Inherited from Entity */ | |||||
virtual char const *GetName(); | |||||
virtual void TickGame(float seconds); | |||||
virtual void TickDraw(float seconds); | |||||
public: | |||||
/* New methods */ | |||||
int GetWidth(); | |||||
int GetHeight(); | |||||
bool ExecLua(String const &lua); | |||||
double GetLuaNumber(String const &var); | |||||
private: | |||||
WorldData *data; | |||||
//private: | |||||
World(); | |||||
~World(); | |||||
}; | }; | ||||
extern World g_world; | |||||
} /* namespace lol */ | } /* namespace lol */ | ||||
#endif // __LOL_WORLD_H__ | #endif // __LOL_WORLD_H__ | ||||