pacman/lib/include/PacMan.hpp

46 lines
946 B
C++
Raw Normal View History

2021-06-10 12:42:51 +00:00
#pragma once
2020-11-27 13:10:09 +00:00
#include "Direction.hpp"
2020-11-28 12:04:14 +00:00
#include "PacManAnimation.hpp"
#include "Position.hpp"
2020-11-27 13:10:09 +00:00
#include <chrono>
2021-07-05 12:10:01 +00:00
namespace pacman {
class Board;
class InputState;
2020-11-27 13:10:09 +00:00
class PacMan {
public:
2021-07-07 09:39:09 +00:00
explicit PacMan();
2021-07-05 09:46:49 +00:00
[[nodiscard]] GridPosition currentSprite() const;
2020-11-27 16:16:42 +00:00
[[nodiscard]] Position position() const;
2020-11-27 13:10:09 +00:00
2021-07-05 11:54:54 +00:00
[[nodiscard]] GridPosition positionInGrid() const;
2021-06-16 11:59:16 +00:00
2021-07-07 09:39:09 +00:00
void update(std::chrono::milliseconds time_delta, InputState state);
2020-11-27 13:10:09 +00:00
2021-06-28 10:42:21 +00:00
void eat();
2021-07-07 09:39:09 +00:00
void reset();
2021-07-07 09:24:12 +00:00
[[nodiscard]] bool onTheMove() const {
2021-06-28 10:42:21 +00:00
return direction != Direction::NONE;
}
2020-11-27 13:10:09 +00:00
private:
Direction direction = Direction::NONE;
2020-11-27 16:01:27 +00:00
Direction desired_direction = Direction::NONE;
Position pos;
2020-11-28 12:04:14 +00:00
PacManAnimation pacManAnimation;
2021-06-28 10:42:21 +00:00
bool eaten = false;
2020-11-27 13:10:09 +00:00
void setDirection(const InputState & state);
2020-11-27 16:16:42 +00:00
void updateAnimationPosition(std::chrono::milliseconds time_delta, bool paused);
2021-07-07 09:39:09 +00:00
void updateMazePosition(std::chrono::milliseconds time_delta);
2020-11-27 13:10:09 +00:00
};
2021-07-05 12:10:01 +00:00
} // namespace pacman