diff options
-rw-r--r-- | src/engine/data/bounds.cpp | 4 | ||||
-rw-r--r-- | src/engine/data/vector2.cpp | 8 | ||||
-rw-r--r-- | src/engine/data/vector2.hpp | 16 | ||||
-rw-r--r-- | src/engine/graphics/string_matrix.cpp | 10 |
4 files changed, 22 insertions, 16 deletions
diff --git a/src/engine/data/bounds.cpp b/src/engine/data/bounds.cpp index fbd7ec4..acd98af 100644 --- a/src/engine/data/bounds.cpp +++ b/src/engine/data/bounds.cpp @@ -27,12 +27,12 @@ void Bounds::set_height(uint32_t height) noexcept CoordsValidation Bounds::validate_coords(const Vector2 &coords) const noexcept { - if (coords.get_x() >= _width) + if (static_cast<uint32_t>(coords.get_x()) >= _width) { return CoordsValidation::X_HIGH; } - if (coords.get_y() >= _height) + if (static_cast<uint32_t>(coords.get_y()) >= _height) { return CoordsValidation::Y_HIGH; } diff --git a/src/engine/data/vector2.cpp b/src/engine/data/vector2.cpp index 7a22d62..6dcd7d6 100644 --- a/src/engine/data/vector2.cpp +++ b/src/engine/data/vector2.cpp @@ -2,22 +2,22 @@ Vector2::Vector2(const Vector2Options &options) : _x(options.x), _y(options.y) {} -uint32_t Vector2::get_x() const noexcept +int32_t Vector2::get_x() const noexcept { return _x; } -void Vector2::set_x(uint32_t x) noexcept +void Vector2::set_x(int32_t x) noexcept { _x = x; } -uint32_t Vector2::get_y() const noexcept +int32_t Vector2::get_y() const noexcept { return _y; } -void Vector2::set_y(uint32_t y) noexcept +void Vector2::set_y(int32_t y) noexcept { _y = y; } diff --git a/src/engine/data/vector2.hpp b/src/engine/data/vector2.hpp index a7896ef..acfe11f 100644 --- a/src/engine/data/vector2.hpp +++ b/src/engine/data/vector2.hpp @@ -4,8 +4,8 @@ struct Vector2Options { - uint32_t x; - uint32_t y; + int32_t x; + int32_t y; }; /** @@ -16,18 +16,18 @@ class Vector2 public: explicit Vector2(const Vector2Options &options); - [[nodiscard]] uint32_t get_x() const noexcept; + [[nodiscard]] int32_t get_x() const noexcept; - void set_x(uint32_t x) noexcept; + void set_x(int32_t x) noexcept; - [[nodiscard]] uint32_t get_y() const noexcept; + [[nodiscard]] int32_t get_y() const noexcept; - void set_y(uint32_t y) noexcept; + void set_y(int32_t y) noexcept; const Vector2 &operator+=(const Vector2 &vector2) noexcept; const Vector2 &operator-=(const Vector2 &vector2) noexcept; private: - uint32_t _x; - uint32_t _y; + int32_t _x; + int32_t _y; }; diff --git a/src/engine/graphics/string_matrix.cpp b/src/engine/graphics/string_matrix.cpp index b1db334..26d48df 100644 --- a/src/engine/graphics/string_matrix.cpp +++ b/src/engine/graphics/string_matrix.cpp @@ -22,12 +22,18 @@ void StringMatrix::fill(std::string_view element) std::string_view StringMatrix::get(const Vector2 &pos) const { - return _matrix[pos.get_y()][pos.get_x()]; + auto x = static_cast<std::size_t>(pos.get_x()); + auto y = static_cast<std::size_t>(pos.get_y()); + + return _matrix[y][x]; } void StringMatrix::set(const Vector2 &pos, std::string_view element) { - _matrix[pos.get_y()][pos.get_x()] = element; + auto x = static_cast<std::size_t>(pos.get_x()); + auto y = static_cast<std::size_t>(pos.get_y()); + + _matrix[y][x] = element; } uint32_t StringMatrix::rows() const |