2021-06-10 12:42:51 +00:00
|
|
|
#pragma once
|
2020-11-27 13:10:09 +00:00
|
|
|
|
2021-06-20 16:52:34 +00:00
|
|
|
#include <SFML/Graphics.hpp>
|
2021-07-08 14:57:18 +00:00
|
|
|
#include <cmath>
|
2021-06-16 11:59:16 +00:00
|
|
|
|
2021-07-05 12:10:01 +00:00
|
|
|
namespace pacman {
|
|
|
|
|
2020-11-27 13:10:09 +00:00
|
|
|
struct Position {
|
2021-07-05 09:40:10 +00:00
|
|
|
double x;
|
|
|
|
double y;
|
2020-11-27 13:10:09 +00:00
|
|
|
};
|
2021-06-16 11:59:16 +00:00
|
|
|
|
2021-07-05 09:46:49 +00:00
|
|
|
struct GridPosition {
|
2021-07-06 10:35:23 +00:00
|
|
|
size_t x;
|
|
|
|
size_t y;
|
2021-07-06 10:41:50 +00:00
|
|
|
constexpr GridPosition(size_t x, size_t y) : x(x), y(y) {}
|
2021-06-20 16:52:34 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
using Rect = sf::Rect<int>;
|
|
|
|
|
|
|
|
using Sprite = sf::Sprite;
|
|
|
|
|
2021-07-06 10:35:23 +00:00
|
|
|
inline GridPosition positionToGridPosition(Position pos) {
|
|
|
|
return { size_t(std::round(pos.x)), size_t(std::round(pos.y)) };
|
|
|
|
}
|
|
|
|
|
2021-07-07 09:09:53 +00:00
|
|
|
inline Position gridPositionToPosition(GridPosition pos) {
|
|
|
|
return { double(pos.x), double(pos.y) };
|
|
|
|
}
|
|
|
|
|
2021-07-06 10:35:23 +00:00
|
|
|
constexpr bool operator==(const GridPosition & a, const GridPosition & b) {
|
2021-07-05 11:54:54 +00:00
|
|
|
return a.x == b.x && a.y == b.y;
|
|
|
|
}
|
|
|
|
|
2021-07-09 08:24:24 +00:00
|
|
|
constexpr bool operator!=(const GridPosition & a, const GridPosition & b) {
|
|
|
|
return !(a == b);
|
2021-06-16 11:59:16 +00:00
|
|
|
}
|
2021-06-22 13:35:50 +00:00
|
|
|
|
2021-07-06 10:35:23 +00:00
|
|
|
constexpr bool operator==(const Position & a, const Position & b) {
|
2021-06-22 13:35:50 +00:00
|
|
|
return a.x == b.x && a.y == b.y;
|
|
|
|
}
|
|
|
|
|
2021-07-06 10:35:23 +00:00
|
|
|
constexpr bool operator!=(const Position & a, const Position & b) {
|
2021-06-22 13:35:50 +00:00
|
|
|
return !(a == b);
|
|
|
|
}
|
2021-07-05 12:10:01 +00:00
|
|
|
|
2021-07-09 08:24:24 +00:00
|
|
|
|
2021-07-05 15:19:35 +00:00
|
|
|
|
2021-07-05 12:10:01 +00:00
|
|
|
} // namespace pacman
|