aboutsummaryrefslogtreecommitdiff
path: root/src/game/game.cpp
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2022-04-24 17:13:52 +0200
committerHampusM <hampus@hampusmat.com>2022-06-13 17:56:58 +0200
commitdb6edcd473a684420e9a7611b24462df21165c1b (patch)
tree9646bdb4f5f6e339a0a01873b44e0b185476ce56 /src/game/game.cpp
parentb36d072ad7a7b9c6e30fcb25d6bbb001a8393468 (diff)
style: improve function and brace styling
Diffstat (limited to 'src/game/game.cpp')
-rw-r--r--src/game/game.cpp56
1 files changed, 38 insertions, 18 deletions
diff --git a/src/game/game.cpp b/src/game/game.cpp
index 88b9584..1a69e2e 100644
--- a/src/game/game.cpp
+++ b/src/game/game.cpp
@@ -9,11 +9,14 @@
#include <iostream>
#include <utility>
-Game::Game(std::shared_ptr<IWindow> window, std::shared_ptr<IScene> scene,
- std::shared_ptr<ICursorController> cursor_controller,
- std::shared_ptr<IStatusLine> statusline,
- std::shared_ptr<IGenerationTracker> generation_tracker,
- std::shared_ptr<IStatusUpdater> status_updater) noexcept
+Game::Game(
+ std::shared_ptr<IWindow> window,
+ std::shared_ptr<IScene> scene,
+ std::shared_ptr<ICursorController> cursor_controller,
+ std::shared_ptr<IStatusLine> statusline,
+ std::shared_ptr<IGenerationTracker> generation_tracker,
+ std::shared_ptr<IStatusUpdater> status_updater
+) noexcept
: _window(std::move(window)),
_scene(std::move(scene)),
_cursor_controller(std::move(cursor_controller)),
@@ -32,8 +35,8 @@ void Game::on_start() noexcept
const auto window_size = _window->size();
const auto center_position =
- Vector2({.x = static_cast<Vector2::Value>(window_size.get_width()) / 2,
- .y = static_cast<Vector2::Value>(window_size.get_height()) / 2});
+ Vector2({ .x = static_cast<Vector2::Value>(window_size.get_width()) / 2,
+ .y = static_cast<Vector2::Value>(window_size.get_height()) / 2 });
_cursor_controller->move_to(center_position);
@@ -60,15 +63,32 @@ void Game::on_exit() const noexcept
auto Game::get_input_config() const noexcept
-> std::unordered_map<char, std::shared_ptr<ICommand>>
{
- return {{'q', std::make_shared<QuitCommand>()},
- {'i', std::make_shared<InsertCellCommand>(_cursor_controller, _scene)},
- {'p', std::make_shared<TogglePauseCommand>(_generation_tracker, _statusline)},
- {'k', std::make_shared<MoveCursorCommand>(Vector2::up(), _cursor_controller,
- _window)},
- {'j', std::make_shared<MoveCursorCommand>(Vector2::down(), _cursor_controller,
- _window)},
- {'h', std::make_shared<MoveCursorCommand>(Vector2::left(), _cursor_controller,
- _window)},
- {'l', std::make_shared<MoveCursorCommand>(Vector2::right(),
- _cursor_controller, _window)}};
+ return { { 'q', std::make_shared<QuitCommand>() },
+ { 'i', std::make_shared<InsertCellCommand>(_cursor_controller, _scene) },
+ { 'p',
+ std::make_shared<TogglePauseCommand>(_generation_tracker, _statusline) },
+ { 'k',
+ std::make_shared<MoveCursorCommand>(
+ Vector2::up(),
+ _cursor_controller,
+ _window
+ ) },
+ { 'j',
+ std::make_shared<MoveCursorCommand>(
+ Vector2::down(),
+ _cursor_controller,
+ _window
+ ) },
+ { 'h',
+ std::make_shared<MoveCursorCommand>(
+ Vector2::left(),
+ _cursor_controller,
+ _window
+ ) },
+ { 'l',
+ std::make_shared<MoveCursorCommand>(
+ Vector2::right(),
+ _cursor_controller,
+ _window
+ ) } };
}