}
}
+-- Create the world
+dofile("Scripts/world.lua")
+
birdSpawn = game.spawn(bird);
dogSpawn = game.spawn(cat);
end
});
-dofile("Scripts/world.lua")
-
-------------------
-- SERIALIZING --
-------------------
end
}
-world:Generate()
+--world:Generate()
+game.worldRegister(world)
systems.add<InputSystem>();
systems.add<PlayerSystem>(entities);
systems.add<RenderSystem>();
- systems.add<ScriptSystem>(entities);
+ systems.add<WorldSystem>();
+ systems.add<ScriptSystem>(entities, *(systems.system<WorldSystem>().get()));
systems.add<PhysicsSystem>();
systems.configure();
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
+#define GLEW_STATIC
#define SOL_ALL_SAFETIES_ON = 1
#include "engine.hpp"
/**
* @file position.hpp
- * Manages all Lua scripts.
+ * Manages all entity movements
*
* Copyright (C) 2019 Belle-Isle, Andrew <drumsetmonkey@gmail.com>
*
#ifndef SYSTEM_RENDER_HPP_
#define SYSTEM_RENDER_HPP_
-#include "shader.hpp"
-
#include <entityx/entityx.h>
+#include <GL/glew.h>
#include <SDL2/SDL.h>
+#include <SDL2/SDL_opengl.h>
#define GLM_FORCE_RADIANS
#include <glm/glm.hpp>
#include <glm/gtc/type_ptr.hpp>
#include <glm/gtc/noise.hpp>
+#include "shader.hpp"
+
class RenderSystem : public entityx::System<RenderSystem>
{
private:
void ScriptSystem::scriptExport(void)
{
- std::function<sol::table(sol::table)> func =
+ std::function<sol::table(sol::table)> entitySpawn =
[this](sol::table t){ return spawn(t);};
+ std::function<unsigned int(sol::object)> worldRegister =
+ [this](sol::object t){ return worldSystem.addWorld(t); };
+
lua.new_usertype<Position>("Position",
sol::constructors<Position(double x, double y), Position()>(),
"x", &Position::x,
"standing", &Physics::standing);
auto gamespace = lua["game"].get_or_create<sol::table>();
- gamespace.set_function("spawn", func);
+ gamespace.set_function("spawn", entitySpawn);
+ gamespace.set_function("worldRegister", worldRegister);
}
sol::table ScriptSystem::spawn(sol::object param)
#include <entityx/entityx.h>
#include <sol/sol.hpp>
+#include "world.hpp"
+
struct EntitySpawnEvent
{
sol::object ref;
sol::state lua;
entityx::EntityManager& manager;
+
+ WorldSystem &worldSystem;
public:
- ScriptSystem(entityx::EntityManager& _manager):
- manager(_manager) {}
+ ScriptSystem(entityx::EntityManager& _mg, WorldSystem& _ws):
+ manager(_mg), worldSystem(_ws) {}
~ScriptSystem(void) {}
#include <unordered_map>
#include <GL/glew.h>
+#include <SDL2/SDL_opengl.h>
class Shader
{
#define TEXTURE_HPP_
#include <soil/SOIL.h>
+
+#include <GL/glew.h>
#include <SDL2/SDL_opengl.h>
+
#include <string>
class Texture
--- /dev/null
+/**
+ * @file world.cpp
+ *
+ * Copyright (C) 2019 Belle-Isle, Andrew <drumsetmonkey@gmail.com>
+ * Author: Belle-Isle, Andrew <drumsetmonkey@gmail.com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "world.hpp"
+
+/*****************
+* WORLD CLASS *
+*****************/
+World::World(sol::object ref)
+{
+ if (ref.get_type() == sol::type::table) {
+
+ } else {
+ // TODO better logging
+ std::cerr << "World paramaters must be stored in a table" << std::endl;
+ }
+}
+
+
+/******************
+* WORLD SYSTEM *
+******************/
+
+unsigned int WorldSystem::addWorld(sol::object t)
+{
+ worlds.push_back(World(t));
+ return worlds.size()-1;
+}
+
+void WorldSystem::configure([[maybe_unused]]entityx::EntityManager& entities,
+ [[maybe_unused]]entityx::EventManager& events)
+{
+
+}
+
+void WorldSystem::update([[maybe_unused]]entityx::EntityManager& entities,
+ [[maybe_unused]]entityx::EventManager& events,
+ [[maybe_unused]]entityx::TimeDelta dt)
+{
+
+}
--- /dev/null
+/**
+ * @file world.hpp
+ * Manages the world systems
+ *
+ * Copyright (C) 2019 Belle-Isle, Andrew <drumsetmonkey@gmail.com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef SYSTEM_WORLD_HPP_
+#define SYSTEM_WORLD_HPP_
+
+#include <vector>
+
+#include <entityx/entityx.h>
+#include <sol/sol.hpp>
+
+#include "texture.hpp"
+
+struct WorldMaterial
+{
+ Texture texture;
+ Texture normal;
+};
+
+class World
+{
+private:
+ std::vector<unsigned int> registry;
+ std::vector<std::vector<unsigned int>> worldData;
+public:
+ World(sol::object ref);
+ ~World() {}
+};
+
+/**
+ * @class WorldSystem
+ * Handles the game's world system
+ */
+class WorldSystem : public entityx::System<WorldSystem>
+{
+private:
+ std::vector<World> worlds;
+ //World& currentWorld;
+public:
+ WorldSystem(void) {}
+
+ ~WorldSystem(void) {}
+
+ unsigned int addWorld(sol::object);
+
+ /**
+ * Prepares the system for running.
+ */
+ void configure(entityx::EntityManager& entities,
+ entityx::EventManager& events) final;
+
+ /**
+ * Updates the world ticks (entity spawns and world events)
+ */
+ void update(entityx::EntityManager& entites,
+ entityx::EventManager& events,
+ entityx::TimeDelta dt) final;
+};
+
+#endif // SYSTEM_WORLD_HPP_
+