Pacman should not be animated when hitting a wall

This commit is contained in:
Corentin Jabot 2021-06-22 15:35:50 +02:00 committed by Patricia Aas
parent f51b7d65e0
commit a69e66d114
2 changed files with 11 additions and 1 deletions

View File

@ -28,8 +28,10 @@ Position PacMan::positionInGrid() const {
void PacMan::update(std::chrono::milliseconds time_delta, InputState state, const Board & board) {
setDirection(state);
updateAnimationPosition(time_delta);
auto old = pos;
updateMazePosition(time_delta, board);
if(old != pos)
updateAnimationPosition(time_delta);
}
void PacMan::setDirection(const InputState & state) {

View File

@ -19,3 +19,11 @@ using Sprite = sf::Sprite;
inline bool operator==(const PositionInt & b, const Position & a) {
return a.x == b.x && a.y == b.y;
}
inline bool operator==(const Position & a, const Position & b) {
return a.x == b.x && a.y == b.y;
}
inline bool operator!=(const Position & a, const Position & b) {
return !(a == b);
}