Rhythm
Game Engines Final Project
Loading...
Searching...
No Matches
GameObject Struct Reference

Represents a game object within a scene. More...

Public Member Functions

 this (string name, Scene *scene)
 Constructs a GameObject with the given name and scene.
 
 ~this ()
 Destructor for GameObject.
 
string GetName () const
 Gets the name of the game object.
 
size_t GetID () const
 Gets the ID of the game object.
 
Scene * GetScene ()
 Gets the scene that owns this game object.
 
void Update ()
 Updates the game object by updating all its components.
 
void Input ()
 Handles input for the game object by delegating to its components.
 
void Render (SDL_Renderer *renderer)
 Renders the game object by delegating to its components.
 
 ComponentForType (T) GetComponent(ComponentType T)() const
 Gets a component of the specified type.
 
void AddComponent (ComponentType T)(IComponent component)
 Adds a component to the game object.
 
bool HasComponent (ComponentType T)() const
 Checks if the game object has a component of the specified type.
 

Protected Attributes

IComponent[ComponentType] mComponents
 Common components for all game objects.
 

Detailed Description

Represents a game object within a scene.

Constructor & Destructor Documentation

◆ this()

GameObject::this ( string name,
Scene * scene )
inline

Constructs a GameObject with the given name and scene.

Parameters
nameName of the game object.
scenePointer to the scene that owns this game object.

Member Function Documentation

◆ AddComponent()

void GameObject::AddComponent ( ComponentType T)
inline

Adds a component to the game object.

Parameters
TThe type of the component to add.
componentThe component to add.

◆ ComponentForType()

GameObject::ComponentForType ( T ) const
inline

Gets a component of the specified type.

Parameters
TThe type of the component to get.
Returns
The component of the specified type.

◆ GetID()

size_t GameObject::GetID ( ) const
inline

Gets the ID of the game object.

Returns
The ID of the game object.

◆ GetName()

string GameObject::GetName ( ) const
inline

Gets the name of the game object.

Returns
The name of the game object.

◆ GetScene()

Scene * GameObject::GetScene ( )
inline

Gets the scene that owns this game object.

Returns
Pointer to the scene that owns this game object.

◆ HasComponent()

bool GameObject::HasComponent ( ComponentType T) const
inline

Checks if the game object has a component of the specified type.

Parameters
TThe type of the component to check for.
Returns
True if the game object has the component, false otherwise.

◆ Render()

void GameObject::Render ( SDL_Renderer * renderer)
inline

Renders the game object by delegating to its components.

Parameters
rendererPointer to the SDL renderer.

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