ASW Lib
A.D.S. Games SDL Wrapper Library. A library targeted at Allegro4 users who want to switch to SDL3 and use modern c++.
Loading...
Searching...
No Matches
asw::scene::Scene< T > Class Template Reference

Base class for game scenes. More...

#include <scene.h>

Public Member Functions

 Scene (SceneManager< T > &sceneManager)
 Constructor for the Scene class.
 
virtual ~Scene ()=default
 Destructor for the Scene class.
 
virtual void init ()
 Initialize the game scene.
 
virtual void update (float deltaTime)
 Update the game scene.
 
virtual void draw ()
 Draw the game scene.
 
virtual void cleanup ()
 Handle input for the game scene.
 
void registerObject (const std::shared_ptr< game::GameObject > obj)
 Add a game object to the scene.
 
template<typename ObjectType , typename... Args>
std::shared_ptr< ObjectType > createObject (Args &&... args)
 Create a new game object in the scene.
 
std::vector< std::shared_ptr< game::GameObject > > getObjects ()
 Get game objects in the scene.
 
template<typename ObjectType >
std::vector< std::shared_ptr< ObjectType > > getObjectView ()
 Get game objects of a specific type in the scene.
 

Protected Attributes

SceneManager< T > & sceneManager
 Reference to the scene manager.
 

Private Attributes

std::vector< std::shared_ptr< game::GameObject > > objects
 Collection of game objects in the scene.
 
std::vector< std::shared_ptr< game::GameObject > > objectsToCreate
 Objects to be created in the next frame.
 

Detailed Description

template<typename T>
class asw::scene::Scene< T >

Base class for game scenes.

Template Parameters
TThe type of the scene ID.

This class defines the interface for game scenes in the scene engine.

Definition at line 42 of file scene.h.

Constructor & Destructor Documentation

◆ Scene()

template<typename T >
asw::scene::Scene< T >::Scene ( SceneManager< T > & sceneManager)
inlineexplicit

Constructor for the Scene class.

Parameters
sceneManagerReference to the SceneManager object.

This constructor initializes the scene engine reference.

Definition at line 48 of file scene.h.

◆ ~Scene()

template<typename T >
virtual asw::scene::Scene< T >::~Scene ( )
virtualdefault

Destructor for the Scene class.

Member Function Documentation

◆ cleanup()

template<typename T >
virtual void asw::scene::Scene< T >::cleanup ( )
inlinevirtual

Handle input for the game scene.

This function is called every frame to handle input for the scene.

Definition at line 115 of file scene.h.

◆ createObject()

template<typename T >
template<typename ObjectType , typename... Args>
std::shared_ptr< ObjectType > asw::scene::Scene< T >::createObject ( Args &&... args)
inline

Create a new game object in the scene.

Parameters
gameObjectThe game object to add to the scene.

Definition at line 130 of file scene.h.

◆ draw()

template<typename T >
virtual void asw::scene::Scene< T >::draw ( )
inlinevirtual

Draw the game scene.

This function is called every frame to draw the scene.

Definition at line 95 of file scene.h.

◆ getObjects()

template<typename T >
std::vector< std::shared_ptr< game::GameObject > > asw::scene::Scene< T >::getObjects ( )
inline

Get game objects in the scene.

Returns
A vector of shared pointers to game objects in the scene.

Definition at line 146 of file scene.h.

◆ getObjectView()

template<typename T >
template<typename ObjectType >
std::vector< std::shared_ptr< ObjectType > > asw::scene::Scene< T >::getObjectView ( )
inline

Get game objects of a specific type in the scene.

Template Parameters
ObjectTypeThe type of the game object to get.
Returns
A vector of shared pointers to game objects of the specified type in the scene.

Definition at line 157 of file scene.h.

◆ init()

template<typename T >
virtual void asw::scene::Scene< T >::init ( )
inlinevirtual

Initialize the game scene.

This function is called when the scene is registered and initialized.

Definition at line 59 of file scene.h.

◆ registerObject()

template<typename T >
void asw::scene::Scene< T >::registerObject ( const std::shared_ptr< game::GameObject > obj)
inline

Add a game object to the scene.

Parameters
gameObjectThe game object to add to the scene.

Definition at line 121 of file scene.h.

◆ update()

template<typename T >
virtual void asw::scene::Scene< T >::update ( float deltaTime)
inlinevirtual

Update the game scene.

Parameters
deltaTimeThe time since the last update.

This function is called every frame to update the scene.

Definition at line 66 of file scene.h.

Member Data Documentation

◆ objects

template<typename T >
std::vector<std::shared_ptr<game::GameObject> > asw::scene::Scene< T >::objects
private

Collection of game objects in the scene.

Definition at line 176 of file scene.h.

◆ objectsToCreate

template<typename T >
std::vector<std::shared_ptr<game::GameObject> > asw::scene::Scene< T >::objectsToCreate
private

Objects to be created in the next frame.

Definition at line 179 of file scene.h.

◆ sceneManager

template<typename T >
SceneManager<T>& asw::scene::Scene< T >::sceneManager
protected

Reference to the scene manager.

Definition at line 172 of file scene.h.


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