The Table Engine
scenemanager.h
Go to the documentation of this file.
1 #pragma once
2 
11 #include <string>
12 #include <atomic>
13 
14 #include "scene.h"
15 #include "camera.h"
16 #include <SDL2/SDL.h>
17 #include <nlohmann/json.hpp>
18 
27 {
28  private:
29  SDL_Renderer* m_renderer;
30  std::vector<SceneTree*> m_sceneTrees;
31 
34 
38  SceneManager();
39 
43  SceneManager(const SceneManager&) = delete;
44 
48  void operator=(const SceneManager&) = delete;
49 
50  public:
55  static SceneManager& getInstance();
56 
57  static std::atomic<uint64_t> m_totalObjects;
58  static std::atomic<uint64_t> m_aliveObjects;
59 
60  bool isDemo = false;
61 
66  void setRenderer(SDL_Renderer* renderer);
67 
68  void loadDemo();
69 
70  void loadScenesFromJSON(const std::string& filePath);
71 
75  void getNextScene();
76 
81  int getSceneIndex();
82 
87  SDL_Renderer* getRenderer();
88 
94 
98  void cleanTree();
99 
105 
113 
117  void input();
118 
122  void update();
123 
127  void render();
128 };
Manages the camera's view in a game, handling its position in the world space.
Definition: camera.h:14
Singleton class that manages scenes and their transitions.
Definition: scenemanager.h:27
static SceneManager & getInstance()
Retrieves the singleton instance of SceneManager.
SceneTree * createSceneTest2()
std::vector< SceneTree * > m_sceneTrees
Array of scene trees.
Definition: scenemanager.h:30
SceneTree * createSceneTest1()
Creates a test scene. This method is an example of how to define specific scenes.
void operator=(const SceneManager &)=delete
Deleted assignment operator to prevent copying of singleton.
SceneTree * getSceneTree()
Retrieves the current scene tree managing the game objects.
void getNextScene()
Advances to the next scene based on the current scene index.
void render()
Renders the current scene.
void cleanTree()
Cleans up the scene tree, removing all inactive game objects.
void input()
Processes input for the current scene.
SceneManager(const SceneManager &)=delete
Deleted copy constructor to prevent copying of singleton.
SceneManager()
Private constructor for singleton pattern.
SDL_Renderer * m_renderer
Renderer used to render the game objects.
Definition: scenemanager.h:29
int m_currentSceneIndex
Index of the current scene in the game.
Definition: scenemanager.h:32
void loadScenesFromJSON(const std::string &filePath)
void update()
Updates the state of the current scene.
SceneTree * createSceneTest3()
SDL_Renderer * getRenderer()
Retrieves the current SDL_Renderer used by the SceneManager.
int getSceneIndex()
Retrieves the index of the current scene.
Camera * m_camera
Definition: scenemanager.h:33
static std::atomic< uint64_t > m_totalObjects
Total number of game objects created.
Definition: scenemanager.h:57
static std::atomic< uint64_t > m_aliveObjects
Current number of active game objects.
Definition: scenemanager.h:58
Vec2 getCameraWorldPosition()
Retrieves the world position of the camera.
void setRenderer(SDL_Renderer *renderer)
Sets the renderer used for drawing game objects.
Manages a tree structure of SceneNodes, facilitating scene graph operations.
Definition: scene.h:109
Defines the SceneNode and SceneTree classes for managing game objects within scenes.
A structure to represent 2D vectors.
Definition: vec2.h:16