diff --git a/lib/Blinky.cpp b/lib/Blinky.cpp index 0a57d14..116a7df 100644 --- a/lib/Blinky.cpp +++ b/lib/Blinky.cpp @@ -16,16 +16,20 @@ double Blinky::speed(const GameState & gameState) const { Position Blinky::target(const GameState & gameState) const { if (state == State::Eyes) - return initialBlinkyPosition(); + return initialPosition(); if (isInPen()) return penDoorPosition(); - return blinkyScatterTarget(); + return scatterTarget(); } Position Blinky::initialPosition() const { - return initialBlinkyPosition(); + return { 13.5, 11 }; +} + +Position Blinky::scatterTarget() const { + return { 25, -3 }; } } diff --git a/lib/Clyde.cpp b/lib/Clyde.cpp index f35bacb..86b5fbe 100644 --- a/lib/Clyde.cpp +++ b/lib/Clyde.cpp @@ -16,17 +16,20 @@ double Clyde::speed(const GameState & gameState) const { Position Clyde::target(const GameState & gameState) const { if (state == State::Eyes) - return initialClydePosition(); + return initialPosition(); if (isInPen()) return penDoorPosition(); - return clydeScatterTarget(); + return scatterTarget(); } Position Clyde::initialPosition() const { - return initialClydePosition(); + return { 15.5, 14 }; } +Position Clyde::scatterTarget() const { + return { 0, 30 }; +} } diff --git a/lib/Inky.cpp b/lib/Inky.cpp index 3e598f3..24d89df 100644 --- a/lib/Inky.cpp +++ b/lib/Inky.cpp @@ -16,17 +16,20 @@ double Inky::speed(const GameState & gameState) const { Position Inky::target(const GameState & gameState) const { if (state == State::Eyes) - return initialInkyPosition(); + return initialPosition(); if (isInPen()) return penDoorPosition(); - return inkyScatterTarget(); + return scatterTarget(); } Position Inky::initialPosition() const { - return initialInkyPosition(); + return { 13.5, 14 }; } +Position Inky::scatterTarget() const { + return { 27, 30 }; +} } diff --git a/lib/Pinky.cpp b/lib/Pinky.cpp index 8a6c6b2..52fa0b8 100644 --- a/lib/Pinky.cpp +++ b/lib/Pinky.cpp @@ -16,16 +16,20 @@ double Pinky::speed(const GameState & gameState) const { Position Pinky::target(const GameState & gameState) const { if (state == State::Eyes) - return initialPinkyPosition(); + return initialPosition(); if (isInPen()) return penDoorPosition(); - return pinkyScatterTarget(); + return scatterTarget(); } Position Pinky::initialPosition() const { - return initialPinkyPosition(); + return { 11.5, 14 }; +} + +Position Pinky::scatterTarget() const { + return { 3, -2 }; } } diff --git a/lib/include/Blinky.hpp b/lib/include/Blinky.hpp index 91f0de2..f2a93d1 100644 --- a/lib/include/Blinky.hpp +++ b/lib/include/Blinky.hpp @@ -6,10 +6,15 @@ namespace pacman { class Blinky : public Ghost { public: - explicit Blinky(); - [[nodiscard]] double speed(const GameState & gameState) const override; - [[nodiscard]] Position target(const GameState & gameState) const override; + Blinky(); + +protected: + double speed(const GameState & gameState) const override; + Position target(const GameState & gameState) const override; Position initialPosition() const override; + +private: + Position scatterTarget() const; }; } // namespace pacman diff --git a/lib/include/Board.hpp b/lib/include/Board.hpp index 45f7700..4016107 100644 --- a/lib/include/Board.hpp +++ b/lib/include/Board.hpp @@ -23,16 +23,4 @@ namespace pacman { inline Position penDoorPosition() { return { 13, 11 }; } inline Position initialPacManPosition() { return { 13.5, 23 }; } - inline Position initialBlinkyPosition() { return { 13.5, 11 }; } - inline Position blinkyScatterTarget() { return { 25, -3 }; } - - inline Position initialPinkyPosition() { return { 11.5, 14 }; } - inline Position pinkyScatterTarget() { return { 3, -2 }; } - - inline Position initialInkyPosition() { return { 13.5, 14 }; } - inline Position inkyScatterTarget() { return { 27, 30 }; } - - inline Position initialClydePosition() { return { 15.5, 14 }; } - inline Position clydeScatterTarget() { return { 0, 30 }; } - -} // namespace pacman + } // namespace pacman diff --git a/lib/include/Clyde.hpp b/lib/include/Clyde.hpp index 7f3642f..ef76ebb 100644 --- a/lib/include/Clyde.hpp +++ b/lib/include/Clyde.hpp @@ -7,9 +7,14 @@ namespace pacman { class Clyde : public Ghost { public: explicit Clyde(); - [[nodiscard]] double speed(const GameState & gameState) const override; - [[nodiscard]] Position target(const GameState & gameState) const override; + +protected: + double speed(const GameState & gameState) const override; + Position target(const GameState & gameState) const override; Position initialPosition() const override; + +private: + Position scatterTarget() const; }; } // namespace pacman diff --git a/lib/include/Ghost.hpp b/lib/include/Ghost.hpp index a5b8d0a..cdb72d5 100644 --- a/lib/include/Ghost.hpp +++ b/lib/include/Ghost.hpp @@ -46,7 +46,6 @@ protected: virtual Position target(const GameState & gameState) const = 0; virtual Position initialPosition() const = 0; - Atlas::Ghost spritesSet; Direction direction = Direction::NONE; double timeForAnimation = 0; diff --git a/lib/include/Inky.hpp b/lib/include/Inky.hpp index d4dac46..9588c84 100644 --- a/lib/include/Inky.hpp +++ b/lib/include/Inky.hpp @@ -7,9 +7,14 @@ namespace pacman { class Inky : public Ghost { public: explicit Inky(); - [[nodiscard]] double speed(const GameState & gameState) const override; - [[nodiscard]] Position target(const GameState & gameState) const override; + +protected: + double speed(const GameState & gameState) const override; + Position target(const GameState & gameState) const override; Position initialPosition() const override; + +private: + Position scatterTarget() const; }; } // namespace pacman diff --git a/lib/include/Pinky.hpp b/lib/include/Pinky.hpp index 2d052de..83db11c 100644 --- a/lib/include/Pinky.hpp +++ b/lib/include/Pinky.hpp @@ -7,9 +7,14 @@ namespace pacman { class Pinky : public Ghost { public: explicit Pinky(); - [[nodiscard]] double speed(const GameState & gameState) const override; - [[nodiscard]] Position target(const GameState & gameState) const override; + +protected: + double speed(const GameState & gameState) const override; + Position target(const GameState & gameState) const override; Position initialPosition() const override; + +private: + Position scatterTarget() const; }; } // namespace pacman