Base class for all entities in scenes. More...
#include <GameObject.h>
Public Member Functions | |
GameObject () | |
Constructor. More... | |
~GameObject () | |
Destructor. More... | |
virtual void | processInput (SDL_Event e) |
Virtual method. Process user input. More... | |
virtual void | Update (int x, int y, int *params) |
Update the position of something. More... | |
virtual void | Render (SDL_Renderer *ren) |
Render the gameobject to the active viewport. More... | |
void | removeComponent (std::string key) |
Remove a component in this gameobject. More... | |
void | addComponent (std::string key, Component *component) |
Add a component in this gameobject. More... | |
Component * | getComponent (std::string key) |
Get an reference of a component. More... | |
void | setActive (bool newState) |
activate / deactivate game object. inactive object won't be updated and rendered More... | |
bool | isActive () |
Get the state of the game. More... | |
int | getID () |
Get the unique id of the gameobject. More... | |
Static Public Attributes | |
static int | idCounter = 0 |
Protected Attributes | |
std::map< std::string, Component * > | m_components |
Store all the game components in a map. More... | |
bool | objState |
deactivated objects won't get updated/rendered More... | |
int | id |
the unique id More... | |
Base class for all entities in scenes.
|
inline |
Constructor.
|
inline |
Destructor.
|
inline |
Add a component in this gameobject.
key | The name of the component. |
component | The reference of the component. |
|
inline |
Get an reference of a component.
key | The name of the component. |
|
inline |
Get the unique id of the gameobject.
|
inline |
Get the state of the game.
|
inlinevirtual |
Virtual method. Process user input.
e | A SDL_Event that contains structures for the different event types. |
Reimplemented in TileMapEditor, Player, Menu, and EnemyObject.
|
inline |
Remove a component in this gameobject.
key | The name of the component. |
|
inlinevirtual |
Render the gameobject to the active viewport.
ren | Reference to SDL renderer. |
Reimplemented in TileMapEditor, Player, Menu, Map, and EnemyObject.
|
inline |
activate / deactivate game object. inactive object won't be updated and rendered
|
inlinevirtual |
Update the position of something.
x | The x location of something. |
y | The x location of something. |
params | An int array stores additional data. |
Reimplemented in TileMapEditor, Player, Menu, Map, and EnemyObject.
|
protected |
the unique id
|
static |
|
protected |
Store all the game components in a map.
|
protected |
deactivated objects won't get updated/rendered