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 > &manager)
 Constructor for the Scene class.
 
virtual ~Scene ()=default
 Destructor for the Scene class.
 
virtual void init ()
 Initialize the game scene.
 
virtual void update (float dt)
 Update the game scene.
 
virtual void draw ()
 Draw the game scene.
 
virtual void cleanup ()
 Handle input for the game scene.
 
void register_object (const std::shared_ptr< game::GameObject > &obj)
 Add a game object to the scene.
 
template<typename ObjectType , typename... Args>
std::shared_ptr< ObjectType > create_object (Args &&... args)
 Create a new game object in the scene.
 
const std::vector< std::shared_ptr< game::GameObject > > & get_objects () const
 Get game objects in the scene.
 
template<typename ObjectType >
std::vector< std::shared_ptr< ObjectType > > get_object_view ()
 Get game objects of a specific type in the scene.
 

Protected Attributes

SceneManager< T > & manager
 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 > > _obj_to_create
 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 41 of file scene.h.

Constructor & Destructor Documentation

◆ Scene()

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

Constructor for the Scene class.

Parameters
managerReference to the SceneManager object.

This constructor initializes the scene engine reference.

Definition at line 47 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 111 of file scene.h.

◆ create_object()

template<typename T >
template<typename ObjectType , typename... Args>
std::shared_ptr< ObjectType > asw::scene::Scene< T >::create_object ( 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 94 of file scene.h.

◆ get_object_view()

template<typename T >
template<typename ObjectType >
std::vector< std::shared_ptr< ObjectType > > asw::scene::Scene< T >::get_object_view ( )
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.

◆ get_objects()

template<typename T >
const std::vector< std::shared_ptr< game::GameObject > > & asw::scene::Scene< T >::get_objects ( ) const
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.

◆ 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 60 of file scene.h.

◆ register_object()

template<typename T >
void asw::scene::Scene< T >::register_object ( 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 120 of file scene.h.

◆ update()

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

Update the game scene.

Parameters
dtThe time in seconds since the last update.

This function is called every frame to update the scene.

Definition at line 69 of file scene.h.

Member Data Documentation

◆ _obj_to_create

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

Objects to be created in the next frame.

Definition at line 180 of file scene.h.

◆ _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 177 of file scene.h.

◆ manager

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

Reference to the scene manager.

Definition at line 173 of file scene.h.


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