From 5dae8f8d10d506abc3c75a1f66c1dfe620c84fc1 Mon Sep 17 00:00:00 2001 From: HampusM Date: Tue, 15 Feb 2022 20:27:51 +0100 Subject: refactor: improve project design --- src/engine/vector2.hpp | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'src/engine/vector2.hpp') 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 +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 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); -- cgit v1.2.3-18-g5258