pacman/lib/PacManAnimation.hpp
Corentin Jabot c7ef086d3d Migrate from SDL to SFML
This simplifies the rendering code and remove all(!) pointers.

There is a number of unresolved issues

* Windows build ?
* position delta computation: migrating to SFML seems to have modified
the frame rate.
2021-06-22 13:17:12 +02:00

32 lines
1.1 KiB
C++

#pragma once
#include "Board.hpp"
#include "Direction.hpp"
#include "InputState.hpp"
#include "Position.hpp"
#include <chrono>
class PacManAnimation {
public:
[[nodiscard]] PositionInt animationFrame(Direction direction) const;
void updateAnimationPosition(std::chrono::milliseconds time_delta);
private:
uint8_t animation_position = 0;
float animation_position_delta = 0.0;
const PositionInt right_wide = { 0, 0 };
const PositionInt right_narrow = { 1, 0 };
const PositionInt closed = { 2, 0 };
const PositionInt left_narrow = { 3, 0 };
const PositionInt left_wide = { 4, 0 };
const PositionInt up_wide = { 5, 0 };
const PositionInt up_narrow = { 6, 0 };
const PositionInt down_wide = { 7, 0 };
const PositionInt down_narrow = { 8, 0 };
const PositionInt down_animation[4]{ down_wide, down_narrow, closed, down_narrow };
const PositionInt left_animation[4]{ left_wide, left_narrow, closed, left_narrow };
const PositionInt right_animation[4]{ right_wide, right_narrow, closed, right_narrow };
const PositionInt up_animation[4]{ up_wide, up_narrow, closed, up_narrow };
};