aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYann Herklotz <ymherklotz@gmail.com>2018-06-12 06:45:47 +0100
committerYann Herklotz <ymherklotz@gmail.com>2018-06-12 06:45:47 +0100
commitc3a7658120c9bb396bde01bed2bcec938fef1f10 (patch)
treed7fd576b654a66cd6b215b549953e390d2b0a966
parentc6217d8b43b6ddf360485f9ba3b731a783482eaa (diff)
downloadYAGE-c3a7658120c9bb396bde01bed2bcec938fef1f10.tar.gz
YAGE-c3a7658120c9bb396bde01bed2bcec938fef1f10.zip
Making functions return themselves
This is so that the functions can be chained together
-rw-r--r--yage/entity/engine.cpp10
-rw-r--r--yage/entity/engine.h6
2 files changed, 10 insertions, 6 deletions
diff --git a/yage/entity/engine.cpp b/yage/entity/engine.cpp
index 1cef4504..73774093 100644
--- a/yage/entity/engine.cpp
+++ b/yage/entity/engine.cpp
@@ -21,13 +21,14 @@ Engine::~Engine()
quit();
}
-void Engine::init()
+Engine &Engine::init()
{
yage::init();
window_.create("Game Engine", 800, 640);
+ return *this;
}
-void Engine::mainLoop()
+Engine &Engine::mainLoop()
{
while (!window_.shouldClose()) {
window_.pollEvents();
@@ -37,6 +38,8 @@ void Engine::mainLoop()
window_.swapBuffer();
}
+
+ return *this;
}
void Engine::update()
@@ -46,9 +49,10 @@ void Engine::update()
}
}
-void Engine::addSpace(std::unique_ptr<Space> space)
+Engine &Engine::addSpace(std::unique_ptr<Space> space)
{
spaces_.push_back(std::move(space));
+ return *this;
}
Engine &Engine::instance()
diff --git a/yage/entity/engine.h b/yage/entity/engine.h
index 9a1f6d2b..6719eeaf 100644
--- a/yage/entity/engine.h
+++ b/yage/entity/engine.h
@@ -32,16 +32,16 @@ public:
~Engine();
/// Initialize window and other aspects of the engine.
- void init();
+ Engine &init();
/// Main game loop of the engine.
- void mainLoop();
+ Engine &mainLoop();
/// Updates the systems.
void update();
/// Add spaces to the engine
- void addSpace(std::unique_ptr<Space> space);
+ Engine &addSpace(std::unique_ptr<Space> space);
/// Returns the instance of the engine, as there is only one instance of the
/// engine.