diff --git a/include/Components/TopLevel/Game.hpp b/include/Components/TopLevel/Game.hpp index 5d64caf..eacfc08 100644 --- a/include/Components/TopLevel/Game.hpp +++ b/include/Components/TopLevel/Game.hpp @@ -1,14 +1,28 @@ #ifndef _GAME_H #define _GAME_H +#include +#include + +#include // Pain + struct Game : public GameObject { Game() : GameObject("game") { std::cout << "[+] Game" << '\n'; } - bool isGame(); + bool isGame() { + return true; + } }; -void registerGame(lua_State* L); +void registerGame(lua_State* L) { + luabridge::getGlobalNamespace (L) + .beginNamespace ("Core") + .deriveClass ("Game") + .addFunction ("isGame", &Game::isGame) + .endClass () + .endNamespace (); +} #endif \ No newline at end of file diff --git a/include/Components/TopLevel/GameObject.hpp b/include/Components/TopLevel/GameObject.hpp index 4b332b6..510c14d 100644 --- a/include/Components/TopLevel/GameObject.hpp +++ b/include/Components/TopLevel/GameObject.hpp @@ -10,6 +10,10 @@ extern "C" { #include } +#include +#include // Pain +#include // Pain + struct GameObject { GameObject(std::string name) : name(name) {} @@ -20,11 +24,35 @@ struct GameObject { std::vector children; std::map> handlers; - GameObject& Get(std::string name); - void Add(GameObject* obj); - std::vector& GetChildren(); + std::vector& GetChildren() { + return this->children; + } + + GameObject& Get(std::string name) { + // NOTE(hippoz): This is a mess. + // I should be using find_if, not a loop + for (int i = this->children.size()-1; i >= 0; i--) { + if (this->children[i]->name == name) { + return *this->children[i]; + } + } + } + + void Add(GameObject* gameObject) { + this->children.push_back(gameObject); + } }; -void registerGameObject(lua_State* L); +void registerGameObject(lua_State* L) { + luabridge::getGlobalNamespace (L) + .beginNamespace ("Core") + .beginClass ("GameObject") + .addProperty ("name", &GameObject::name) + .addFunction ("GetChildren", &GameObject::GetChildren) + .addFunction ("Add", &GameObject::Add) + .addFunction ("Get", &GameObject::Get) + .endClass () + .endNamespace (); +} #endif \ No newline at end of file diff --git a/include/Components/TopLevel/World.hpp b/include/Components/TopLevel/World.hpp new file mode 100644 index 0000000..49b28f3 --- /dev/null +++ b/include/Components/TopLevel/World.hpp @@ -0,0 +1,12 @@ +#ifndef _WORLD_H +#define _WORLD_H + +struct World : public GameObject { + Game() : GameObject("World") {} + + void addRenderCandidate(); +}; + +void registerWorld(lua_State* L); + +#endif \ No newline at end of file diff --git a/include/Components/World/Cube.hpp b/include/Components/World/Cube.hpp new file mode 100644 index 0000000..58cd2da --- /dev/null +++ b/include/Components/World/Cube.hpp @@ -0,0 +1,41 @@ +#ifndef _CUBE_H +#define _CUBE_H + +#define DIGRAPHENE_GRAPHICS_BUFFER_IMPLEMENTATION +#define DIGRAPHENE_GRAPHICS_CAMERA_IMPLEMENTATION +#define DIGRAPHENE_GRAPHICS_MESH_IMPLEMENTATION +#define DIGRAPHENE_GRAPHICS_SHADER_IMPLEMENTATION + +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +// Using this allows us to pass a vector or matrix +// from linalg to something like std::cout +using namespace linalg::ostream_overloads; + +using namespace Digraphene; + +struct Cube : public Renderable { + Game() : GameObject("Cube") {} + + void render() { + + } +}; + +void registerCube(lua_State* L) { + luabridge::getGlobalNamespace(L) + .beginNamespace("Core") + .deriveClass ("Cube").endClass() + .endNamespace(); +} + +#endif \ No newline at end of file diff --git a/include/Components/World/Renderable.hpp b/include/Components/World/Renderable.hpp new file mode 100644 index 0000000..be57e03 --- /dev/null +++ b/include/Components/World/Renderable.hpp @@ -0,0 +1,19 @@ +#ifndef _RENDERABLE_H +#define _RENDERABLE_H + +#include + +struct Renderable : public GameObject { + Game() : GameObject("Renderable") {} + + virtual void render(); +}; + +void registerRenderable(lua_State* L) { + luabridge::getGlobalNamespace(L) + .beginNamespace("Core") + .deriveClass ("Renderable").endClass() + .endNamespace(); +} + +#endif \ No newline at end of file diff --git a/include/vendor/digraphene-headers b/include/vendor/digraphene-headers new file mode 160000 index 0000000..cce6b8d --- /dev/null +++ b/include/vendor/digraphene-headers @@ -0,0 +1 @@ +Subproject commit cce6b8dc39bf63d13cb01f0bb5ad4d82164da016 diff --git a/src/Components/TopLevel/Game.cpp b/src/Components/TopLevel/Game.cpp deleted file mode 100644 index e00ee27..0000000 --- a/src/Components/TopLevel/Game.cpp +++ /dev/null @@ -1,17 +0,0 @@ -#include -#include - -#include // Pain - -bool Game::isGame() { - return true; -} - -void registerGame(lua_State* L) { - luabridge::getGlobalNamespace (L) - .beginNamespace ("Core") - .deriveClass ("Game") - .addFunction ("isGame", &Game::isGame) - .endClass () - .endNamespace (); -} \ No newline at end of file diff --git a/src/Components/TopLevel/GameObject.cpp b/src/Components/TopLevel/GameObject.cpp deleted file mode 100644 index 854875a..0000000 --- a/src/Components/TopLevel/GameObject.cpp +++ /dev/null @@ -1,34 +0,0 @@ -#include -#include // Pain -#include // Pain - -std::vector& GameObject::GetChildren() { - return this->children; -} - -GameObject& GameObject::Get(std::string name) { - // NOTE(hippoz): This is a mess. - // I should be using find_if, not a loop - for (int i = this->children.size()-1; i >= 0; i--) { - if (this->children[i]->name == name) { - return *this->children[i]; - } - } -} - -void GameObject::Add(GameObject* gameObject) { - this->children.push_back(gameObject); -} - - -void registerGameObject(lua_State* L) { - luabridge::getGlobalNamespace (L) - .beginNamespace ("Core") - .beginClass ("GameObject") - .addProperty ("name", &GameObject::name) - .addFunction ("GetChildren", &GameObject::GetChildren) - .addFunction ("Add", &GameObject::Add) - .addFunction ("Get", &GameObject::Get) - .endClass () - .endNamespace (); -} \ No newline at end of file