project-kyoku/include/core/point.h

41 lines
792 B
C
Raw Normal View History

2021-12-29 15:59:18 +01:00
#pragma once
namespace kku
{
struct Point
{
float x;
float y;
constexpr inline explicit Point() noexcept : x(0.), y(0.) {}
2021-12-29 15:59:18 +01:00
constexpr inline explicit Point(int x, int y) noexcept : x(x), y(y) {}
2021-12-29 15:59:18 +01:00
constexpr inline explicit Point(float x, float y) noexcept : x(x), y(y) {}
2021-12-29 15:59:18 +01:00
constexpr inline Point operator+(const Point &right) const noexcept
2021-12-29 15:59:18 +01:00
{
return Point{right.x + x, right.y + y};
}
constexpr inline Point operator-(const Point &right) const noexcept
2021-12-29 15:59:18 +01:00
{
return Point{right.x - x, right.y - y};
}
inline void moveBy(float x, float y) noexcept
{
this->x += x;
this->y += y;
}
inline void scaleBy(float factor) noexcept
{
x *= factor;
y *= factor;
}
};
} // namespace kku