2021-07-28 13:28:36 +00:00
|
|
|
#include "Blinky.hpp"
|
2021-07-29 09:16:08 +00:00
|
|
|
#include "GameState.hpp"
|
2021-07-28 13:28:36 +00:00
|
|
|
|
|
|
|
namespace pacman {
|
|
|
|
|
|
|
|
Blinky::Blinky()
|
2021-07-28 14:20:19 +00:00
|
|
|
: Ghost(Atlas::Ghost::blinky) {
|
2021-07-28 15:01:22 +00:00
|
|
|
pos = initialPosition();
|
2021-07-28 13:28:36 +00:00
|
|
|
}
|
|
|
|
|
2021-08-02 12:29:25 +00:00
|
|
|
double Blinky::speed(const GameState &) const {
|
2021-07-28 13:28:36 +00:00
|
|
|
if (state == State::Eyes)
|
|
|
|
return 2;
|
|
|
|
if (state == State::Frightened)
|
|
|
|
return 0.5;
|
|
|
|
return 0.75;
|
|
|
|
}
|
|
|
|
|
|
|
|
Position Blinky::target(const GameState & gameState) const {
|
|
|
|
if (state == State::Eyes)
|
2021-07-28 14:39:27 +00:00
|
|
|
return initialPosition();
|
2021-07-28 13:28:36 +00:00
|
|
|
|
|
|
|
if (isInPen())
|
2021-07-28 13:41:32 +00:00
|
|
|
return penDoorPosition();
|
2021-07-28 13:28:36 +00:00
|
|
|
|
2021-08-02 12:09:03 +00:00
|
|
|
const auto pacManPosition = gridPositionToPosition(gameState.pacMan.positionInGrid());
|
|
|
|
return state == State::Chase ? pacManPosition : scatterTarget();
|
2021-07-28 13:28:36 +00:00
|
|
|
}
|
|
|
|
|
2021-07-28 14:20:19 +00:00
|
|
|
Position Blinky::initialPosition() const {
|
2021-07-28 14:39:27 +00:00
|
|
|
return { 13.5, 11 };
|
|
|
|
}
|
|
|
|
|
|
|
|
Position Blinky::scatterTarget() const {
|
|
|
|
return { 25, -3 };
|
2021-07-28 14:20:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|