Pacman Torben Petré
Loading...
Searching...
No Matches
logic::PacmanModel Class Referencefinal

#include <PacmanModel.h>

Inheritance diagram for logic::PacmanModel:
Collaboration diagram for logic::PacmanModel:

Public Member Functions

 PacmanModel (float normalizedX, float normalizedY, float mapWidth, float mapHeight)
Moves getNextDirection () const
 Pacman works with input buffering, this function returns the buffered direction.
bool isMoving () const
void setNextDirection (const Moves &move)
 Update the direction of Pacman. This move is buffed if Pacman can not currently move in this direction. The moment it can, it will.
void move (const World &world, float dt) override
 This function is to be called inside the World loop. Moves Pacman in its current direction. Will change that direction if possible.
void respawn () override
 Tell Pacman to respawn. It will go back to its spawnpoint and change everything back to their default values.
Public Member Functions inherited from logic::MovingEntityModel
 MovingEntityModel (float normalizedX, float normalizedY, float mapWidth, float mapHeight, float speed)
 Subclass of EntityModel to be used for any moving entity.
Moves getDirection () const
 Get the direction the entity is currently moving in.
int getGridX () const
int getGridY () const
Public Member Functions inherited from logic::EntityModel
 EntityModel (float normalizedX, float normalizedY)
 Base class for entities.
 ~EntityModel () override=default
float getX () const
float getY () const
Public Member Functions inherited from logic::Subject
virtual ~Subject ()=default
void attach (const std::shared_ptr< Observer > &observer)
 Attaches an observer to this Subject.
void notify (Events event)
 Call the Observer update function with the provided event.

Additional Inherited Members

Protected Member Functions inherited from logic::MovingEntityModel
void normalizeTarget ()
 Normalizes the grid coordinates and stores these values in as target coordinates. Moving entities strive towards normalized grid coordinates.
Protected Attributes inherited from logic::MovingEntityModel
float mapWidth
float mapHeight
float spawnX
float spawnY
int gridY
int gridX
float targetX
float targetY
Moves direction = Moves::RIGHT
float speed
Protected Attributes inherited from logic::EntityModel
float x
float y
Protected Attributes inherited from logic::Subject
std::list< std::weak_ptr< Observer > > observers

Constructor & Destructor Documentation

◆ PacmanModel()

PacmanModel::PacmanModel ( float normalizedX,
float normalizedY,
float mapWidth,
float mapHeight )
Parameters
normalizedXNormalized X spawn coordinate
normalizedYNormalized Y spawn coordinate
mapWidthWidth of map (in tiles)
mapHeightWidth of map (in tiles)

Member Function Documentation

◆ getNextDirection()

Moves PacmanModel::getNextDirection ( ) const
nodiscard

Pacman works with input buffering, this function returns the buffered direction.

Returns
Buffered direction

◆ isMoving()

bool PacmanModel::isMoving ( ) const
nodiscard
Returns
Whether Pacman is moving

◆ move()

void PacmanModel::move ( const World & world,
float dt )
overridevirtual

This function is to be called inside the World loop. Moves Pacman in its current direction. Will change that direction if possible.

Parameters
worldWorld
dtDeltatime since last call

Implements logic::MovingEntityModel.

◆ respawn()

void PacmanModel::respawn ( )
overridevirtual

Tell Pacman to respawn. It will go back to its spawnpoint and change everything back to their default values.

Implements logic::MovingEntityModel.

◆ setNextDirection()

void PacmanModel::setNextDirection ( const Moves & move)

Update the direction of Pacman. This move is buffed if Pacman can not currently move in this direction. The moment it can, it will.

Parameters
moveDirection

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