Polygon Dash
Loading...
Searching...
No Matches
GameObject Class Reference

Represents an in-game entity. More...

Public Member Functions

 this (string name)
 Create a new GameObject.
 
string GetName () const
 Get the name of the GameObject.
 
size_t GetID () const
 Get the ID of the GameObject.
 
bool IsActive ()
 Whether the GameObject is active.
 
bool IsEnabled ()
 Whether the GameObject is enabled.
 
void SetActive (bool active)
 Set whether the GameObject is active or not.
 
void SetEnabled (bool enabled)
 Set whether the GameObject is enabled or not.
 
void Update ()
 Update the state of the GameObject's components and scripts.
 
void Render (SDL_Renderer *renderer, SDL_Rect *camera)
 Render the GameObject's components and scripts.
 
IComponent GetComponent (ComponentType type)
 Get a specific component of the GameObject.
 
void AddComponent (ComponentType T)(IComponent component)
 Add a new component to the GameObject.
 
ComponentScript GetScript (ScriptType type)
 Get a specific script of the GameObject.
 
void AddScript (ScriptType T)(ComponentScript component)
 Add a new script to the GameObject.
 

Public Attributes

bool mActive = true
 Whether the GameObject is active or not.
 

Protected Attributes

IComponent[ComponentType] mComponents
 
ComponentScript[ScriptType] mScripts
 

Detailed Description

Represents an in-game entity.

Each GameObject has components (IComponent) and scripts (ComponentScript) that implement specific behaviors.

See also
IComponent
ComponentScript

Constructor & Destructor Documentation

◆ this()

GameObject::this ( string name)
inline

Create a new GameObject.

Parameters
namethe name for the GameObject.

Member Function Documentation

◆ AddComponent()

void GameObject::AddComponent ( ComponentType T)
inline

Add a new component to the GameObject.

Parameters
Tthe type of IComponent to add.
componentthe new IComponent.

◆ AddScript()

void GameObject::AddScript ( ScriptType T)
inline

Add a new script to the GameObject.

Parameters
Tthe type of ComponentScript to add.
componentthe new ComponentScript.

◆ GetComponent()

IComponent GameObject::GetComponent ( ComponentType type)
inline

Get a specific component of the GameObject.

Parameters
typethe type of IComponent to receive.
Returns
the given IComponent if it exists.

◆ GetID()

size_t GameObject::GetID ( ) const
inline

Get the ID of the GameObject.

Returns
the GameObject id.

◆ GetName()

string GameObject::GetName ( ) const
inline

Get the name of the GameObject.

Returns
the GameObject name.

◆ GetScript()

ComponentScript GameObject::GetScript ( ScriptType type)
inline

Get a specific script of the GameObject.

Parameters
typethe type of ComponentScript to receive.
Returns
the given ComponentScript if it exists.

◆ IsActive()

bool GameObject::IsActive ( )
inline

Whether the GameObject is active.

Returns
true if active, false otherwise.

◆ IsEnabled()

bool GameObject::IsEnabled ( )
inline

Whether the GameObject is enabled.

Returns
true if enabled, false otherwise.

◆ Render()

void GameObject::Render ( SDL_Renderer * renderer,
SDL_Rect * camera )
inline

Render the GameObject's components and scripts.

See also
GameApplication::Render
IComponent::Render
ComponentScript::Render

◆ SetActive()

void GameObject::SetActive ( bool active)
inline

Set whether the GameObject is active or not.

Parameters
activewhether the GameObject should be active or not.

◆ SetEnabled()

void GameObject::SetEnabled ( bool enabled)
inline

Set whether the GameObject is enabled or not.

Parameters
enabledwhether the GameObject should be enabled or not.

◆ Update()

void GameObject::Update ( )
inline

Update the state of the GameObject's components and scripts.

See also
GameApplication::Update
IComponent::Update
ComponentScript::Update

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