diff --git a/lib/PacMan.cpp b/lib/PacMan.cpp index 6701297..0e610d2 100644 --- a/lib/PacMan.cpp +++ b/lib/PacMan.cpp @@ -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) { diff --git a/lib/Position.hpp b/lib/Position.hpp index b740945..cf089a9 100644 --- a/lib/Position.hpp +++ b/lib/Position.hpp @@ -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); +}