pacman/lib/Blinky.cpp

41 lines
680 B
C++
Raw Normal View History

2021-07-28 13:28:36 +00:00
#include "Blinky.hpp"
namespace pacman {
Blinky::Blinky()
: Ghost(Atlas::Ghost::blinky) {
2021-07-28 15:01:22 +00:00
pos = initialPosition();
2021-07-28 13:28:36 +00:00
}
double Blinky::speed() 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;
}
void Blinky::setTarget(Position pacManPos) {
if (state == State::Eyes) {
target = initialPosition();
return;
}
2021-07-28 13:28:36 +00:00
if (isInPen()) {
target = penDoorPosition();
return;
}
2021-07-28 13:28:36 +00:00
target = state == State::Chase ? pacManPos : scatterTarget();
2021-07-28 13:28:36 +00:00
}
Position Blinky::initialPosition() const {
return { 13.5, 11 };
}
Position Blinky::scatterTarget() const {
return { 25, -3 };
}
} // namespace pacman