From f778317bae709f397345a2d5e04e23864c6391b3 Mon Sep 17 00:00:00 2001 From: HampusM Date: Tue, 7 Jun 2022 14:49:51 +0200 Subject: fix: index cursor x position from 0 --- src/engine/data/bounds.cpp | 4 ++-- src/engine/user/cursor.cpp | 2 +- src/game/game.cpp | 5 +++++ 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/engine/data/bounds.cpp b/src/engine/data/bounds.cpp index ca67008..0cbe9c3 100644 --- a/src/engine/data/bounds.cpp +++ b/src/engine/data/bounds.cpp @@ -32,7 +32,7 @@ auto Bounds::validate_coords(const Vector2 &coords) const noexcept -> CoordsVali return CoordsValidation::X_HIGH; } - if (static_cast(coords.get_x()) <= 0) + if (static_cast(coords.get_x()) < 0) { return CoordsValidation::X_LOW; } @@ -42,7 +42,7 @@ auto Bounds::validate_coords(const Vector2 &coords) const noexcept -> CoordsVali return CoordsValidation::Y_HIGH; } - if (static_cast(coords.get_y()) <= 0) + if (static_cast(coords.get_y()) < 0) { return CoordsValidation::Y_LOW; } diff --git a/src/engine/user/cursor.cpp b/src/engine/user/cursor.cpp index 70828c3..d348d9e 100644 --- a/src/engine/user/cursor.cpp +++ b/src/engine/user/cursor.cpp @@ -31,7 +31,7 @@ void CursorController::move_to(const Vector2 &position) noexcept MOVE_CURSOR_TO, fmt::arg("esc", ESC), fmt::arg("row", inverted_pos.get_y()), - fmt::arg("column", inverted_pos.get_x())); + fmt::arg("column", inverted_pos.get_x() + 1)); std::cout.flush(); _position = position; diff --git a/src/game/game.cpp b/src/game/game.cpp index 2eef4cf..064b643 100644 --- a/src/game/game.cpp +++ b/src/game/game.cpp @@ -285,6 +285,11 @@ auto Game::_move_cursor(const Vector2 &direction) noexcept -> bool return false; } + if (dest_position.get_y() < 1) + { + return false; + } + _cursor_controller->move_to(dest_position); return true; -- cgit v1.2.3-18-g5258