Pac-Man
Public Types | Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
CMovingObject Class Reference

A class that is ancestor of all moving objects in a game. More...

#include <CMovingObject.h>

Inheritance diagram for CMovingObject:
Inheritance graph
Collaboration diagram for CMovingObject:
Collaboration graph

Public Types

enum  EDirection {
  DIRECTION_LEFT, DIRECTION_UP, DIRECTION_RIGHT, DIRECTION_DOWN,
  NO_DIRECTION
}
 Enum of all directions that can moving object go in.
 

Public Member Functions

 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

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 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

CMap::CMapCoordinates location_
 

Detailed Description

A class that is ancestor of all moving objects in a game.

Constructor & Destructor Documentation

◆ CMovingObject()

CMovingObject::CMovingObject ( const CMap map,
const SCoordinates location 
)

A constructor of the moving object.

Parameters
[in]mapmap where the moving object is
[in]locationthe location where the moving object will be after creation

Member Function Documentation

◆ getMoveVector()

SCoordinates CMovingObject::getMoveVector ( CMovingObject::EDirection  direction,
float  speed 
)
staticprotected

Method returns move vector constructed from given arguments.

Parameters
[in]directiondirection in which the move vector will be constructed
[in]speeddetermines how big will be the move vector
Returns
the move vector is returned in form of coordinates ( vector goes from zero origin to these coordinates)

◆ getOpositeDirectionTo()

CMovingObject::EDirection CMovingObject::getOpositeDirectionTo ( EDirection  directon)
staticprotected

Method returns opposite direction to given direction.

Parameters
[in]directoninput direction
Returns
opposite direction to the input direction

◆ getTileInDirection()

EGameObject CMovingObject::getTileInDirection ( const CMap map,
CMovingObject::EDirection  direction 
) const
protected

Method returns neighbour tile from map in given direction.

Parameters
[in]mapmap where the moving object is
[in]directiondetermines in which direction the tile will be
Returns
the neighbour tile in the given direction

◆ innerGridMove()

float CMovingObject::innerGridMove ( const SCoordinates moveVector)
protected

Method that do the move in the space.

Parameters
[in]moveVectorvector that will move the object (x or y must be 0 in the vector)
Returns
how much distance still wasnt used

◆ isOnIntersection()

bool CMovingObject::isOnIntersection ( ) const

checks whether is object on intersection

Returns
true if is on intersection (coordinates with whole numbers, for example {32.0, 25.0})

◆ reset()

void CMovingObject::reset ( const CMap map,
SCoordinates coordinates 
)
protected

Method resets the moving object to initial state.

Parameters
[in]mapmap where the moving object is
[in]coordinatesnew location after the rest

Member Data Documentation

◆ location_

CMap::CMapCoordinates CMovingObject::location_
protected

location of the moving object


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