Pac-Man
Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
CGhost Class Referenceabstract

A class that represents ghost in the game, it solves common problems of all ghosts in its methods. More...

#include <CGhost.h>

Inheritance diagram for CGhost:
Inheritance graph
Collaboration diagram for CGhost:
Collaboration graph

Public Member Functions

 CGhost (const CMap &map, const SCoordinates &homeLocation)
 It initializes new ghost. More...
 
virtual SCoordinates move (const CMap &map, const SMainEntitiesInfo &mainEntitiesInfo, const CGameInfo &gameInfo)
 It does general CGhost move behaviour. More...
 
void reset (const CMap &map)
 Method for resetting the ghost to the beginning state. More...
 
void killed (const CMap &map, uint32_t time)
 The method by which ghost is informed about his death. More...
 
bool canKill (const CGameInfo &gameInfo) const
 Returns information whether the ghost can kill player. More...
 
bool canBeKilled (const CGameInfo &gameInfo) const
 Returns information whether the ghost can be killed. More...
 
virtual SGameObjectInfo getObjectInfo (const CGameInfo &gameInfo) const =0
 Returns basic info about the ghost. More...
 
virtual pair< bool, SMainEntityInfogetMainEntityInfo () const
 Returns info in category SMainEntityInfo. More...
 
- Public Member Functions inherited from CMovingObject
 CMovingObject (const CMap &map, const SCoordinates &location)
 A constructor of the moving object. More...
 
bool isOnIntersection () const
 checks whether is object on intersection More...
 

Protected Member Functions

EDirection generalGhostDecision (const CMap &map, const SCoordinates &targetCoords)
 Decides what would be the direction which would be chosen for next move. More...
 
virtual SCoordinates getTargetCoordinates (const CMap &map, const SMainEntitiesInfo &mainEntitiesInfo, const CGameInfo &gameInfo)=0
 Returns coordinates of target, defined by specific ghost behaviour. More...
 
- Protected Member Functions inherited from CMovingObject
void reset (const CMap &map, SCoordinates &coordinates)
 Method resets the moving object to initial state. More...
 
float innerGridMove (const SCoordinates &moveVector)
 Method that do the move in the space. More...
 
EGameObject getTileInDirection (const CMap &map, EDirection direction) const
 Method returns neighbour tile from map in given direction. More...
 

Static Protected Member Functions

static bool canStepOn (EGameObject &object)
 Decides if ghost can step on given map object. More...
 
- Static Protected Member Functions inherited from CMovingObject
static EDirection getOpositeDirectionTo (EDirection directon)
 Method returns opposite direction to given direction. More...
 
static SCoordinates getMoveVector (EDirection direction, float speed)
 Method returns move vector constructed from given arguments. More...
 

Protected Attributes

SCoordinates homeLocation_
 home location of the ghost
 
uint32_t timeOfDeath_ = 0
 time when the ghost was killed
 
bool alive_
 information if is the ghost alive
 
bool randomTileSet_
 information if a new random tile was set
 
SCoordinates randomTile_
 random tile is there for random target of the ghost
 
EDirection goingFromDirection_
 holds the direction from which is the ghost going
 
- Protected Attributes inherited from CMovingObject
CMap::CMapCoordinates location_
 

Additional Inherited Members

- Public Types inherited from CMovingObject
enum  EDirection {
  DIRECTION_LEFT, DIRECTION_UP, DIRECTION_RIGHT, DIRECTION_DOWN,
  NO_DIRECTION
}
 Enum of all directions that can moving object go in.
 

Detailed Description

A class that represents ghost in the game, it solves common problems of all ghosts in its methods.

Constructor & Destructor Documentation

◆ CGhost()

CGhost::CGhost ( const CMap map,
const SCoordinates homeLocation 
)

It initializes new ghost.

Parameters
[in]mapmap in which the ghost will be
[in]homeLocationstart and home location for the ghost

Member Function Documentation

◆ canBeKilled()

bool CGhost::canBeKilled ( const CGameInfo gameInfo) const

Returns information whether the ghost can be killed.

Parameters
[in]gameInfoinfo is needed for deciding if ghost can be killed
Returns
if can be killed

◆ canKill()

bool CGhost::canKill ( const CGameInfo gameInfo) const

Returns information whether the ghost can kill player.

Parameters
[in]gameInfoinfo is needed for deciding if ghost can kill
Returns
if can kill

◆ canStepOn()

bool CGhost::canStepOn ( EGameObject &  object)
staticprotected

Decides if ghost can step on given map object.

Parameters
[in]objectthe object going to be confirmed if the ghost can step on it
Returns
if the ghost can step on such a object

◆ generalGhostDecision()

CMovingObject::EDirection CGhost::generalGhostDecision ( const CMap map,
const SCoordinates targetCoords 
)
protected

Decides what would be the direction which would be chosen for next move.

Parameters
[in]mapmap in which the ghost is
[in]targetCoordsare the coordinates of the target of the ghost
Returns
direction that is the best possible for getting to the target

◆ getMainEntityInfo()

pair< bool, SMainEntityInfo > CGhost::getMainEntityInfo ( ) const
virtual

Returns info in category SMainEntityInfo.

Returns
pair with a bool if the entity is a main entity and if is the second return value (info in category SMainEntityInfo) valid

Reimplemented in CRedGhost, and CCoronaGhost.

◆ getObjectInfo()

virtual SGameObjectInfo CGhost::getObjectInfo ( const CGameInfo gameInfo) const
pure virtual

Returns basic info about the ghost.

Parameters
[in]gameInfoinfo which is used for game where is actual ghost
Returns
the info about the game object (ghost)

Implemented in CPurpleGhost, CSienaGhost, CTurquoiseGhost, CRedGhost, and CCoronaGhost.

◆ getTargetCoordinates()

virtual SCoordinates CGhost::getTargetCoordinates ( const CMap map,
const SMainEntitiesInfo mainEntitiesInfo,
const CGameInfo gameInfo 
)
protectedpure virtual

Returns coordinates of target, defined by specific ghost behaviour.

Parameters
[in]mapmap in which the ghost is
[in]mainEntitiesInfoinformation about main entities in the game
[in]gameInfoinfo which is used for game where is actual ghost
Returns
the coordinates of the target

Implemented in CPurpleGhost, CSienaGhost, CTurquoiseGhost, CCoronaGhost, and CRedGhost.

◆ killed()

void CGhost::killed ( const CMap map,
uint32_t  time 
)

The method by which ghost is informed about his death.

Parameters
[in]mapmap in which the ghost is
[in]timetime from start of the game

◆ move()

SCoordinates CGhost::move ( const CMap map,
const SMainEntitiesInfo mainEntitiesInfo,
const CGameInfo gameInfo 
)
virtual

It does general CGhost move behaviour.

Parameters
[in]mapmap in which the ghost is
[in]mainEntitiesInfoinformation about main entities in the game
[in]timetime from start of the game
Returns
coordinates where the ghost currently is after the move

Reimplemented in CPurpleGhost, CSienaGhost, and CTurquoiseGhost.

◆ reset()

void CGhost::reset ( const CMap map)

Method for resetting the ghost to the beginning state.

Parameters
[in]mapmap in which the ghost is

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