blob: dff548cad3bedee9a53e3c67aa92d815276e651e (
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
|
#pragma once
#include <cstdint>
#include <functional>
struct Vector2Options
{
int32_t x;
int32_t y;
};
/**
* A 2D Vector.
*/
class Vector2
{
public:
explicit Vector2(const Vector2Options &options);
[[nodiscard]] int32_t get_x() const noexcept;
void set_x(int32_t x) noexcept;
[[nodiscard]] int32_t get_y() const noexcept;
void set_y(int32_t y) noexcept;
const Vector2 &operator+=(const Vector2 &vector2) noexcept;
const Vector2 &operator-=(const Vector2 &vector2) noexcept;
bool operator==(const Vector2 &vector2) const noexcept;
/**
* Returns Vector2({.x = 0, .y = 1})
*/
static Vector2 up();
/**
* Returns Vector2({.x = 0, .y = -1})
*/
static Vector2 down();
/**
* Returns Vector2({.x = -1, .y = 0})
*/
static Vector2 left();
/**
* Returns Vector2({.x = 1, .y = 0})
*/
static Vector2 right();
private:
int32_t _x;
int32_t _y;
};
class Vector2Hasher
{
public:
std::size_t operator()(const Vector2 &vector2) const;
};
|