diff options
author | HampusM <hampus@hampusmat.com> | 2022-03-08 16:26:17 +0100 |
---|---|---|
committer | HampusM <hampus@hampusmat.com> | 2022-06-13 17:56:55 +0200 |
commit | 9dd5936333082305b0b9680db2eac9abd128129b (patch) | |
tree | c99bff09a066bde806a520058347b549ed287a9f /src/engine | |
parent | 3a24ec6e5b5236ad6b943548b9948603e053559d (diff) |
refactor: add game factory
Diffstat (limited to 'src/engine')
-rw-r--r-- | src/engine/game_initializer.cpp | 8 | ||||
-rw-r--r-- | src/engine/game_initializer.hpp | 10 |
2 files changed, 10 insertions, 8 deletions
diff --git a/src/engine/game_initializer.cpp b/src/engine/game_initializer.cpp index 52e109a..13d9ba0 100644 --- a/src/engine/game_initializer.cpp +++ b/src/engine/game_initializer.cpp @@ -7,10 +7,10 @@ GameInitializer::GameInitializer(std::shared_ptr<IScene> scene, std::shared_ptr<IInputHandler> input_handler, - std::shared_ptr<IGame> game) + IGameFactory game_factory) : _scene(std::move(scene)), _input_handler(std::move(input_handler)), - _game(std::move(game)) + _game_factory(game_factory) { } @@ -26,5 +26,7 @@ void GameInitializer::initialize() _input_handler->leave_raw_mode(); })); - _game->run(*_scene, *_input_handler); + auto game = _game_factory(); + + game->run(*_scene, *_input_handler); } diff --git a/src/engine/game_initializer.hpp b/src/engine/game_initializer.hpp index 12b42de..2f63e0f 100644 --- a/src/engine/game_initializer.hpp +++ b/src/engine/game_initializer.hpp @@ -8,19 +8,19 @@ #include <memory> -class GameInitializer - : public IGameInitializer, - public AutoWirable<IGameInitializer, GameInitializer, IScene, IInputHandler, IGame> +class GameInitializer : public IGameInitializer, + public AutoWirable<IGameInitializer, GameInitializer, IScene, + IInputHandler, IGameFactory> { public: GameInitializer(std::shared_ptr<IScene> scene, std::shared_ptr<IInputHandler> input_handler, - std::shared_ptr<IGame> game); + IGameFactory game_factory); void initialize() override; private: std::shared_ptr<IScene> _scene; std::shared_ptr<IInputHandler> _input_handler; - std::shared_ptr<IGame> _game; + IGameFactory _game_factory; }; |