Platformer
Platformer
GameManager.hpp
1 #ifndef GAME_MANAGER_HPP
2 #define GAME_MANAGER_HPP
3 
4 #include <string>
5 
6 #include "ConfigParser.hpp"
7 #include "GameWorld.hpp"
8 
13 class GameManager {
14  public:
16  static GameManager& instance();
17 
19  void init();
20 
23  void shutdown();
24 
26  void LoadLevels();
27 
29  static void LoadNextLevel();
30 
32  static void ReloadLevel();
33 
38  void Update();
39 
44  static std::vector<std::shared_ptr<GameObject>> GetActiveObjects();
45 
47  GameManager(const GameManager&) = delete;
48 
50  GameManager& operator=(const GameManager&) = delete;
51 
52  void RegisterObject(std::shared_ptr<GameObject> obj, bool isPermanent);
53 
54  private:
56  GameManager();
57 
59  ~GameManager();
60 
62  void LoadLevel(
63  const std::string& path);
64 
66  std::shared_ptr<GameWorld> curWorld_;
67 
69  std::vector<std::shared_ptr<GameObject>> permanentObjs_;
70 
72  std::vector<std::string> levelPaths;
73 
75  int curLevel;
76 
79 };
80 
81 #endif
void LoadLevel(const std::string &path)
Loads the given level path.
Definition: GameManager.cpp:31
void LoadLevels()
Calls to parse the levels and sets shouldLoadLevel true.
Definition: GameManager.cpp:26
GameManager()
Constructs a GameManager.
Definition: GameManager.cpp:10
static GameManager & instance()
The singleton instance of the GameManager.
Definition: GameManager.cpp:13
void init()
Initializes the GameManager.
Definition: GameManager.cpp:19
std::vector< std::string > levelPaths
The list of level paths for loading assets.
Definition: GameManager.hpp:72
static void ReloadLevel()
Reloads the level by setting shouldLoadLevel true.
Definition: GameManager.cpp:46
int curLevel
The current level.
Definition: GameManager.hpp:75
std::shared_ptr< GameWorld > curWorld_
The current world for our GameManager.
Definition: GameManager.hpp:66
static void LoadNextLevel()
Increments the curLevel and sets shouldLoadLevel true.
Definition: GameManager.cpp:36
std::vector< std::shared_ptr< GameObject > > permanentObjs_
The permanent objects in our GameManager.
Definition: GameManager.hpp:69
void Update()
Updates the world and any other gameobjects controlled by the GameManager, and calls to load levels i...
Definition: GameManager.cpp:50
void shutdown()
Shuts down the GameManager, removing its reference to the currently loaded GameWorld and all GameObje...
Definition: GameManager.cpp:21
~GameManager()
Destructs a GameManager.
Definition: GameManager.cpp:11
This class manages the loading, rendering, and objects of our game as a singleton.
Definition: GameManager.hpp:13
static std::vector< std::shared_ptr< GameObject > > GetActiveObjects()
Gets the list of all active objects in our GameManager.
Definition: GameManager.cpp:64
bool shouldLoadLevel
Whether or not the GameManager should load the next level.
Definition: GameManager.hpp:78
GameManager & operator=(const GameManager &)=delete
Stop the compiler from generating methods to copy the object.