Pacman Torben Petré
Loading...
Searching...
No Matches
EntityView Class Reference

#include <EntityView.h>

Inheritance diagram for EntityView:
Collaboration diagram for EntityView:

Public Member Functions

 EntityView (const std::shared_ptr< logic::EntityModel > &model, float frameDuration)
bool shouldDelete () const
size_t getFrameIndex (float dt, size_t frameLimit)
 Calculates the current frameIndex based on the elapsed time.
virtual void resized ()
 Determines how the sprites should react when the Screen dimension changes.
virtual void render ()
 Determines what needs to happen to sprites when they should be rendered.
Public Member Functions inherited from logic::Observer
virtual ~Observer ()=default
virtual void update (Events event)=0
 Update method that is called by the observed Subjects.

Protected Attributes

std::shared_ptr< logic::EntityModelmodel
sf::Sprite sprite
bool markedForDeletion = false
float frameDuration
float elapsedTime = 0
size_t frameIndex = 0

Constructor & Destructor Documentation

◆ EntityView()

EntityView::EntityView ( const std::shared_ptr< logic::EntityModel > & model,
float frameDuration )
explicit

Abstract EntityView class. Initiates sprite offset to 0.8, 0.8 as that is centered on my 16x16 pixel representation.

Parameters
modelReference model
frameDurationLength of a single frame

Member Function Documentation

◆ getFrameIndex()

size_t EntityView::getFrameIndex ( float dt,
size_t frameLimit )
nodiscard

Calculates the current frameIndex based on the elapsed time.

Parameters
dtStopwatch time.
frameLimitMaximum frame index.
Returns
Current frame index.

◆ render()

void EntityView::render ( )
virtual

Determines what needs to happen to sprites when they should be rendered.

Reimplemented in GhostView, and PacmanView.

◆ resized()

void EntityView::resized ( )
virtual

Determines how the sprites should react when the Screen dimension changes.

Reimplemented in PacmanView.

◆ shouldDelete()

bool EntityView::shouldDelete ( ) const
nodiscard
Returns
Whether Entity is marked for deletion.

Member Data Documentation

◆ elapsedTime

float EntityView::elapsedTime = 0
protected

◆ frameDuration

float EntityView::frameDuration
protected

◆ frameIndex

size_t EntityView::frameIndex = 0
protected

◆ markedForDeletion

bool EntityView::markedForDeletion = false
protected

◆ model

std::shared_ptr<logic::EntityModel> EntityView::model
protected

◆ sprite

sf::Sprite EntityView::sprite
protected

The documentation for this class was generated from the following files: