aboutsummaryrefslogtreecommitdiffstats
path: root/yage/engine
diff options
context:
space:
mode:
Diffstat (limited to 'yage/engine')
-rw-r--r--yage/engine/component.h21
-rw-r--r--yage/engine/engine.cpp55
-rw-r--r--yage/engine/engine.h51
-rw-r--r--yage/engine/entity.cpp23
-rw-r--r--yage/engine/entity.h53
-rw-r--r--yage/engine/entitymanager.cpp34
-rw-r--r--yage/engine/entitymanager.h83
-rw-r--r--yage/engine/space.cpp21
-rw-r--r--yage/engine/space.h61
-rw-r--r--yage/engine/system.h57
10 files changed, 0 insertions, 459 deletions
diff --git a/yage/engine/component.h b/yage/engine/component.h
deleted file mode 100644
index 9fd85d82..00000000
--- a/yage/engine/component.h
+++ /dev/null
@@ -1,21 +0,0 @@
-/** ---------------------------------------------------------------------------
- * @file: component.h
- *
- * Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com>
- * MIT License, see LICENSE file for more details.
- * ----------------------------------------------------------------------------
- */
-
-#ifndef YAGE_ENGINE_COMPONENT_H
-#define YAGE_ENGINE_COMPONENT_H
-
-class Component
-{
-};
-
-enum class ComponentEnum {
- POSITION,
- NAX_COMPONENTS,
-};
-
-#endif
diff --git a/yage/engine/engine.cpp b/yage/engine/engine.cpp
deleted file mode 100644
index cf6f73b7..00000000
--- a/yage/engine/engine.cpp
+++ /dev/null
@@ -1,55 +0,0 @@
-/** ---------------------------------------------------------------------------
- * @file: engine.cpp
- *
- * Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com>
- * MIT License, see LICENSE file for more details.
- * ----------------------------------------------------------------------------
- */
-
-#include "engine.h"
-
-namespace yage
-{
-
-void Engine::init()
-{
- window_.create("Game Engine", 800, 640);
-
- for (auto &system : systems_) {
- system->init();
- }
-}
-
-void Engine::mainLoop()
-{
- while (!window_.shouldClose()) {
- window_.clearBuffer();
-
- update();
-
- window_.swapBuffer();
- }
-}
-
-void Engine::update()
-{
- const double dt = 1.0 / 60.0;
-
- for (auto &system : systems_) {
- system->update(dt);
- }
-}
-
-void Engine::addSystem(System *system)
-{
- systems_.push_back(system);
-}
-
-Engine &Engine::instance()
-{
- static Engine engine_instance;
-
- return engine_instance;
-}
-
-} // namespace yage
diff --git a/yage/engine/engine.h b/yage/engine/engine.h
deleted file mode 100644
index 147769e5..00000000
--- a/yage/engine/engine.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/** ---------------------------------------------------------------------------
- * @file: engine.h
- *
- * Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com>
- * MIT License, see LICENSE file for more details.
- * ----------------------------------------------------------------------------
- */
-
-#ifndef YAGE_CORE_ENGINE_H
-#define YAGE_CORE_ENGINE_H
-
-#include "../core/window.h"
-#include "system.h"
-
-#include <vector>
-
-namespace yage
-{
-
-/// Main engine class that contains a systems, the main loop and the update
-/// function that updates all the systems.
-class Engine
-{
-public:
- /// Initialize window and other aspects of the engine.
- void init();
-
- /// Main game loop of the engine.
- void mainLoop();
-
- /// Updates the systems.
- void update();
-
- /// Adds a system to the engine.
- void addSystem(System *system);
-
- /// Returns the instance of the engine, as there is only one instance of the
- /// engine.
- static Engine &instance();
-
-private:
- /// Vector of all the systems in the engine.
- std::vector<System *> systems_;
-
- /// Window
- Window window_;
-};
-
-} // namespace yage
-
-#endif
diff --git a/yage/engine/entity.cpp b/yage/engine/entity.cpp
deleted file mode 100644
index 4d9a4b0a..00000000
--- a/yage/engine/entity.cpp
+++ /dev/null
@@ -1,23 +0,0 @@
-/** ---------------------------------------------------------------------------
- * @file: entity.cpp
- *
- * Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com>
- * MIT License, see LICENSE file for more details.
- * ----------------------------------------------------------------------------
- */
-
-#include "entity.h"
-
-#include "space.h"
-
-namespace yage
-{
-
-Entity::Entity(unsigned handle) : handle_(handle) {}
-
-unsigned Entity::getHandle() const
-{
- return handle_;
-}
-
-} // naemspace yage
diff --git a/yage/engine/entity.h b/yage/engine/entity.h
deleted file mode 100644
index c31490e5..00000000
--- a/yage/engine/entity.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/** ---------------------------------------------------------------------------
- * @file: entity.h
- *
- * Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com>
- * MIT License, see LICENSE file for more details.
- * ----------------------------------------------------------------------------
- */
-
-#ifndef YAGE_ENGINE_ENTITY_H
-#define YAGE_ENGINE_ENTITY_H
-
-#include <vector>
-
-namespace yage
-{
-
-class Space;
-
-/**
- * Entity convenience class. It contains handles to where the entity is in the
- * entity manager of the space, and a pointer back to the space itself.
- *
- * This class cannot be instantiated outside of a Space and should only be
- * instantiated through an entity manager, as otherwise the handle will not have
- * a meaning.
- */
-class Entity
-{
-public:
- /**
- * Creates an instance of an Entity with a handle that is associated to it.
- * This handle refers to the position of he Entity in the list that is held
- * by the EntityManager, and therefore the id is enough to refer to it.
- */
- Entity(unsigned handle);
-
- /**
- * Handle getter, as the user will only interact with the id itself. The
- * handle is the unique identifier that the user can use to refer to the
- * entity.
- */
- unsigned getHandle() const;
-
-private:
- /**
- * Entity handle for the entity manager.
- */
- unsigned handle_;
-};
-
-} // namespace yage
-
-#endif
diff --git a/yage/engine/entitymanager.cpp b/yage/engine/entitymanager.cpp
deleted file mode 100644
index 332ed9b8..00000000
--- a/yage/engine/entitymanager.cpp
+++ /dev/null
@@ -1,34 +0,0 @@
-/** ---------------------------------------------------------------------------
- * @file: entitymanager.cpp
- *
- * Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com>
- * MIT License, see LICENSE file for more details.
- * ----------------------------------------------------------------------------
- */
-
-#include "entitymanager.h"
-
-namespace yage
-{
-
-EntityManager::EntityManager(Space *space) : next_handle_(0), space_(space) {}
-
-EntityManager::EntityManager(Space *space, std::size_t n)
- : next_handle_(0), space_(space)
-{
- entities_.reserve(n);
-}
-
-unsigned EntityManager::createEntity()
-{
- return createEntityInstance().getHandle();
-}
-
-Entity EntityManager::createEntityInstance()
-{
- Entity entity(next_handle_++);
- entities_.push_back(entity);
- return entity;
-}
-
-} // namespace yage
diff --git a/yage/engine/entitymanager.h b/yage/engine/entitymanager.h
deleted file mode 100644
index da125d94..00000000
--- a/yage/engine/entitymanager.h
+++ /dev/null
@@ -1,83 +0,0 @@
-/** ---------------------------------------------------------------------------
- * @file: entitymanager.h
- *
- * Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com>
- * MIT License, see LICENSE file for more details.
- * ----------------------------------------------------------------------------
- */
-
-#ifndef YAGE_ENGINE_ENTITYMANAGER_H
-#define YAGE_ENGINE_ENTITYMANAGER_H
-
-#include "entity.h"
-
-#include <vector>
-
-namespace yage
-{
-
-class Space;
-
-/**
- * Manages entities in a space.
- */
-class EntityManager
-{
-public:
- /**
- * Default instance of an EntityManager.
- */
- EntityManager() = default;
-
- /**
- * Creates an instance of the entity manager, which refers back to the space
- * it was created in and belongs to.
- *
- * @param space Current space that the EntityManager belongs to.
- */
- EntityManager(Space *space);
-
- /**
- * Creates an instance of the entitiy manager with an initial size.
- *
- * @param space Current space that the EntityManager belongs to.
- * @param n Initial size of the EntityManager.
- */
- EntityManager(Space *space, std::size_t n);
-
- /**
- * Creates an Entity and returns the handle to the entity, which can then be
- * used by the user to do operations on it.
- *
- * @return The handle to the entity that was created in the space.
- */
- unsigned createEntity();
-
- /**
- * Creates an Entity and returns it.
- *
- * @return The entity that was created by the entity manager in the current
- * space.
- */
- Entity createEntityInstance();
-
-private:
- /**
- * The next available handle to give to the user.
- */
- unsigned next_handle_;
-
- /**
- * The space that the entity manager belongs to.
- */
- Space *space_;
-
- /**
- * The entities in the current space.
- */
- std::vector<Entity> entities_;
-};
-
-} // namespace yage
-
-#endif
diff --git a/yage/engine/space.cpp b/yage/engine/space.cpp
deleted file mode 100644
index f3e343b5..00000000
--- a/yage/engine/space.cpp
+++ /dev/null
@@ -1,21 +0,0 @@
-/** ---------------------------------------------------------------------------
- * @file: space.cpp
- *
- * Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com>
- * MIT License, see LICENSE file for more details.
- * ----------------------------------------------------------------------------
- */
-
-#include "space.h"
-
-namespace yage
-{
-
-Space::Space() : em_(this) {}
-
-unsigned Space::createEntity()
-{
- return em_.createEntity();
-}
-
-} // namespace yage
diff --git a/yage/engine/space.h b/yage/engine/space.h
deleted file mode 100644
index e69df37a..00000000
--- a/yage/engine/space.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/** ---------------------------------------------------------------------------
- * @file: space.h
- *
- * Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com>
- * MIT License, see LICENSE file for more details.
- * ----------------------------------------------------------------------------
- */
-
-#ifndef YAGE_ENGINE_SPACE_H
-#define YAGE_ENGINE_SPACE_H
-
-#include <vector>
-
-#include "entitymanager.h"
-
-namespace yage
-{
-
-class System;
-
-/**
- * Space that keeps track of all the entities, componenets and runs the systems
- * on the data to update them. There can be multiple instances of a space, which
- * can be used, for example, for different levels in the game that can be loaded
- * separately, or a game menu that can be loaded above the other spaces when the
- * user presses on pause.
- */
-class Space
-{
-public:
- /**
- * Default instance for a space.
- */
- Space();
-
- /**
- * Create an entity that will belong to this space, and return the handle to
- * the user. The Entity class itself should not be visible to the user, as
- * the user only needs to worry about the handle when referring to the
- * Entity and changing it.
- */
- unsigned createEntity();
-
-private:
- /**
- * The subspaces of the Space that act on the data and on their respective
- * component. These are specific to the Space, as other spaces might have
- * different Systems and not act on the same entities.
- */
- std::vector<System *> systems_;
-
- /**
- * Manages all the entities in the system, can create them for the current
- * space.
- */
- EntityManager em_;
-};
-
-} // namespace yage
-
-#endif
diff --git a/yage/engine/system.h b/yage/engine/system.h
deleted file mode 100644
index 9100fa17..00000000
--- a/yage/engine/system.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/** ---------------------------------------------------------------------------
- * @file: system.h
- *
- * Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com>
- * MIT License, see LICENSE file for more details.
- * ----------------------------------------------------------------------------
- */
-
-#ifndef YAGE_ENGINE_SYSTEM_H
-#define YAGE_ENGINE_SYSTEM_H
-
-namespace yage
-{
-
-/**
- * System interface for the different systems in the engine.
- */
-class System
-{
-public:
- /**
- * Virtual destructor to destroy all the objects that implement this
- * properly.
- */
- virtual ~System() = 0;
-
- /**
- * Initializes the system. Good practice to have this function instead
- * using the constructor.
- */
- virtual void init() = 0;
-
- /**
- * Updates the system at each interval using the time step.
- *
- * @param dt The time difference between the previous frame and the current one.
- */
- virtual void update(double dt) = 0;
-
- /**
- * Destroy the system and the components that are contained in it.
- */
- virtual void destroy() = 0;
-};
-
-/**
- * Implement the default destructor, but leaving it as purely virtual in the
- * definition of the abstract class. This is so that the classes that implement
- * the abstract class have to implement a desctructor, but at the same time,
- * that there is no undefined behavious when the stack unwinds to the system and
- * calls the system destructor.
- */
-inline System::~System() {}
-
-} // namespace yage
-
-#endif