Carpenter Engine
A C++ game engine with a build once run anywhere solution
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | List of all members
Engine::Game Class Reference

The game class singleton used to run the game loop. More...

#include <Game.hpp>

Public Member Functions

Success AddScene (const char *id, Scene *scene)
 
Success SwitchScene (const char *id)
 
Success UnloadScene (const char *id)
 
void DrawScene ()
 
void UpdateScene (float dt)
 
Graphics::RendererGetRenderer ()
 

Static Public Member Functions

static GamegetInstance (Engine::Scene *startingScene=nullptr)
 

Detailed Description

The game class singleton used to run the game loop.

This class communicates with the game DOM to run the game loop. This allows the programmers to code without worrying about a main function. The game can hold multiple scenes and switch between them using the SwitchScene method.

Warning
This class is a singleton and should not be created manually. Instead, you use the GetInstance method to get the singleton instance and assign it only to references of the class.

Example

Engine::Game& game = Engine::Game::GetInstance(new SampleScene());
The game class singleton used to run the game loop.
Definition Game.hpp:35
Author
Roberto Selles

Member Function Documentation

◆ AddScene()

Engine::Success Engine::Game::AddScene ( const char *  id,
Scene scene 
)

Adds a scene to the game

Parameters
idThe loaded scene ID
sceneThe scene to add
Returns
Success if there is no scene with the same ID

◆ DrawScene()

void Engine::Game::DrawScene ( )

Draws the current scene

◆ GetRenderer()

Engine::Graphics::Renderer & Engine::Game::GetRenderer ( )

Returns the base renderer associated with the game engine

◆ SwitchScene()

Engine::Success Engine::Game::SwitchScene ( const char *  id)

Switches the scene requested

Parameters
idThe ID of the scene to switch to
Returns
Success if the scene exists

◆ UnloadScene()

Engine::Success Engine::Game::UnloadScene ( const char *  id)

Deletes a loaded scene from the game

Parameters
idThe ID of the scene to delete
Returns
Success if the scene exists

◆ UpdateScene()

void Engine::Game::UpdateScene ( float  dt)

Updates the current scene


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