diff options
author | HampusM <hampus@hampusmat.com> | 2022-02-13 19:55:53 +0100 |
---|---|---|
committer | HampusM <hampus@hampusmat.com> | 2022-02-13 19:55:53 +0100 |
commit | b0c265ee3d94921f55266a679d3801a4d2b4505b (patch) | |
tree | b489dcbafddafdb05b415e920e9a2ca8524158e6 /src/engine/vector2.cpp | |
parent | 36ce8d5d2c9b3bb9588a2bc1d96ee2678c2b990c (diff) |
refactor: move some components to a engine dir
Diffstat (limited to 'src/engine/vector2.cpp')
-rw-r--r-- | src/engine/vector2.cpp | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/src/engine/vector2.cpp b/src/engine/vector2.cpp new file mode 100644 index 0000000..effc8b5 --- /dev/null +++ b/src/engine/vector2.cpp @@ -0,0 +1,58 @@ +#include "vector2.hpp" + +Vector2::Vector2(unsigned int x, unsigned int y) +{ + _x = x; + _y = y; +} + +unsigned int Vector2::x() const +{ + return _x; +} + +void Vector2::x(unsigned int x) +{ + _x = x; +} + +unsigned int Vector2::y() const +{ + return _y; +} + +void Vector2::y(unsigned int y) +{ + _y = y; +} + +std::shared_ptr<Vector2> Vector2::copy() +{ + return std::shared_ptr<Vector2>(new Vector2(*this)); +} + +Vector2 Vector2::operator+(const Vector2 vector2) +{ + return Vector2(_x + vector2.x(), _y + vector2.y()); +} + +Vector2 Vector2::operator-(const Vector2 vector2) +{ + return Vector2(_x - vector2.x(), _y - vector2.y()); +} + +Vector2 &Vector2::operator+=(const Vector2 &vector2) +{ + _x += vector2.x(); + _y += vector2.y(); + + return *this; +} + +Vector2 &Vector2::operator-=(const Vector2 &vector2) +{ + _x -= vector2.x(); + _y -= vector2.y(); + + return *this; +} |