From f9e69ee3144ba6f4d5eefcdf55239e3b2c6d874a Mon Sep 17 00:00:00 2001 From: hippoz Date: Sat, 24 Apr 2021 13:37:57 +0300 Subject: [PATCH] AAAAA --- Makefile | 6 +++--- Script.lua | 2 +- include/Components/Data/Vector3.hpp | 12 ++++++++++++ include/Components/TopLevel/Game.hpp | 2 +- include/Components/TopLevel/World.hpp | 4 +--- include/Components/World/Cube.hpp | 25 +++++++++---------------- include/Components/World/Renderable.hpp | 19 ------------------- src/Main/Main.cpp | 14 +++++++++----- 8 files changed, 36 insertions(+), 48 deletions(-) create mode 100644 include/Components/Data/Vector3.hpp delete mode 100644 include/Components/World/Renderable.hpp diff --git a/Makefile b/Makefile index ae8e79c..b6a9802 100644 --- a/Makefile +++ b/Makefile @@ -6,9 +6,9 @@ OBJ_DIR := obj BIN_DIR := bin EXE := $(BIN_DIR)/out -OBJ_OUT_DIRS := obj/Main obj/Components obj/Components obj/Components/TopLevel -SRC := $(SRC_DIR)/Main/Main.cpp $(SRC_DIR)/Components/TopLevel/GameObject.cpp $(SRC_DIR)/Components/TopLevel/Game.cpp -OBJ := $(OBJ_DIR)/Main/Main.o $(OBJ_DIR)/Components/TopLevel/GameObject.o $(OBJ_DIR)/Components/TopLevel/Game.o +OBJ_OUT_DIRS := obj/Main +SRC := $(SRC_DIR)/Main/Main.cpp +OBJ := $(OBJ_DIR)/Main/Main.o CC := g++ -std=c++17 CPPFLAGS := -I/usr/include/$(LUA) -Iinclude -MMD -MP diff --git a/Script.lua b/Script.lua index 646b4ab..76310b0 100644 --- a/Script.lua +++ b/Script.lua @@ -1,3 +1,3 @@ for i, v in pairs(program.game:GetChildren()) do print(v.name) -end \ No newline at end of file +end diff --git a/include/Components/Data/Vector3.hpp b/include/Components/Data/Vector3.hpp new file mode 100644 index 0000000..5470114 --- /dev/null +++ b/include/Components/Data/Vector3.hpp @@ -0,0 +1,12 @@ +struct Vector3 { + int x; + int y; + int z; +}; + +void registerVector3(lua_State* L) { + luabridge::getGlobalNamespace(L) + .beginNamespace("Core") + .beginClass ("Vector3").endClass() + .endNamespace(); +} \ No newline at end of file diff --git a/include/Components/TopLevel/Game.hpp b/include/Components/TopLevel/Game.hpp index eacfc08..236862a 100644 --- a/include/Components/TopLevel/Game.hpp +++ b/include/Components/TopLevel/Game.hpp @@ -8,7 +8,7 @@ struct Game : public GameObject { Game() : GameObject("game") { - std::cout << "[+] Game" << '\n'; + std::cout << "Game: created\n"; } bool isGame() { diff --git a/include/Components/TopLevel/World.hpp b/include/Components/TopLevel/World.hpp index 49b28f3..eab8b51 100644 --- a/include/Components/TopLevel/World.hpp +++ b/include/Components/TopLevel/World.hpp @@ -2,9 +2,7 @@ #define _WORLD_H struct World : public GameObject { - Game() : GameObject("World") {} - - void addRenderCandidate(); + World() : GameObject("World") {} }; void registerWorld(lua_State* L); diff --git a/include/Components/World/Cube.hpp b/include/Components/World/Cube.hpp index 58cd2da..e23000f 100644 --- a/include/Components/World/Cube.hpp +++ b/include/Components/World/Cube.hpp @@ -6,35 +6,28 @@ #define DIGRAPHENE_GRAPHICS_MESH_IMPLEMENTATION #define DIGRAPHENE_GRAPHICS_SHADER_IMPLEMENTATION -#include -#include -#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 { +struct Cube : public GameObject { Game() : GameObject("Cube") {} - void render() { - - } + Vector3 position; + Vector3 size; }; void registerCube(lua_State* L) { luabridge::getGlobalNamespace(L) .beginNamespace("Core") - .deriveClass ("Cube").endClass() + .deriveClass ("Cube") + .addProperty ("position", &Cube::position) + .addProperty ("size", &Cube::size) + .endClass() .endNamespace(); } diff --git a/include/Components/World/Renderable.hpp b/include/Components/World/Renderable.hpp deleted file mode 100644 index be57e03..0000000 --- a/include/Components/World/Renderable.hpp +++ /dev/null @@ -1,19 +0,0 @@ -#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/src/Main/Main.cpp b/src/Main/Main.cpp index 633f6af..675144b 100644 --- a/src/Main/Main.cpp +++ b/src/Main/Main.cpp @@ -9,6 +9,7 @@ extern "C" { #include // Pain #include #include +#include static Game game; @@ -22,21 +23,24 @@ void registerInit(lua_State* L) { .endNamespace (); } -int main() { - GameObject gaming("gamer"); - game.Add(&gaming); +void defaultGame() { + World world; + game.Add(&world); +} +int main() { lua_State* L = luaL_newstate(); luaL_openlibs(L); // TODO: dangerous registerInit(L); + defaultGame(); int ret = luaL_dofile(L, "Script.lua"); if (ret != 0) { - std::cout << "[E] Error running main script" << '\n'; + std::cout << "[E] Error running main script\n"; std::cout << " -> " << lua_tostring(L, -1) << '\n'; - return 2; + return -1; } return 0;