C++ Project 2016-2017: Arkanoid
Public Member Functions | Protected Attributes | List of all members
arkanoid::Entity Class Referenceabstract

An Entity represents an "object" (like Player, Ball, Block, ...) in the game World. More...

#include <entity.h>

Inheritance diagram for arkanoid::Entity:
arkanoid::Ball arkanoid::Player arkanoid::Wall arkanoid::World arkanoidSFML::BallSFML arkanoidSFML::PlayerSFML arkanoid::Block arkanoidSFML::WallSFML arkanoid::BallSpeedBlock arkanoid::InvisBlock arkanoid::PlayerSpeedBlock arkanoidSFML::BlockSFML arkanoidSFML::BallSpeedBlockSFML arkanoidSFML::InvisBlockSFML arkanoidSFML::PlayerSpeedBlockSFML arkanoidSFML::BallSpeedBlockSFML arkanoidSFML::InvisBlockSFML arkanoidSFML::PlayerSpeedBlockSFML

Public Member Functions

 Entity ()
 
 Entity (double x, double y, pair< double, double > newSize=make_pair(1.0, 1.0))
 
virtual ~Entity ()
 
virtual void update ()=0
 
virtual void draw () const =0
 
Vector2D getPosition () const
 
void setPosition (double x, double y)
 
void setPosition (const Vector2D &vector)
 
void setSize (pair< double, double > newSize)
 
pair< double, double > getSize () const
 
bool collidesWith (const Entity &other) const
 

Protected Attributes

Vector2D position
 The current position of the Entity (in the 9x7 grid).
 
pair< double, double > size
 The size (width and height respectively) of the Entity.
 

Detailed Description

An Entity represents an "object" (like Player, Ball, Block, ...) in the game World.

Definition at line 15 of file entity.h.

Constructor & Destructor Documentation

◆ Entity() [1/2]

arkanoid::Entity::Entity ( )

Default Constructor.

Initialise the Entity at origin ([0, 0]) in the World.

Definition at line 13 of file entity.cpp.

◆ Entity() [2/2]

arkanoid::Entity::Entity ( double  x,
double  y,
pair< double, double >  newSize = make_pair(1.0, 1.0) 
)

Constructor.

Initialise the Entity at a specific position in the World.

Parameters
xThe x position of the Entity.
yThe y position of the Entity.
newSize(optional) The size (width and height respectively) of the Entity.

Definition at line 15 of file entity.cpp.

◆ ~Entity()

virtual arkanoid::Entity::~Entity ( )
inlinevirtual

Destructor.

Definition at line 43 of file entity.h.

Member Function Documentation

◆ collidesWith()

bool arkanoid::Entity::collidesWith ( const Entity other) const

Checks if this Entity is intersecting with another Entity.

Returns
True if intersecting, otherwise false.

Definition at line 38 of file entity.cpp.

◆ draw()

virtual void arkanoid::Entity::draw ( ) const
pure virtual

◆ getPosition()

Vector2D arkanoid::Entity::getPosition ( ) const

Get the current position of the Entity.

Returns
The current position of the Entity (in a Vector2D).

Definition at line 17 of file entity.cpp.

◆ getSize()

pair< double, double > arkanoid::Entity::getSize ( ) const

Get the size of the Entity.

Returns
The size of the Entity.

Definition at line 34 of file entity.cpp.

◆ setPosition() [1/2]

void arkanoid::Entity::setPosition ( double  x,
double  y 
)

Set the current position of the Entity.

Parameters
xThe nex 'x' component of the Entity.
yThe nex 'y' component of the Entity.

Definition at line 21 of file entity.cpp.

◆ setPosition() [2/2]

void arkanoid::Entity::setPosition ( const Vector2D vector)

Set the current position of the Entity.

Parameters
vectorThe vector who this Entity will be equal to.

Definition at line 26 of file entity.cpp.

◆ setSize()

void arkanoid::Entity::setSize ( pair< double, double >  newSize)

Set the size of the Entity.

Parameters
newSizeThe new size of the Entity.

Definition at line 30 of file entity.cpp.

◆ update()

virtual void arkanoid::Entity::update ( )
pure virtual

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