Pacman Torben Petré
Loading...
Searching...
No Matches
EntityView.h
Go to the documentation of this file.
1#ifndef ENTITYVIEW_H
2#define ENTITYVIEW_H
3
4#include <SFML/Graphics/Sprite.hpp>
5
7
8
9class EntityView : public logic::Observer {
10public:
17 explicit EntityView(const std::shared_ptr<logic::EntityModel>& model, float frameDuration);
18
22 [[nodiscard]] bool shouldDelete() const;
23
30 [[nodiscard]] size_t getFrameIndex(float dt, size_t frameLimit);
31
32
37 virtual void resized();
38
43 virtual void render();
44
45protected:
46 std::shared_ptr<logic::EntityModel> model;
47 sf::Sprite sprite;
48
49 bool markedForDeletion = false;
50
51 // Animation relatded variables
53 float elapsedTime = 0;
54 size_t frameIndex = 0;
55};
56
57
58
59#endif //ENTITYVIEW_H
bool markedForDeletion
Definition EntityView.h:49
sf::Sprite sprite
Definition EntityView.h:47
bool shouldDelete() const
Definition EntityView.cpp:27
float elapsedTime
Definition EntityView.h:53
size_t frameIndex
Definition EntityView.h:54
virtual void resized()
Determines how the sprites should react when the Screen dimension changes.
Definition EntityView.cpp:11
size_t getFrameIndex(float dt, size_t frameLimit)
Calculates the current frameIndex based on the elapsed time.
Definition EntityView.cpp:31
std::shared_ptr< logic::EntityModel > model
Definition EntityView.h:46
EntityView(const std::shared_ptr< logic::EntityModel > &model, float frameDuration)
Definition EntityView.cpp:6
virtual void render()
Determines what needs to happen to sprites when they should be rendered.
Definition EntityView.cpp:18
float frameDuration
Definition EntityView.h:52
Definition Observer.h:16