pacman/lib/PacMan.hpp
Corentin Jabot bbf3731cf4 Change window geometry for scoring.
* Add margins all around the board for better aestetics.
* Add room for scoring
* Because the texture atlas is a 32x32 grid, we can manipulate
textures as positions on that grid and only create a rectangle
for that texture in the rendering code.
* Avoid hardcoded values in the rendering code.
2021-06-15 23:55:55 +02:00

35 lines
784 B
C++

#pragma once
#include "Direction.hpp"
#include "Position.hpp"
#include "PacManAnimation.hpp"
#include <SDL2/SDL_rect.h>
#include <chrono>
class Board;
class InputState;
class PacMan {
public:
explicit PacMan(const Board & board);
[[nodiscard]] SDL_Point currentSprite() const;
[[nodiscard]] Position position() const;
void update(std::chrono::milliseconds time_delta, InputState state, const Board & board);
private:
Direction direction = Direction::NONE;
Direction desired_direction = Direction::NONE;
Position pos;
PacManAnimation pacManAnimation;
void setDirection(const InputState & state);
void updateAnimationPosition(std::chrono::milliseconds time_delta);
void updateMazePosition(std::chrono::milliseconds time_delta, const Board & board);
};