Carpenter Engine
A C++ game engine with a build once run anywhere solution
Loading...
Searching...
No Matches
Game.hpp
1/*
2 * This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at https://mozilla.org/MPL/2.0/.
5 */
6
7#ifndef ENGINE_GAME
8#define ENGINE_GAME
9
10#include "Node.hpp"
11#include "Graphics/Renderer.hpp"
12#include <map>
13
14namespace Engine {
15
35 class Game {
36 private:
37 Scene* m_currentScene;
38 std::map<const char*, Scene*> m_loadedScenes;
39
40 Graphics::Renderer m_renderer;
41
42 // SINGLETON STUFF //
43 static Game* m_instance;
44
50 Game(Scene* startingScene);
51
52 public:
53
54 static Game& getInstance(Engine::Scene* startingScene = nullptr);
55
64 Success AddScene(const char* id, Scene* scene);
65
72 Success SwitchScene(const char* id);
73
80 Success UnloadScene(const char* id);
81
82 // For the game Loop //
83
87 void DrawScene();
88
92 void UpdateScene(float dt);
93
98
99 };
100}
101
102#endif
Success
A generic success type.
Definition Utils.hpp:29
The game class singleton used to run the game loop.
Definition Game.hpp:35
void DrawScene()
Definition Game.cpp:56
Success AddScene(const char *id, Scene *scene)
Definition Game.cpp:30
Success UnloadScene(const char *id)
Definition Game.cpp:49
void UpdateScene(float dt)
Definition Game.cpp:61
Success SwitchScene(const char *id)
Definition Game.cpp:37
Graphics::Renderer & GetRenderer()
Definition Game.cpp:65
a class used to interact with html canvases
Definition Renderer.hpp:33
A single node in a game scene.
Definition Node.hpp:43