aboutsummaryrefslogtreecommitdiffstats
path: root/yage/entity/engine.cpp
diff options
context:
space:
mode:
authorYann Herklotz <ymherklotz@gmail.com>2018-02-13 19:14:33 +0000
committerYann Herklotz <ymherklotz@gmail.com>2018-02-13 19:14:33 +0000
commit49af8b16ae3f9e6579656ed10f815e9c465557d0 (patch)
tree1dff4aea6a59c466ea6a6f15ad7f5e2ac69f5b37 /yage/entity/engine.cpp
parente9bd903761605c7619a235edddf07c3a0b963968 (diff)
downloadYAGE-49af8b16ae3f9e6579656ed10f815e9c465557d0.tar.gz
YAGE-49af8b16ae3f9e6579656ed10f815e9c465557d0.zip
[entity] Starting work on entity system.
Diffstat (limited to 'yage/entity/engine.cpp')
-rw-r--r--yage/entity/engine.cpp55
1 files changed, 55 insertions, 0 deletions
diff --git a/yage/entity/engine.cpp b/yage/entity/engine.cpp
new file mode 100644
index 00000000..cf6f73b7
--- /dev/null
+++ b/yage/entity/engine.cpp
@@ -0,0 +1,55 @@
+/** ---------------------------------------------------------------------------
+ * @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