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/vector2.cpp | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 src/engine/data/vector2.cpp (limited to 'src/engine/data/vector2.cpp') diff --git a/src/engine/data/vector2.cpp b/src/engine/data/vector2.cpp new file mode 100644 index 0000000..5d42913 --- /dev/null +++ b/src/engine/data/vector2.cpp @@ -0,0 +1,39 @@ +#include "vector2.hpp" + +Vector2::Vector2(const Vector2Options &options) : _x(options.x), _y(options.y) {} + +uint32_t Vector2::x() const noexcept +{ + return _x; +} + +void Vector2::x(uint32_t x) noexcept +{ + _x = x; +} + +uint32_t Vector2::y() const noexcept +{ + return _y; +} + +void Vector2::y(uint32_t y) noexcept +{ + _y = y; +} + +const Vector2 &Vector2::operator+=(const Vector2 &vector2) noexcept +{ + _x += vector2.x(); + _y += vector2.y(); + + return *this; +} + +const Vector2 &Vector2::operator-=(const Vector2 &vector2) noexcept +{ + _x -= vector2.x(); + _y -= vector2.y(); + + return *this; +} -- cgit v1.2.3-18-g5258