pacman/lib/PacMan.hpp
Patricia Aas 68f63f3f66
Canvas rewrite (#6)
* Beginning rewrite

* Move all constants to canvas, wire sprite handling code

* Make Sprite a struct and reformat

* Fix warning

Co-authored-by: Corentin Jabot <corentinjabot@gmail.com>
2021-06-16 12:52:04 +02:00

34 lines
783 B
C++

#pragma once
#include "Direction.hpp"
#include "PacManAnimation.hpp"
#include "Position.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);
};