blob: b0f559fdf4c4a4eed3d4deca52fa37ce1d97d3de (
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
|
#ifndef VEC2_HPP
#define VEC2_HPP
#include <tuple>
struct Vec2 {
float x = 0.f, y = 0.f;
constexpr Vec2() = default;
constexpr Vec2(float x_, float y_):
x(x_), y(y_) {}
Vec2(std::tuple<float, float> tup):
x(std::get<0>(tup)), y(std::get<1>(tup)) {}
auto operator+(const Vec2& o) const noexcept {
return Vec2 {x + o.x, y + o.y};
}
auto& operator+=(const Vec2& o) noexcept {
x += o.x;
y += o.y;
return *this;
}
};
#endif // VEC2_HPP
|