aboutsummaryrefslogtreecommitdiff
path: root/src/vector2.hpp
blob: ccfa75b835d29f015ebfcde82b65cbe56736656f (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
62
#ifndef VECTOR2_HPP
#define VECTOR2_HPP

#include <memory>

/**
 * 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<Vector2> 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;
};

#endif