From 12fffa7df0685ef6d23ffe888a06695ae490df81 Mon Sep 17 00:00:00 2001 From: HampusM Date: Mon, 7 Mar 2022 19:08:08 +0100 Subject: refactor: make vector2 data int32_t --- src/engine/data/bounds.cpp | 4 ++-- src/engine/data/vector2.cpp | 8 ++++---- src/engine/data/vector2.hpp | 16 ++++++++-------- 3 files changed, 14 insertions(+), 14 deletions(-) (limited to 'src/engine/data') 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(coords.get_x()) >= _width) { return CoordsValidation::X_HIGH; } - if (coords.get_y() >= _height) + if (static_cast(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; }; -- cgit v1.2.3-18-g5258