diff options
author | HampusM <hampus@hampusmat.com> | 2022-02-15 20:27:51 +0100 |
---|---|---|
committer | HampusM <hampus@hampusmat.com> | 2022-02-15 20:27:51 +0100 |
commit | 5dae8f8d10d506abc3c75a1f66c1dfe620c84fc1 (patch) | |
tree | 2bfb6efef0535a35bab1da811a5f69cb5203dff9 /src/engine/vector2.hpp | |
parent | 9147551cd21d565f9503e3ebbcd2121e284d88d5 (diff) |
refactor: improve project design
Diffstat (limited to 'src/engine/vector2.hpp')
-rw-r--r-- | src/engine/vector2.hpp | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/src/engine/vector2.hpp b/src/engine/vector2.hpp index 3dc1db1..8423431 100644 --- a/src/engine/vector2.hpp +++ b/src/engine/vector2.hpp @@ -2,6 +2,12 @@ #include <memory> +struct Vector2Opts +{ + unsigned int x; + unsigned int y; +}; + /** * A 2D Vector. */ @@ -10,16 +16,13 @@ class Vector2 public: /** * Creates a 2D vector. - * - * @param x A X coordinate - * @param y A Y coordinate */ - Vector2(unsigned int x, unsigned int y); + explicit Vector2(Vector2Opts opts); /** * Returns the X coordinate. */ - unsigned int x() const; + [[nodiscard]] unsigned int x() const; /** * Sets the X coordinate. @@ -31,7 +34,7 @@ public: /** * Returns the Y coordinate. */ - unsigned int y() const; + [[nodiscard]] unsigned int y() const; /** * Sets the Y coordinate. @@ -47,8 +50,9 @@ public: */ std::shared_ptr<Vector2> copy(); - Vector2 operator+(const Vector2 vector2); - Vector2 operator-(const Vector2 vector2); + Vector2 operator*(const Vector2 &vector2) const; + Vector2 operator+(const Vector2 &vector2) const; + Vector2 operator-(const Vector2 &vector2) const; Vector2 &operator+=(const Vector2 &vector2); Vector2 &operator-=(const Vector2 &vector2); |