From 0e40bc7ce8c3b3be083002f88c3317d65f6570ad Mon Sep 17 00:00:00 2001 From: HampusM Date: Sun, 6 Mar 2022 13:16:05 +0100 Subject: refactor: make vector2 & bounds data classes --- src/engine/data/bounds.hpp | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 src/engine/data/bounds.hpp (limited to 'src/engine/data/bounds.hpp') diff --git a/src/engine/data/bounds.hpp b/src/engine/data/bounds.hpp new file mode 100644 index 0000000..1875bf4 --- /dev/null +++ b/src/engine/data/bounds.hpp @@ -0,0 +1,42 @@ +#pragma once + +#include "engine/data/vector2.hpp" + +#include + +enum CoordsValidation +{ + VALID, + X_HIGH, + Y_HIGH +}; + +struct BoundsOptions +{ + uint32_t width; + uint32_t height; +}; + +class Bounds +{ +public: + explicit Bounds(const BoundsOptions &options); + + [[nodiscard]] uint32_t width() const noexcept; + + void width(uint32_t width) noexcept; + + [[nodiscard]] uint32_t height() const noexcept; + + void height(uint32_t height) noexcept; + + [[nodiscard]] CoordsValidation validate_coords(const Vector2 &coords) const noexcept; + + const Bounds &operator*=(const Bounds &bounds) noexcept; + const Bounds &operator+=(const Bounds &bounds) noexcept; + const Bounds &operator-=(const Bounds &bounds) noexcept; + +private: + uint32_t _width = 0U; + uint32_t _height = 0U; +}; -- cgit v1.2.3-18-g5258