GameEngine::GameObject Class Reference

#include <GameObject.h>

Inheritance diagram for GameEngine::GameObject:

Inheritance graph
Collaboration diagram for GameEngine::GameObject:

Collaboration graph
List of all members.

Detailed Description

Base class for game objects. A game object is made up of GameObjectComponents which represent the object in many different ways. E.g A rendering component to display the object, a physics component to simulate it with the physics engine, an AI component to control the object with artificial intelligence etc etc

Definition at line 46 of file GameObject.h.

Public Member Functions

 GameObject (char const *const objectType, const std::string &objectID, GameState *gameState, int timeToLive=-1)
 GameObject (const GameObject &o)
virtual ~GameObject ()
void addComponent (boost::shared_ptr< GameObjectComponent > component)
void removeComponent (boost::shared_ptr< GameObjectComponent > component)
bool init ()
void destroy ()
void update (const double &dt)
virtual bool handleEvent (const Event &event)
boost::shared_ptr< GameObjectgetSharedToThis ()
const std::string & getID () const
const GameObjectTypegetType () const
GameState *const getGameState () const

Protected Attributes

GameObjectType mType
std::string mID
GameObjectComponentList mComponents
double mLifeTime
double mTimeLived

Constructor & Destructor Documentation

GameEngine::GameObject::GameObject ( char const *const  objectType,
const std::string &  objectID,
GameState gameState,
int  timeToLive = -1 


objectType The type of the object
objectID A unique ID for the object
gameState The game state the object belongs to
timeToLive The length of time the object should live for (0 = infinity)

Definition at line 25 of file GameObject.cpp.

GameEngine::GameObject::GameObject ( const GameObject o  ) 

Copy constructor

o The game object to create a copy of

GameEngine::GameObject::~GameObject (  )  [virtual]


Definition at line 39 of file GameObject.cpp.

Member Function Documentation

void GameEngine::GameObject::addComponent ( boost::shared_ptr< GameObjectComponent component  ) 

Add a component to this object

component The component to add

Definition at line 45 of file GameObject.cpp.

void GameEngine::GameObject::removeComponent ( boost::shared_ptr< GameObjectComponent component  ) 

Remove a component from this object

component The component to remove

Definition at line 59 of file GameObject.cpp.

bool GameEngine::GameObject::init (  )  [virtual]

Initialise the object and its components

true if object was initialised successfully, false otherwise

Reimplemented from GameEngine::Process.

Definition at line 66 of file GameObject.cpp.

void GameEngine::GameObject::destroy (  )  [virtual]

Destroy the object and its components

Reimplemented from GameEngine::Process.

Definition at line 84 of file GameObject.cpp.

void GameEngine::GameObject::update ( const double &  dt  )  [virtual]

Update the object and its components

dt Time since last frame was renedered

Reimplemented from GameEngine::Process.

Definition at line 96 of file GameObject.cpp.

virtual bool GameEngine::GameObject::handleEvent ( const Event event  )  [inline, virtual]

Handle an event the object has listened for

event The event to handle
true if the event is consumed, false otherwise

Implements GameEngine::IEventListener.

Definition at line 112 of file GameObject.h.

boost::shared_ptr<GameObject> GameEngine::GameObject::getSharedToThis (  )  [inline]

Get a shared_ptr to this object

A shared_ptr to this object

Definition at line 120 of file GameObject.h.

const std::string& GameEngine::GameObject::getID (  )  const [inline]

Get this objects ID

The ID of this object

Definition at line 126 of file GameObject.h.

const GameObjectType& GameEngine::GameObject::getType (  )  const [inline]

Get the type of this object

The GameObjectType of this object

Definition at line 132 of file GameObject.h.

GameState* const GameEngine::GameObject::getGameState (  )  const [inline]

Get the game state that this object belongs to

A pointer to the game state this object belongs to

Definition at line 138 of file GameObject.h.

Member Data Documentation

GameObjectType GameEngine::GameObject::mType [protected]

Definition at line 142 of file GameObject.h.

std::string GameEngine::GameObject::mID [protected]

Definition at line 143 of file GameObject.h.

GameState* GameEngine::GameObject::mGameState [protected]

Definition at line 144 of file GameObject.h.

GameObjectComponentList GameEngine::GameObject::mComponents [protected]

Definition at line 146 of file GameObject.h.

double GameEngine::GameObject::mLifeTime [protected]

Definition at line 148 of file GameObject.h.

double GameEngine::GameObject::mTimeLived [protected]

Definition at line 149 of file GameObject.h.

The documentation for this class was generated from the following files:
Generated on Thu Apr 19 09:48:45 2007 for GameEngine by  doxygen 1.5.2