Dauphine  0.1
A platforming/stealth game in a medieval fantasy setting, developed with SDL2.
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
Entity Class Referenceabstract

Base class for all game objects (entities). More...

#include <Entity.h>

Public Member Functions

virtual ~Entity ()
 The destructor.
 
virtual void update (const double dt_)=0
 Updates the entity. More...
 
virtual void render (const double cameraX_, const double cameraY_)=0
 Renders the entity. More...
 
unsigned int getWidth ()
 
unsigned int getHeight ()
 
SDL_Rect & getAnimationClip ()
 

Public Attributes

double x
 The position in the x axis. More...
 
double y
 The position in the y axis. More...
 
bool isRight
 The direction in the x axis. More...
 

Protected Member Functions

 Entity (const double x_, const double y_, Sprite *const sprite_)
 The constructor. More...
 

Protected Attributes

Spritesprite
 The Sprite attributed to the entity. More...
 
unsigned int width
 The entitys width, from its sprite. More...
 
unsigned int height
 The entitys height, from its sprite. More...
 
SDL_Rect animationClip
 The current clip on the spritesheet, to determine animation. More...
 
SDL_Rect boundingBox
 

Detailed Description

Base class for all game objects (entities).

The entity contains the (x,y) position, width and height, and a sprite.

Constructor & Destructor Documentation

Entity::Entity ( const double  x_,
const double  y_,
Sprite *const  sprite_ 
)
protected

The constructor.

Initializes all the attributes.

Parameters
x_: position in x axis.
y_: position in y axis.
sprite_: which sprite to use.

Member Function Documentation

SDL_Rect & Entity::getAnimationClip ( )
Returns
The Entity::animationClip.
unsigned int Entity::getHeight ( )
Returns
The Entity height.
unsigned int Entity::getWidth ( )
Returns
The Entity width.
virtual void Entity::render ( const double  cameraX_,
const double  cameraY_ 
)
pure virtual

Renders the entity.

Pure virtual function. Purpose is to copy the entity's texture onto the renderer.

Note
Usually just calls the render method from the Sprite class.
Parameters
cameraX_: The x position of the camera.
cameraY_: The y position of the camera.

Implemented in Player, Enemy, BombPotion, Text, and Crosshair.

virtual void Entity::update ( const double  dt_)
pure virtual

Updates the entity.

Pure virtual function. Purpose is to update whatever is necessary, relative to the entity.

Parameters
dt_: Delta time. Time elapsed between one frame and the other.

Implemented in Player, Enemy, BombPotion, Text, and Crosshair.

Member Data Documentation

SDL_Rect Entity::animationClip
protected

The current clip on the spritesheet, to determine animation.

unsigned int Entity::height
protected

The entitys height, from its sprite.

bool Entity::isRight

The direction in the x axis.

Sprite* Entity::sprite
protected

The Sprite attributed to the entity.

unsigned int Entity::width
protected

The entitys width, from its sprite.

double Entity::x

The position in the x axis.

double Entity::y

The position in the y axis.


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