blob: d091ea53c42e6aea0d19b069de9b95b3cc3aa9d1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
#include "vector2.hpp"
#include <memory>
Vector2::Vector2(Vector2Opts opts) : _x(opts.x), _y(opts.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::make_shared<Vector2>(*this);
}
Vector2 Vector2::operator*(const Vector2 &vector2) const
{
return Vector2({.x = _x * vector2.x(), .y = _y * vector2.y()});
}
Vector2 Vector2::operator+(const Vector2 &vector2) const
{
return Vector2({.x = _x + vector2.x(), .y = _y + vector2.y()});
}
Vector2 Vector2::operator-(const Vector2 &vector2) const
{
return Vector2({.x = _x - vector2.x(), .y = _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;
}
|