From b0c265ee3d94921f55266a679d3801a4d2b4505b Mon Sep 17 00:00:00 2001 From: HampusM Date: Sun, 13 Feb 2022 19:55:53 +0100 Subject: refactor: move some components to a engine dir --- src/engine/vector2.hpp | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 src/engine/vector2.hpp (limited to 'src/engine/vector2.hpp') diff --git a/src/engine/vector2.hpp b/src/engine/vector2.hpp new file mode 100644 index 0000000..3dc1db1 --- /dev/null +++ b/src/engine/vector2.hpp @@ -0,0 +1,59 @@ +#pragma once + +#include + +/** + * A 2D Vector. + */ +class Vector2 +{ +public: + /** + * Creates a 2D vector. + * + * @param x A X coordinate + * @param y A Y coordinate + */ + Vector2(unsigned int x, unsigned int y); + + /** + * Returns the X coordinate. + */ + unsigned int x() const; + + /** + * Sets the X coordinate. + * + * @param x A new X coordinate + */ + void x(unsigned int x); + + /** + * Returns the Y coordinate. + */ + unsigned int y() const; + + /** + * Sets the Y coordinate. + * + * @param Y A new Y coordinate + */ + void y(unsigned int y); + + /** + * Creates a copy of the 2D vector. + * + * @returns A identical 2D vector. + */ + std::shared_ptr copy(); + + Vector2 operator+(const Vector2 vector2); + Vector2 operator-(const Vector2 vector2); + + Vector2 &operator+=(const Vector2 &vector2); + Vector2 &operator-=(const Vector2 &vector2); + +private: + unsigned int _x; + unsigned int _y; +}; -- cgit v1.2.3-18-g5258