diff --git a/lib/Board.cpp b/lib/Board.cpp index 1d25d29..658689a 100644 --- a/lib/Board.cpp +++ b/lib/Board.cpp @@ -43,11 +43,11 @@ std::array, ROWS> Board::board = {{ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, // 30 }}; -bool Board::isWalkableForPacMan(Position point, float d, Direction direction) { +bool Board::isWalkableForPacMan(Position point, double d, Direction direction) { return isWalkable(point, d, direction, true); } -bool Board::isWalkableForGhost(Position point, float d, Direction direction) { +bool Board::isWalkableForGhost(Position point, double d, Direction direction) { return isWalkable(point, d, direction, false); } @@ -63,11 +63,11 @@ bool Board::isInPen(Position point) { return board[int(point.y)][int(point.x)] == int(Cell::pen); } -bool Board::isWalkable(Position point, float position_delta, Direction direction, bool pacman) { +bool Board::isWalkable(Position point, double position_delta, Direction direction, bool pacman) { if (point.x <= 0 || point.x >= COLUMNS - 1) return true; - auto cellAtPosition = [&](Position point, float position_delta, Direction direction) { + auto cellAtPosition = [&](Position point, double position_delta, Direction direction) { switch (direction) { case Direction::LEFT: return board[int(point.y)][int(point.x - position_delta)]; diff --git a/lib/Board.hpp b/lib/Board.hpp index c0f01e8..d60bbdb 100644 --- a/lib/Board.hpp +++ b/lib/Board.hpp @@ -22,8 +22,8 @@ public: pen = 5, }; - [[nodiscard]] static bool isWalkableForPacMan(Position point, float d, Direction direction) ; - [[nodiscard]] static bool isWalkableForGhost(Position point, float d, Direction direction) ; + [[nodiscard]] static bool isWalkableForPacMan(Position point, double d, Direction direction) ; + [[nodiscard]] static bool isWalkableForGhost(Position point, double d, Direction direction) ; [[nodiscard]] static bool isWalkableForGost(Position point, Position origin, bool isEyes) ; [[nodiscard]] static bool isWalkable(Position point) ; @@ -50,7 +50,7 @@ public: static Position clydeScatterTarget() { return { 0, 30 }; } private: - [[nodiscard]] static bool isWalkable(Position point, float d, Direction direction, bool pacman) ; + [[nodiscard]] static bool isWalkable(Position point, double d, Direction direction, bool pacman) ; static std::array< std::array, ROWS> diff --git a/lib/Canvas.cpp b/lib/Canvas.cpp index 059670b..0c63d34 100644 --- a/lib/Canvas.cpp +++ b/lib/Canvas.cpp @@ -60,7 +60,7 @@ void Canvas::renderPellets(const Pellets & pellets) { Sprite pellet = getSprite(pellets.currentSprite()); std::vector pelletPositions = pellets.currentPositions(); for (const auto & pos : pelletPositions) { - renderSprite(pellet, { float(pos.x), float(pos.y) }); + renderSprite(pellet, { double(pos.x), double(pos.y) }); } } @@ -68,7 +68,7 @@ void Canvas::renderSuperPellets(const SuperPellets & superPellets) { Sprite pellet = getSprite(superPellets.currentSprite()); std::vector superPelletPositions = superPellets.currentPositions(); for (const auto & pos : superPelletPositions) { - renderSprite(pellet, { float(pos.x), float(pos.y) }); + renderSprite(pellet, { double(pos.x), double(pos.y) }); } } diff --git a/lib/Ghost.cpp b/lib/Ghost.cpp index fc0640e..cfb06eb 100644 --- a/lib/Ghost.cpp +++ b/lib/Ghost.cpp @@ -81,7 +81,7 @@ bool Ghost::isInPen(const Board & board) const { void Ghost::updatePosition(std::chrono::milliseconds time_delta, const Board & board) { updateDirection(board); - float position_delta = (0.004 * time_delta.count()) * speed(); + double position_delta = (0.004 * time_delta.count()) * speed(); switch (direction) { case Direction::NONE: diff --git a/lib/PacMan.cpp b/lib/PacMan.cpp index c3e62d1..dc3f748 100644 --- a/lib/PacMan.cpp +++ b/lib/PacMan.cpp @@ -61,7 +61,7 @@ void PacMan::updateAnimationPosition(std::chrono::milliseconds time_delta, bool } void PacMan::updateMazePosition(std::chrono::milliseconds time_delta, const Board & board) { - float position_delta = 0.004 * time_delta.count(); + double position_delta = 0.004 * time_delta.count(); // Handle teleport if (pos.x >= COLUMNS - 1 && direction == Direction::RIGHT) { diff --git a/lib/PacManAnimation.cpp b/lib/PacManAnimation.cpp index cabe5b0..8448480 100644 --- a/lib/PacManAnimation.cpp +++ b/lib/PacManAnimation.cpp @@ -24,7 +24,7 @@ void PacManAnimation::updateAnimationPosition(std::chrono::milliseconds time_del if (dead && animation_position >= 11) return; - animation_position_delta += (0.02) * float(time_delta.count()); + animation_position_delta += (0.02) * double(time_delta.count()); animation_position = int(animation_position + animation_position_delta); if (!dead) diff --git a/lib/PacManAnimation.hpp b/lib/PacManAnimation.hpp index a1f683a..bd00ffb 100644 --- a/lib/PacManAnimation.hpp +++ b/lib/PacManAnimation.hpp @@ -18,7 +18,7 @@ public: private: uint8_t animation_position = 0; - float animation_position_delta = 0.0; + double animation_position_delta = 0.0; const PositionInt down_animation[4]{ Atlas::pacman_down_wide, Atlas::pacman_down_narrow, Atlas::pacman_closed, Atlas::pacman_down_narrow }; const PositionInt left_animation[4]{ Atlas::pacman_left_wide, Atlas::pacman_left_narrow, Atlas::pacman_closed, Atlas::pacman_left_narrow }; const PositionInt right_animation[4]{ Atlas::pacman_right_wide, Atlas::pacman_right_narrow, Atlas::pacman_closed, Atlas::pacman_right_narrow }; diff --git a/lib/Position.hpp b/lib/Position.hpp index cf089a9..c35fe9b 100644 --- a/lib/Position.hpp +++ b/lib/Position.hpp @@ -3,8 +3,8 @@ #include struct Position { - float x; - float y; + double x; + double y; }; struct PositionInt {