pacman/lib/include/PacMan.hpp

41 lines
889 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 {
2020-11-27 13:10:09 +00:00
class PacMan {
public:
2021-08-02 13:31:32 +00:00
GridPosition currentSprite() const;
Position position() const;
GridPosition positionInGrid() const;
2021-06-16 11:59:16 +00:00
2021-07-08 14:57:18 +00:00
void update(std::chrono::milliseconds time_delta, Direction input_direction);
2020-11-27 13:10:09 +00:00
2021-07-13 12:26:57 +00:00
void die();
2021-07-07 09:39:09 +00:00
void reset();
2021-08-02 13:31:32 +00:00
bool hasDirection() const {
2021-06-28 10:42:21 +00:00
return direction != Direction::NONE;
}
2021-07-29 09:16:08 +00:00
Direction currentDirection() const {
return direction;
}
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;
2021-07-13 12:26:57 +00:00
Position pos = initialPacManPosition();
2020-11-28 12:04:14 +00:00
PacManAnimation pacManAnimation;
2021-07-13 12:26:57 +00:00
bool dead = false;
2020-11-27 13:10:09 +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