2021-06-24 11:32:52 +00:00
|
|
|
#pragma once
|
2021-07-01 12:53:52 +00:00
|
|
|
|
2021-06-24 11:32:52 +00:00
|
|
|
#include "Direction.hpp"
|
|
|
|
#include "Position.hpp"
|
2021-07-07 09:24:12 +00:00
|
|
|
#include <cassert>
|
2021-06-24 11:32:52 +00:00
|
|
|
|
2021-07-01 12:53:52 +00:00
|
|
|
#include <array>
|
|
|
|
|
2021-07-05 12:10:01 +00:00
|
|
|
namespace pacman::Atlas {
|
2021-06-24 11:32:52 +00:00
|
|
|
|
2021-07-06 10:35:23 +00:00
|
|
|
enum class Ghost : unsigned int {
|
2021-07-05 12:10:01 +00:00
|
|
|
blinky = 2,
|
2021-07-28 14:20:19 +00:00
|
|
|
pinky = 3,
|
2021-07-05 12:10:01 +00:00
|
|
|
inky = 4,
|
|
|
|
clyde = 5,
|
|
|
|
};
|
2021-06-24 11:32:52 +00:00
|
|
|
|
2021-07-05 12:10:01 +00:00
|
|
|
constexpr GridPosition pacman_right_wide = { 0, 0 };
|
|
|
|
constexpr GridPosition pacman_right_narrow = { 1, 0 };
|
|
|
|
constexpr GridPosition pacman_closed = { 2, 0 };
|
|
|
|
constexpr GridPosition pacman_left_narrow = { 3, 0 };
|
|
|
|
constexpr GridPosition pacman_left_wide = { 4, 0 };
|
|
|
|
constexpr GridPosition pacman_up_wide = { 5, 0 };
|
|
|
|
constexpr GridPosition pacman_up_narrow = { 6, 0 };
|
|
|
|
constexpr GridPosition pacman_down_wide = { 7, 0 };
|
|
|
|
constexpr GridPosition pacman_down_narrow = { 8, 0 };
|
2021-06-24 11:32:52 +00:00
|
|
|
|
2021-07-05 12:10:01 +00:00
|
|
|
constexpr GridPosition ghost_blue_frightened = { 0, 7 };
|
|
|
|
constexpr GridPosition ghost_blue_frightened2 = { 1, 7 };
|
|
|
|
constexpr GridPosition ghost_white_frightened = { 2, 7 };
|
|
|
|
constexpr GridPosition ghost_white_frightened2 = { 3, 7 };
|
2021-06-28 10:42:21 +00:00
|
|
|
|
2021-07-05 12:10:01 +00:00
|
|
|
constexpr GridPosition eyeSprite(Direction direction) {
|
|
|
|
switch (direction) {
|
|
|
|
case Direction::RIGHT:
|
2021-07-07 09:24:12 +00:00
|
|
|
return { 0, 6 };
|
2021-07-05 12:10:01 +00:00
|
|
|
case Direction::DOWN:
|
2021-07-07 09:24:12 +00:00
|
|
|
return { 2, 6 };
|
2021-07-05 12:10:01 +00:00
|
|
|
case Direction::LEFT:
|
2021-07-07 09:24:12 +00:00
|
|
|
return { 4, 6 };
|
2021-07-05 12:10:01 +00:00
|
|
|
case Direction::UP:
|
2021-07-07 09:24:12 +00:00
|
|
|
return { 6, 6 };
|
2021-07-05 12:10:01 +00:00
|
|
|
default:
|
2021-07-07 09:24:12 +00:00
|
|
|
return { 0, 6 };
|
2021-06-28 10:42:21 +00:00
|
|
|
}
|
2021-07-05 12:10:01 +00:00
|
|
|
}
|
2021-06-28 10:42:21 +00:00
|
|
|
|
2021-07-05 12:10:01 +00:00
|
|
|
constexpr GridPosition ghostSprite(Ghost ghost, Direction direction, bool alternative) {
|
|
|
|
assert(ghost >= Ghost::blinky && ghost <= Ghost::clyde && "Invalid Ghost");
|
2021-09-10 09:02:37 +00:00
|
|
|
auto y = static_cast<size_t>(ghost);
|
|
|
|
size_t x = 0;
|
2021-07-05 12:10:01 +00:00
|
|
|
switch (direction) {
|
|
|
|
case Direction::RIGHT:
|
|
|
|
x = 0;
|
|
|
|
break;
|
|
|
|
case Direction::DOWN:
|
|
|
|
x = 2;
|
|
|
|
break;
|
|
|
|
case Direction::LEFT:
|
|
|
|
x = 4;
|
|
|
|
break;
|
|
|
|
case Direction::UP:
|
|
|
|
x = 6;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
x = 0;
|
|
|
|
break;
|
2021-06-24 11:32:52 +00:00
|
|
|
}
|
2021-07-05 12:10:01 +00:00
|
|
|
if (alternative)
|
|
|
|
x++;
|
|
|
|
return { x, y };
|
|
|
|
}
|
2021-07-01 12:53:52 +00:00
|
|
|
|
2021-09-10 12:02:00 +00:00
|
|
|
constexpr GridPosition initialFrightened(std::size_t animationIndex) {
|
2021-07-05 12:10:01 +00:00
|
|
|
return (animationIndex % 2) == 0 ? Atlas::ghost_blue_frightened2 : Atlas::ghost_blue_frightened;
|
|
|
|
}
|
2021-07-01 12:53:52 +00:00
|
|
|
|
2021-09-10 12:02:00 +00:00
|
|
|
constexpr GridPosition endingFrightened(std::size_t animationIndex) {
|
2021-07-05 12:10:01 +00:00
|
|
|
std::array<GridPosition, 4> positions = { Atlas::ghost_blue_frightened,
|
|
|
|
Atlas::ghost_blue_frightened2,
|
|
|
|
Atlas::ghost_white_frightened,
|
|
|
|
Atlas::ghost_white_frightened2 };
|
|
|
|
return positions[animationIndex];
|
2021-06-24 11:32:52 +00:00
|
|
|
}
|
2021-07-05 12:10:01 +00:00
|
|
|
} // namespace pacman::Atlas
|