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
|
||||
|
||||
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
|
||||
|
|
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 {
|
||||
Game() : GameObject("game") {
|
||||
std::cout << "[+] Game" << '\n';
|
||||
std::cout << "Game: created\n";
|
||||
}
|
||||
|
||||
bool isGame() {
|
||||
|
|
|
@ -2,9 +2,7 @@
|
|||
#define _WORLD_H
|
||||
|
||||
struct World : public GameObject {
|
||||
Game() : GameObject("World") {}
|
||||
|
||||
void addRenderCandidate();
|
||||
World() : GameObject("World") {}
|
||||
};
|
||||
|
||||
void registerWorld(lua_State* L);
|
||||
|
|
|
@ -6,35 +6,28 @@
|
|||
#define DIGRAPHENE_GRAPHICS_MESH_IMPLEMENTATION
|
||||
#define DIGRAPHENE_GRAPHICS_SHADER_IMPLEMENTATION
|
||||
|
||||
#include <Components/World/Renderable.cpp>
|
||||
#include <vendor/digraphene-headers/graphics/buffer.h>
|
||||
#include <vendor/digraphene-headers/graphics/camera.h>
|
||||
#include <vendor/digraphene-headers/graphics/mesh.h>
|
||||
#include <vendor/digraphene-headers/graphics/shader.h>
|
||||
#include <Components/Data/Vector3.cpp>
|
||||
#include <Components/TopLevel/GameObject.cpp>
|
||||
|
||||
#include <cassert>
|
||||
#include <cmath>
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
|
||||
// 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, GameObject> ("Cube").endClass()
|
||||
.deriveClass <Cube, GameObject> ("Cube")
|
||||
.addProperty ("position", &Cube::position)
|
||||
.addProperty ("size", &Cube::size)
|
||||
.endClass()
|
||||
.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 <Components/TopLevel/GameObject.hpp>
|
||||
#include <Components/TopLevel/Game.hpp>
|
||||
#include <Components/TopLevel/World.hpp>
|
||||
|
||||
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;
|
||||
|
|
Reference in a new issue