diff options
author | HampusM <hampus@hampusmat.com> | 2022-03-06 13:16:05 +0100 |
---|---|---|
committer | HampusM <hampus@hampusmat.com> | 2022-06-13 17:56:54 +0200 |
commit | 0e40bc7ce8c3b3be083002f88c3317d65f6570ad (patch) | |
tree | 2fcc470a0f1ce1d51ff26c53c8a9a890b3f31b3b /src/engine/data/vector2.hpp | |
parent | f4d812a5b9131e65bb55db7211dc68fc453792df (diff) |
refactor: make vector2 & bounds data classes
Diffstat (limited to 'src/engine/data/vector2.hpp')
-rw-r--r-- | src/engine/data/vector2.hpp | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/src/engine/data/vector2.hpp b/src/engine/data/vector2.hpp new file mode 100644 index 0000000..580123c --- /dev/null +++ b/src/engine/data/vector2.hpp @@ -0,0 +1,52 @@ +#pragma once + +#include <cstdint> + +struct Vector2Options +{ + uint32_t x; + uint32_t y; +}; + +/** + * A 2D Vector. + */ +class Vector2 +{ +public: + /** + * Creates a 2D vector. + */ + explicit Vector2(const Vector2Options &options); + + /** + * Returns the X coordinate. + */ + [[nodiscard]] uint32_t x() const noexcept; + + /** + * Sets the X coordinate. + * + * @param x A new X coordinate + */ + void x(uint32_t x) noexcept; + + /** + * Returns the Y coordinate. + */ + [[nodiscard]] uint32_t y() const noexcept; + + /** + * Sets the Y coordinate. + * + * @param Y A new Y coordinate + */ + void y(uint32_t y) noexcept; + + const Vector2 &operator+=(const Vector2 &vector2) noexcept; + const Vector2 &operator-=(const Vector2 &vector2) noexcept; + +private: + uint32_t _x; + uint32_t _y; +}; |