Pacman Torben Petré
Loading...
Searching...
No Matches
PacmanView.h
Go to the documentation of this file.
1#ifndef PACMANVIEW_H
2#define PACMANVIEW_H
3
4#include <unordered_map>
5
7#include "EntityView.h"
8
9
10class PacmanView final : public EntityView {
11public:
16 explicit PacmanView(const std::shared_ptr<logic::PacmanModel> &model);
17
21 void resized() override;
22
26 void render() override;
27
28private:
33 void update(logic::Events event) override;
34
35 // I store the PacmanModel in the view insteawd of dynamic casting the
36 // generic model used in the base EntityView class to use PacmanModel
37 // specific functions.
38 std::shared_ptr<logic::PacmanModel> pacman;
39
40 bool dying = false;
41 // When the model did not move, the current frame of the Pacman walking
42 // animation will not update until this boolean changes, effectively
43 // freezing Pacman.
44 bool moving = true;
45
46 std::unordered_map<int, std::vector<sf::IntRect>> animations{};
47 int animationIndex;
48
49 sf::Sprite directionSprite;
50};
51
52
53
54#endif //PACMANVIEW_H
std::shared_ptr< logic::EntityModel > model
Definition EntityView.h:46
EntityView(const std::shared_ptr< logic::EntityModel > &model, float frameDuration)
Definition EntityView.cpp:6
PacmanView(const std::shared_ptr< logic::PacmanModel > &model)
PacmanView renders & animates Pacman.
Definition PacmanView.cpp:8
void render() override
Renders the Pacman sprite and the Pacman direction indicator.
Definition PacmanView.cpp:89
void resized() override
Resizes the Pacman sprite.
Definition PacmanView.cpp:80
Events
Definition Observer.h:14