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::SceneManager< T > Class Template Reference

Forward declaration of the SceneManager class. More...

#include <scene.h>

Public Member Functions

 SceneManager ()
 Constructor for the SceneManager class.
 
template<typename SceneType , typename... Args>
void registerScene (const T sceneId, Args &&... args)
 Register a scene to be managed by the scene engine.
 
void setNextScene (const T sceneId)
 Set the next scene.
 
void start ()
 Main loop for the scene engine. If this is not enough, or you want to define your own loop, you can use the update and draw functions directly.
 
void update (const float deltaTime)
 Update the current scene.
 
void draw ()
 Draw the current scene.
 
int getFPS () const
 Get the current FPS. Only applies to the managed loop.
 

Private Member Functions

void changeScene ()
 Change the current scene to the next scene.
 

Private Attributes

std::shared_ptr< Scene< T > > activeScene
 The current scene of the scene engine.
 
nextScene
 The next scene of the scene engine.
 
bool hasNextScene {false}
 Flag to indicate if there is a next scene to change to.
 
std::unordered_map< T, std::shared_ptr< Scene< T > > > scenes
 Collection of all scenes registered in the scene engine.
 
int fps {0}
 @breif FPS Counter for managed loop;
 

Detailed Description

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

Forward declaration of the SceneManager class.

SceneManager class for managing game scenes.

Template Parameters
TThe type of the scene ID.

This class manages the registration, updating, and drawing of game scenes. It also handles the transition between scenes.

Definition at line 189 of file scene.h.

Constructor & Destructor Documentation

◆ SceneManager()

template<typename T >
asw::scene::SceneManager< T >::SceneManager ( )
inline

Constructor for the SceneManager class.

Definition at line 193 of file scene.h.

Member Function Documentation

◆ changeScene()

template<typename T >
void asw::scene::SceneManager< T >::changeScene ( )
inlineprivate

Change the current scene to the next scene.

Definition at line 296 of file scene.h.

◆ draw()

template<typename T >
void asw::scene::SceneManager< T >::draw ( )
inline

Draw the current scene.

Definition at line 279 of file scene.h.

◆ getFPS()

template<typename T >
int asw::scene::SceneManager< T >::getFPS ( ) const
inline

Get the current FPS. Only applies to the managed loop.

Returns
The current FPS.

Definition at line 291 of file scene.h.

◆ registerScene()

template<typename T >
template<typename SceneType , typename... Args>
void asw::scene::SceneManager< T >::registerScene ( const T sceneId,
Args &&... args )
inline

Register a scene to be managed by the scene engine.

Parameters
sceneIdThe unique identifier for the scene.
scenePointer to the Scene object to be registered.

Definition at line 206 of file scene.h.

◆ setNextScene()

template<typename T >
void asw::scene::SceneManager< T >::setNextScene ( const T sceneId)
inline

Set the next scene.

Parameters
sceneIdThe unique identifier for the scene.

Definition at line 220 of file scene.h.

◆ start()

template<typename T >
void asw::scene::SceneManager< T >::start ( )
inline

Main loop for the scene engine. If this is not enough, or you want to define your own loop, you can use the update and draw functions directly.

This function is called to start the main loop of the scene engine.

Definition at line 231 of file scene.h.

◆ update()

template<typename T >
void asw::scene::SceneManager< T >::update ( const float deltaTime)
inline

Update the current scene.

Definition at line 268 of file scene.h.

Member Data Documentation

◆ activeScene

template<typename T >
std::shared_ptr<Scene<T> > asw::scene::SceneManager< T >::activeScene
private

The current scene of the scene engine.

Definition at line 314 of file scene.h.

◆ fps

template<typename T >
int asw::scene::SceneManager< T >::fps {0}
private

@breif FPS Counter for managed loop;

Definition at line 326 of file scene.h.

◆ hasNextScene

template<typename T >
bool asw::scene::SceneManager< T >::hasNextScene {false}
private

Flag to indicate if there is a next scene to change to.

Definition at line 320 of file scene.h.

◆ nextScene

template<typename T >
T asw::scene::SceneManager< T >::nextScene
private

The next scene of the scene engine.

Definition at line 317 of file scene.h.

◆ scenes

template<typename T >
std::unordered_map<T, std::shared_ptr<Scene<T> > > asw::scene::SceneManager< T >::scenes
private

Collection of all scenes registered in the scene engine.

Definition at line 323 of file scene.h.


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