Pac-Man
|
A class that represents ghost in the game, it solves common problems of all ghosts in its methods. More...
#include <CGhost.h>
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, SMainEntityInfo > | getMainEntityInfo () const |
Returns info in category SMainEntityInfo. More... | |
![]() | |
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... | |
![]() | |
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 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 | |
![]() | |
CMap::CMapCoordinates | location_ |
Additional Inherited Members | |
![]() | |
enum | EDirection { DIRECTION_LEFT, DIRECTION_UP, DIRECTION_RIGHT, DIRECTION_DOWN, NO_DIRECTION } |
Enum of all directions that can moving object go in. | |
A class that represents ghost in the game, it solves common problems of all ghosts in its methods.
CGhost::CGhost | ( | const CMap & | map, |
const SCoordinates & | homeLocation | ||
) |
It initializes new ghost.
[in] | map | map in which the ghost will be |
[in] | homeLocation | start and home location for the ghost |
bool CGhost::canBeKilled | ( | const CGameInfo & | gameInfo | ) | const |
Returns information whether the ghost can be killed.
[in] | gameInfo | info is needed for deciding if ghost can be killed |
bool CGhost::canKill | ( | const CGameInfo & | gameInfo | ) | const |
Returns information whether the ghost can kill player.
[in] | gameInfo | info is needed for deciding if ghost can kill |
|
staticprotected |
Decides if ghost can step on given map object.
[in] | object | the object going to be confirmed if the ghost can step on it |
|
protected |
Decides what would be the direction which would be chosen for next move.
[in] | map | map in which the ghost is |
[in] | targetCoords | are the coordinates of the target of the ghost |
|
virtual |
Returns info in category SMainEntityInfo.
Reimplemented in CRedGhost, and CCoronaGhost.
|
pure virtual |
Returns basic info about the ghost.
[in] | gameInfo | info which is used for game where is actual ghost |
Implemented in CPurpleGhost, CSienaGhost, CTurquoiseGhost, CRedGhost, and CCoronaGhost.
|
protectedpure virtual |
Returns coordinates of target, defined by specific ghost behaviour.
[in] | map | map in which the ghost is |
[in] | mainEntitiesInfo | information about main entities in the game |
[in] | gameInfo | info which is used for game where is actual ghost |
Implemented in CPurpleGhost, CSienaGhost, CTurquoiseGhost, CCoronaGhost, and CRedGhost.
void CGhost::killed | ( | const CMap & | map, |
uint32_t | time | ||
) |
The method by which ghost is informed about his death.
[in] | map | map in which the ghost is |
[in] | time | time from start of the game |
|
virtual |
It does general CGhost move behaviour.
[in] | map | map in which the ghost is |
[in] | mainEntitiesInfo | information about main entities in the game |
[in] | time | time from start of the game |
Reimplemented in CPurpleGhost, CSienaGhost, and CTurquoiseGhost.
void CGhost::reset | ( | const CMap & | map | ) |
Method for resetting the ghost to the beginning state.
[in] | map | map in which the ghost is |