The Table Engine
SceneManager Class Reference

Singleton class that manages scenes and their transitions. More...

#include <scenemanager.h>

+ Collaboration diagram for SceneManager:

Public Member Functions

void setRenderer (SDL_Renderer *renderer)
 Sets the renderer used for drawing game objects. More...
 
void loadDemo ()
 
void loadScenesFromJSON (const std::string &filePath)
 
void getNextScene ()
 Advances to the next scene based on the current scene index. More...
 
int getSceneIndex ()
 Retrieves the index of the current scene. More...
 
SDL_Renderer * getRenderer ()
 Retrieves the current SDL_Renderer used by the SceneManager. More...
 
SceneTreegetSceneTree ()
 Retrieves the current scene tree managing the game objects. More...
 
void cleanTree ()
 Cleans up the scene tree, removing all inactive game objects. More...
 
Vec2 getCameraWorldPosition ()
 Retrieves the world position of the camera. More...
 
SceneTreecreateSceneTest1 ()
 Creates a test scene. This method is an example of how to define specific scenes. More...
 
SceneTreecreateSceneTest2 ()
 
SceneTreecreateSceneTest3 ()
 
void input ()
 Processes input for the current scene. More...
 
void update ()
 Updates the state of the current scene. More...
 
void render ()
 Renders the current scene. More...
 

Static Public Member Functions

static SceneManagergetInstance ()
 Retrieves the singleton instance of SceneManager. More...
 

Public Attributes

bool isDemo = false
 

Static Public Attributes

static std::atomic< uint64_t > m_totalObjects = 0
 Total number of game objects created. More...
 
static std::atomic< uint64_t > m_aliveObjects = 0
 Current number of active game objects. More...
 

Private Member Functions

 SceneManager ()
 Private constructor for singleton pattern. More...
 
 SceneManager (const SceneManager &)=delete
 Deleted copy constructor to prevent copying of singleton. More...
 
void operator= (const SceneManager &)=delete
 Deleted assignment operator to prevent copying of singleton. More...
 

Private Attributes

SDL_Renderer * m_renderer
 Renderer used to render the game objects. More...
 
std::vector< SceneTree * > m_sceneTrees
 Array of scene trees. More...
 
int m_currentSceneIndex = -1
 Index of the current scene in the game. More...
 
Cameram_camera
 

Detailed Description

Singleton class that manages scenes and their transitions.

This class implements the singleton pattern to manage scenes throughout the game. It provides mechanisms to switch scenes, render them, and manage game objects within them.

Definition at line 26 of file scenemanager.h.

Constructor & Destructor Documentation

◆ SceneManager() [1/2]

SceneManager::SceneManager ( )
private

Private constructor for singleton pattern.

Definition at line 20 of file scenemanager.cpp.

◆ SceneManager() [2/2]

SceneManager::SceneManager ( const SceneManager )
privatedelete

Deleted copy constructor to prevent copying of singleton.

Member Function Documentation

◆ cleanTree()

void SceneManager::cleanTree ( )

Cleans up the scene tree, removing all inactive game objects.

Definition at line 289 of file scenemanager.cpp.

◆ createSceneTest1()

SceneTree * SceneManager::createSceneTest1 ( )

Creates a test scene. This method is an example of how to define specific scenes.

Returns
Pointer to the created SceneTree.

Definition at line 175 of file scenemanager.cpp.

◆ createSceneTest2()

SceneTree * SceneManager::createSceneTest2 ( )

Definition at line 213 of file scenemanager.cpp.

◆ createSceneTest3()

SceneTree * SceneManager::createSceneTest3 ( )

Definition at line 251 of file scenemanager.cpp.

◆ getCameraWorldPosition()

Vec2 SceneManager::getCameraWorldPosition ( )

Retrieves the world position of the camera.

Returns
Vec2 representing the camera's world position.

Definition at line 156 of file scenemanager.cpp.

◆ getInstance()

SceneManager & SceneManager::getInstance ( )
static

Retrieves the singleton instance of SceneManager.

Returns
Reference to the singleton instance of SceneManager.

Definition at line 15 of file scenemanager.cpp.

◆ getNextScene()

void SceneManager::getNextScene ( )

Advances to the next scene based on the current scene index.

Definition at line 160 of file scenemanager.cpp.

◆ getRenderer()

SDL_Renderer * SceneManager::getRenderer ( )

Retrieves the current SDL_Renderer used by the SceneManager.

Returns
Pointer to SDL_Renderer.

Definition at line 152 of file scenemanager.cpp.

◆ getSceneIndex()

int SceneManager::getSceneIndex ( )

Retrieves the index of the current scene.

Returns
Index of the current scene.

Definition at line 171 of file scenemanager.cpp.

◆ getSceneTree()

SceneTree * SceneManager::getSceneTree ( )

Retrieves the current scene tree managing the game objects.

Returns
Pointer to the current SceneTree.

Definition at line 28 of file scenemanager.cpp.

◆ input()

void SceneManager::input ( )

Processes input for the current scene.

Definition at line 303 of file scenemanager.cpp.

◆ loadDemo()

void SceneManager::loadDemo ( )

Definition at line 32 of file scenemanager.cpp.

◆ loadScenesFromJSON()

void SceneManager::loadScenesFromJSON ( const std::string &  filePath)

Definition at line 39 of file scenemanager.cpp.

◆ operator=()

void SceneManager::operator= ( const SceneManager )
privatedelete

Deleted assignment operator to prevent copying of singleton.

◆ render()

void SceneManager::render ( )

Renders the current scene.

Definition at line 369 of file scenemanager.cpp.

◆ setRenderer()

void SceneManager::setRenderer ( SDL_Renderer *  renderer)

Sets the renderer used for drawing game objects.

Parameters
rendererPointer to SDL_Renderer.

Definition at line 24 of file scenemanager.cpp.

◆ update()

void SceneManager::update ( )

Updates the state of the current scene.

Definition at line 314 of file scenemanager.cpp.

Member Data Documentation

◆ isDemo

bool SceneManager::isDemo = false

Definition at line 60 of file scenemanager.h.

◆ m_aliveObjects

std::atomic< uint64_t > SceneManager::m_aliveObjects = 0
static

Current number of active game objects.

Definition at line 58 of file scenemanager.h.

◆ m_camera

Camera* SceneManager::m_camera
private

Definition at line 33 of file scenemanager.h.

◆ m_currentSceneIndex

int SceneManager::m_currentSceneIndex = -1
private

Index of the current scene in the game.

Definition at line 32 of file scenemanager.h.

◆ m_renderer

SDL_Renderer* SceneManager::m_renderer
private

Renderer used to render the game objects.

Definition at line 29 of file scenemanager.h.

◆ m_sceneTrees

std::vector<SceneTree*> SceneManager::m_sceneTrees
private

Array of scene trees.

Definition at line 30 of file scenemanager.h.

◆ m_totalObjects

std::atomic< uint64_t > SceneManager::m_totalObjects = 0
static

Total number of game objects created.

Definition at line 57 of file scenemanager.h.


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