AAAAA
This commit is contained in:
parent
7206c53f8e
commit
f9e69ee314
8 changed files with 36 additions and 48 deletions
6
Makefile
6
Makefile
|
@ -6,9 +6,9 @@ OBJ_DIR := obj
|
||||||
BIN_DIR := bin
|
BIN_DIR := bin
|
||||||
|
|
||||||
EXE := $(BIN_DIR)/out
|
EXE := $(BIN_DIR)/out
|
||||||
OBJ_OUT_DIRS := obj/Main obj/Components obj/Components obj/Components/TopLevel
|
OBJ_OUT_DIRS := obj/Main
|
||||||
SRC := $(SRC_DIR)/Main/Main.cpp $(SRC_DIR)/Components/TopLevel/GameObject.cpp $(SRC_DIR)/Components/TopLevel/Game.cpp
|
SRC := $(SRC_DIR)/Main/Main.cpp
|
||||||
OBJ := $(OBJ_DIR)/Main/Main.o $(OBJ_DIR)/Components/TopLevel/GameObject.o $(OBJ_DIR)/Components/TopLevel/Game.o
|
OBJ := $(OBJ_DIR)/Main/Main.o
|
||||||
CC := g++ -std=c++17
|
CC := g++ -std=c++17
|
||||||
|
|
||||||
CPPFLAGS := -I/usr/include/$(LUA) -Iinclude -MMD -MP
|
CPPFLAGS := -I/usr/include/$(LUA) -Iinclude -MMD -MP
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
for i, v in pairs(program.game:GetChildren()) do
|
for i, v in pairs(program.game:GetChildren()) do
|
||||||
print(v.name)
|
print(v.name)
|
||||||
end
|
end
|
||||||
|
|
12
include/Components/Data/Vector3.hpp
Normal file
12
include/Components/Data/Vector3.hpp
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
struct Vector3 {
|
||||||
|
int x;
|
||||||
|
int y;
|
||||||
|
int z;
|
||||||
|
};
|
||||||
|
|
||||||
|
void registerVector3(lua_State* L) {
|
||||||
|
luabridge::getGlobalNamespace(L)
|
||||||
|
.beginNamespace("Core")
|
||||||
|
.beginClass <Vector3> ("Vector3").endClass()
|
||||||
|
.endNamespace();
|
||||||
|
}
|
|
@ -8,7 +8,7 @@
|
||||||
|
|
||||||
struct Game : public GameObject {
|
struct Game : public GameObject {
|
||||||
Game() : GameObject("game") {
|
Game() : GameObject("game") {
|
||||||
std::cout << "[+] Game" << '\n';
|
std::cout << "Game: created\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isGame() {
|
bool isGame() {
|
||||||
|
|
|
@ -2,9 +2,7 @@
|
||||||
#define _WORLD_H
|
#define _WORLD_H
|
||||||
|
|
||||||
struct World : public GameObject {
|
struct World : public GameObject {
|
||||||
Game() : GameObject("World") {}
|
World() : GameObject("World") {}
|
||||||
|
|
||||||
void addRenderCandidate();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void registerWorld(lua_State* L);
|
void registerWorld(lua_State* L);
|
||||||
|
|
|
@ -6,35 +6,28 @@
|
||||||
#define DIGRAPHENE_GRAPHICS_MESH_IMPLEMENTATION
|
#define DIGRAPHENE_GRAPHICS_MESH_IMPLEMENTATION
|
||||||
#define DIGRAPHENE_GRAPHICS_SHADER_IMPLEMENTATION
|
#define DIGRAPHENE_GRAPHICS_SHADER_IMPLEMENTATION
|
||||||
|
|
||||||
#include <Components/World/Renderable.cpp>
|
#include <Components/Data/Vector3.cpp>
|
||||||
#include <vendor/digraphene-headers/graphics/buffer.h>
|
#include <Components/TopLevel/GameObject.cpp>
|
||||||
#include <vendor/digraphene-headers/graphics/camera.h>
|
|
||||||
#include <vendor/digraphene-headers/graphics/mesh.h>
|
|
||||||
#include <vendor/digraphene-headers/graphics/shader.h>
|
|
||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
// Using this allows us to pass a vector or matrix
|
struct Cube : public GameObject {
|
||||||
// from linalg to something like std::cout
|
|
||||||
using namespace linalg::ostream_overloads;
|
|
||||||
|
|
||||||
using namespace Digraphene;
|
|
||||||
|
|
||||||
struct Cube : public Renderable {
|
|
||||||
Game() : GameObject("Cube") {}
|
Game() : GameObject("Cube") {}
|
||||||
|
|
||||||
void render() {
|
Vector3 position;
|
||||||
|
Vector3 size;
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void registerCube(lua_State* L) {
|
void registerCube(lua_State* L) {
|
||||||
luabridge::getGlobalNamespace(L)
|
luabridge::getGlobalNamespace(L)
|
||||||
.beginNamespace("Core")
|
.beginNamespace("Core")
|
||||||
.deriveClass <Cube, GameObject> ("Cube").endClass()
|
.deriveClass <Cube, GameObject> ("Cube")
|
||||||
|
.addProperty ("position", &Cube::position)
|
||||||
|
.addProperty ("size", &Cube::size)
|
||||||
|
.endClass()
|
||||||
.endNamespace();
|
.endNamespace();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,19 +0,0 @@
|
||||||
#ifndef _RENDERABLE_H
|
|
||||||
#define _RENDERABLE_H
|
|
||||||
|
|
||||||
#include <Components/World/GameObject.cpp>
|
|
||||||
|
|
||||||
struct Renderable : public GameObject {
|
|
||||||
Game() : GameObject("Renderable") {}
|
|
||||||
|
|
||||||
virtual void render();
|
|
||||||
};
|
|
||||||
|
|
||||||
void registerRenderable(lua_State* L) {
|
|
||||||
luabridge::getGlobalNamespace(L)
|
|
||||||
.beginNamespace("Core")
|
|
||||||
.deriveClass <Renderable, GameObject> ("Renderable").endClass()
|
|
||||||
.endNamespace();
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -9,6 +9,7 @@ extern "C" {
|
||||||
#include <vendor/LuaBridge3/Source/LuaBridge/LuaBridge.h> // Pain
|
#include <vendor/LuaBridge3/Source/LuaBridge/LuaBridge.h> // Pain
|
||||||
#include <Components/TopLevel/GameObject.hpp>
|
#include <Components/TopLevel/GameObject.hpp>
|
||||||
#include <Components/TopLevel/Game.hpp>
|
#include <Components/TopLevel/Game.hpp>
|
||||||
|
#include <Components/TopLevel/World.hpp>
|
||||||
|
|
||||||
static Game game;
|
static Game game;
|
||||||
|
|
||||||
|
@ -22,21 +23,24 @@ void registerInit(lua_State* L) {
|
||||||
.endNamespace ();
|
.endNamespace ();
|
||||||
}
|
}
|
||||||
|
|
||||||
int main() {
|
void defaultGame() {
|
||||||
GameObject gaming("gamer");
|
World world;
|
||||||
game.Add(&gaming);
|
game.Add(&world);
|
||||||
|
}
|
||||||
|
|
||||||
|
int main() {
|
||||||
lua_State* L = luaL_newstate();
|
lua_State* L = luaL_newstate();
|
||||||
luaL_openlibs(L); // TODO: dangerous
|
luaL_openlibs(L); // TODO: dangerous
|
||||||
|
|
||||||
registerInit(L);
|
registerInit(L);
|
||||||
|
defaultGame();
|
||||||
|
|
||||||
int ret = luaL_dofile(L, "Script.lua");
|
int ret = luaL_dofile(L, "Script.lua");
|
||||||
|
|
||||||
if (ret != 0) {
|
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';
|
std::cout << " -> " << lua_tostring(L, -1) << '\n';
|
||||||
return 2;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Reference in a new issue