From c3a7658120c9bb396bde01bed2bcec938fef1f10 Mon Sep 17 00:00:00 2001 From: Yann Herklotz Date: Tue, 12 Jun 2018 06:45:47 +0100 Subject: Making functions return themselves This is so that the functions can be chained together --- yage/entity/engine.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'yage/entity/engine.cpp') 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) +Engine &Engine::addSpace(std::unique_ptr space) { spaces_.push_back(std::move(space)); + return *this; } Engine &Engine::instance() -- cgit