2020-11-27 13:10:09 +00:00
|
|
|
#ifndef PACMAN_PACMAN_H
|
|
|
|
#define PACMAN_PACMAN_H
|
|
|
|
|
2020-11-28 13:10:25 +00:00
|
|
|
#include "Direction.hpp"
|
|
|
|
#include "Position.hpp"
|
2020-11-28 12:04:14 +00:00
|
|
|
#include "PacManAnimation.hpp"
|
2020-11-27 13:10:09 +00:00
|
|
|
|
|
|
|
#include <SDL2/SDL_rect.h>
|
|
|
|
#include <chrono>
|
|
|
|
|
2020-11-28 13:10:25 +00:00
|
|
|
class Board;
|
|
|
|
class InputState;
|
|
|
|
|
2020-11-27 13:10:09 +00:00
|
|
|
class PacMan {
|
|
|
|
public:
|
2020-11-28 13:10:25 +00:00
|
|
|
explicit PacMan(const Board & board);
|
|
|
|
|
2020-11-27 13:10:09 +00:00
|
|
|
[[nodiscard]] SDL_Rect currentSprite() const;
|
2020-11-27 16:16:42 +00:00
|
|
|
|
2020-11-27 13:10:09 +00:00
|
|
|
[[nodiscard]] Position currentPosition() const;
|
|
|
|
|
|
|
|
void update(std::chrono::milliseconds time_delta, InputState state, const Board & board);
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
Direction direction = Direction::NONE;
|
2020-11-27 16:01:27 +00:00
|
|
|
Direction desired_direction = Direction::NONE;
|
2020-11-28 13:10:25 +00:00
|
|
|
Position pos;
|
2020-11-28 12:04:14 +00:00
|
|
|
PacManAnimation pacManAnimation;
|
2020-11-27 13:10:09 +00:00
|
|
|
|
|
|
|
void setDirection(const InputState & state);
|
2020-11-27 16:16:42 +00:00
|
|
|
|
2020-11-27 13:10:09 +00:00
|
|
|
void updateAnimationPosition(std::chrono::milliseconds time_delta);
|
2020-11-27 16:16:42 +00:00
|
|
|
|
2020-11-27 13:10:09 +00:00
|
|
|
void updateMazePosition(std::chrono::milliseconds time_delta, const Board & board);
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif //PACMAN_PACMAN_H
|