diff options
author | HampusM <hampus@hampusmat.com> | 2022-06-08 18:48:39 +0200 |
---|---|---|
committer | HampusM <hampus@hampusmat.com> | 2022-06-13 17:57:01 +0200 |
commit | 0f9f82c875fef4c8057a994552aa7d7a702b411a (patch) | |
tree | 40dcbbfb0ba618e684a153b1f00e12eac6a7f18e /src | |
parent | 6d66d5675d0fb78827bc47c49f9d4a1852c7255d (diff) |
fix: prevent birth cells from trespassing statusline
Diffstat (limited to 'src')
-rw-r--r-- | src/game/game.cpp | 14 | ||||
-rw-r--r-- | src/game/game.hpp | 2 |
2 files changed, 12 insertions, 4 deletions
diff --git a/src/game/game.cpp b/src/game/game.cpp index 0b3e85e..879f096 100644 --- a/src/game/game.cpp +++ b/src/game/game.cpp @@ -29,7 +29,8 @@ Game::Game( _status_manager(std::move(status_manager)), _user_input_observer(std::move(user_input_observer)), _cell_helper(std::move(cell_helper)), - _current_mode(Mode::NORMAL) + _current_mode(Mode::NORMAL), + _minimum_cursor_pos_y(0) { } @@ -44,6 +45,8 @@ void Game::on_start() noexcept _status_manager->bind(statusline); + _minimum_cursor_pos_y = 2; + _status_manager->set_section_title(StatusLineSection::A, ""); _status_manager->set_section_title(StatusLineSection::B, "X: "); _status_manager->set_section_title(StatusLineSection::C, "Y: "); @@ -319,8 +322,11 @@ void Game::_on_normal_mode_update() noexcept for (const auto &birth_cell_pos : birth_cell_positions) { - _set_space(matrix, birth_cell_pos, 'x'); - _living_cell_positions.push_back(birth_cell_pos); + if (birth_cell_pos.get_y() >= _minimum_cursor_pos_y) + { + _set_space(matrix, birth_cell_pos, 'x'); + _living_cell_positions.push_back(birth_cell_pos); + } } } @@ -502,7 +508,7 @@ auto Game::_move_cursor(const Vector2 &direction) noexcept -> bool return false; } - if (dest_position.get_y() <= 1) + if (dest_position.get_y() < _minimum_cursor_pos_y) { return false; } diff --git a/src/game/game.hpp b/src/game/game.hpp index a35c0ce..4d83fe5 100644 --- a/src/game/game.hpp +++ b/src/game/game.hpp @@ -79,6 +79,8 @@ private: Mode _current_mode; + int32_t _minimum_cursor_pos_y; + std::optional<Vector2> _last_pos_before_command_mode; std::string _command_mode_input; |