aboutsummaryrefslogtreecommitdiff
path: root/src/engine/data/vector2.hpp
blob: 580123ce59d02f3783534a1cf5c70e26f6a0c33c (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
#pragma once

#include <cstdint>

struct Vector2Options
{
	uint32_t x;
	uint32_t y;
};

/**
 * A 2D Vector.
 */
class Vector2
{
public:
	/**
	 * Creates a 2D vector.
	 */
	explicit Vector2(const Vector2Options &options);

	/**
	 * Returns the X coordinate.
	 */
	[[nodiscard]] uint32_t x() const noexcept;

	/**
	 * Sets the X coordinate.
	 *
	 * @param x A new X coordinate
	 */
	void x(uint32_t x) noexcept;

	/**
	 * Returns the Y coordinate.
	 */
	[[nodiscard]] uint32_t y() const noexcept;

	/**
	 * Sets the Y coordinate.
	 *
	 * @param Y A new Y coordinate
	 */
	void y(uint32_t y) noexcept;

	const Vector2 &operator+=(const Vector2 &vector2) noexcept;
	const Vector2 &operator-=(const Vector2 &vector2) noexcept;

private:
	uint32_t _x;
	uint32_t _y;
};