Gamedev Framework (gf)  0.3.0
A C++11 framework for 2D games
Public Member Functions | List of all members
gf::Entity Class Reference

A game entity. More...

#include <gf/Entity.h>

Public Member Functions

 Entity (int priority=0)
 Contructor. More...
 
virtual ~Entity ()
 Destructor. More...
 
int getPriority () const
 Get the priority of the entity. More...
 
virtual void update (float dt)
 Update the entity's state. More...
 
virtual void render (RenderTarget &target)
 Render the entity. More...
 
Entity liveness
bool isAlive () const
 Check if the entity is alive. More...
 
void setAlive ()
 Set the entity alive (again) More...
 
void kill ()
 Kill an entity. More...
 

Detailed Description

A game entity.

gf::Entity represents a game entity, i.e. an object that is updated and rendered every frame.

Entities are ordered by priority when they are renderer, with lower priority being rendered first and higher priority being renderered last. The default priority is \( 0 \).

Entities can become dead, in which case they are neither updated nor rendered anymore.

Entities can be grouped in an gf::EntityContainer.

See also
gf::EntityContainer

Constructor & Destructor Documentation

gf::Entity::Entity ( int  priority = 0)
inline

Contructor.

By default, the entity is alive.

Parameters
prioritythe priority of the entity (default: 0)
virtual gf::Entity::~Entity ( )
virtual

Destructor.

Member Function Documentation

int gf::Entity::getPriority ( ) const
inline

Get the priority of the entity.

Returns
The priority
bool gf::Entity::isAlive ( ) const
inline

Check if the entity is alive.

Returns
True if the entity is alive
See also
setAlive(), kill();
void gf::Entity::kill ( )
inline

Kill an entity.

This function kills the entity. After being killed, the entity must not be updated or rendered.

virtual void gf::Entity::render ( RenderTarget target)
virtual

Render the entity.

Parameters
targetThe render target
See also
gf::EntityContainer::render()
void gf::Entity::setAlive ( )
inline

Set the entity alive (again)

This function can be called to revive an entity that has been killed.

virtual void gf::Entity::update ( float  dt)
virtual

Update the entity's state.

Entities are updated each frame. The time between two frames is given as a parameter to help in the update. This time is in seconds.

Parameters
dtThe time (in seconds) since the last update
See also
gf::EntityContainer::update()