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>
|
|
|
|
|
2020-11-28 13:10:25 +00:00
|
|
|
#include "Direction.hpp"
|
|
|
|
#include "Position.hpp"
|
2020-11-27 13:10:09 +00:00
|
|
|
#include <cstdint>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
const uint8_t ROWS = 31;
|
|
|
|
const uint8_t COLUMNS = 28;
|
|
|
|
|
|
|
|
class Board {
|
|
|
|
public:
|
2021-06-24 11:32:52 +00:00
|
|
|
enum class Cell {
|
|
|
|
wall = 0,
|
|
|
|
pellet = 1,
|
|
|
|
nothing = 2,
|
|
|
|
door = 3,
|
|
|
|
power_pellet = 4,
|
2021-06-25 09:06:50 +00:00
|
|
|
pen = 5,
|
2021-06-24 11:32:52 +00:00
|
|
|
};
|
|
|
|
|
2020-11-27 13:10:09 +00:00
|
|
|
Board();
|
|
|
|
|
2021-06-24 09:40:49 +00:00
|
|
|
[[nodiscard]] bool isWalkableForPacMan(Position point, float d, Direction direction) const;
|
|
|
|
[[nodiscard]] bool isWalkableForGhost(Position point, float d, Direction direction) const;
|
2020-11-27 13:10:09 +00:00
|
|
|
|
2021-06-28 10:42:21 +00:00
|
|
|
[[nodiscard]] bool isWalkableForGost(Position point, Position origin, bool isEyes) const;
|
2021-06-25 09:06:50 +00:00
|
|
|
[[nodiscard]] bool isWalkable(Position point) const;
|
|
|
|
[[nodiscard]] bool isInPen(Position point) const;
|
|
|
|
|
2021-06-20 16:52:34 +00:00
|
|
|
[[nodiscard]] std::vector<PositionInt> initialPelletPositions() const;
|
2020-11-27 13:10:09 +00:00
|
|
|
|
2021-06-20 16:52:34 +00:00
|
|
|
[[nodiscard]] std::vector<PositionInt> initialSuperPelletPositions() const;
|
2020-11-27 13:10:09 +00:00
|
|
|
|
2021-06-24 11:32:52 +00:00
|
|
|
static Position initialPacManPosition() { return { 13.5, 23 }; }
|
|
|
|
|
|
|
|
static Position initialBlinkyPosition() { return { 13.5, 11 }; }
|
2021-06-25 09:06:50 +00:00
|
|
|
static Position penDoorPosition() { return { 13, 11 }; }
|
|
|
|
|
|
|
|
static Position blinkyScatterTarget() { return { 25, -3 }; }
|
2021-06-24 11:32:52 +00:00
|
|
|
|
|
|
|
static Position initialSpeedyPosition() { return { 11.5, 14 }; }
|
|
|
|
static Position speedyScatterTarget() { return { 3, -2 }; }
|
|
|
|
|
|
|
|
static Position initialInkyPosition() { return { 13.5, 14 }; }
|
|
|
|
static Position inkyScatterTarget() { return { 27, 30 }; }
|
|
|
|
|
|
|
|
static Position initialClydePosition() { return { 15.5, 14 }; }
|
|
|
|
static Position clydeScatterTarget() { return { 0, 30 }; }
|
2020-11-27 13:10:09 +00:00
|
|
|
|
|
|
|
private:
|
2021-06-24 09:40:49 +00:00
|
|
|
[[nodiscard]] bool isWalkable(Position point, float d, Direction direction, bool pacman) const;
|
2020-11-27 16:16:42 +00:00
|
|
|
uint8_t board_state[ROWS][COLUMNS]{};
|
2020-11-27 13:10:09 +00:00
|
|
|
};
|