aboutsummaryrefslogtreecommitdiff
path: root/src/game/game.cpp
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2022-06-08 18:48:39 +0200
committerHampusM <hampus@hampusmat.com>2022-06-13 17:57:01 +0200
commit0f9f82c875fef4c8057a994552aa7d7a702b411a (patch)
tree40dcbbfb0ba618e684a153b1f00e12eac6a7f18e /src/game/game.cpp
parent6d66d5675d0fb78827bc47c49f9d4a1852c7255d (diff)
fix: prevent birth cells from trespassing statusline
Diffstat (limited to 'src/game/game.cpp')
-rw-r--r--src/game/game.cpp14
1 files changed, 10 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;
}