Dauphine  0.1
A platforming/stealth game in a medieval fantasy setting, developed with SDL2.
Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
Game Class Reference

Main structure class for the game. More...

#include <Game.h>

Public Types

enum  GStates : uint8_t {
  SPLASH = 0, MENU, LEVEL_ONE, OPTIONS,
  CREDITS, GAMEOVER
}
 All possible game states.
 

Public Member Functions

 ~Game ()
 The destructor. More...
 
void runGame ()
 The main game loop. More...
 
void setState (const GStates state_)
 Sets the current game state. More...
 
AudioHandlergetAudioHandler ()
 
std::array< bool, GameKeys::MAX > getInput ()
 
ResourceManagergetResources ()
 
void stop ()
 Stops execution and closes the game.
 

Static Public Member Functions

static Gameinstance ()
 Singleton imeplementation for Game. More...
 

Private Member Functions

 Game ()
 The constructor. More...
 
void initializeStates ()
 Loads all the states. More...
 
void destroyStates ()
 Deletes all the loaded states. More...
 

Private Attributes

Windowwindow
 The game Window. More...
 
bool isRunning
 Whether the game is currently running/looping or not. More...
 
AudioHandleraudioHandler
 The Game AudioHandler. More...
 
InputHandlerinputHandler
 The Game InputHandler. More...
 
ResourceManagerresourceManager
 The Game ResourceManager. More...
 
StateGamecurrentState
 The current state, which the game is in. More...
 
std::map< GStates, StateGame * > statesMap
 Map containing all possible states. More...
 
FPSmanager fpsManager
 The FPSManager from SDL2_GFX. More...
 

Detailed Description

Main structure class for the game.

Contains all the necessary functionalities to loop and update the game. Is the state machine (controls current state), contains all the different possible states.

Constructor & Destructor Documentation

Game::~Game ( )

The destructor.

Destroys the game's Window and states, and unloads current state.

Game::Game ( )
private

The constructor.

Sets the game window and tells the game that it is OK to begin looping. Also, it begins the FPS manager.

Note
If the Window cannot be created, the game will not begin.

Member Function Documentation

void Game::destroyStates ( )
private

Deletes all the loaded states.

Every new state implemented should be deleted here.

AudioHandler & Game::getAudioHandler ( )
Returns
The Game audioHandler.
std::array< bool, GameKeys::MAX > Game::getInput ( )
Returns
The boolean array recieved from the InputHandler.
ResourceManager & Game::getResources ( )
Returns
The resource manager.
void Game::initializeStates ( )
private

Loads all the states.

Every new state implemented should be initialized here.

Game & Game::instance ( )
static

Singleton imeplementation for Game.

Returns
The instance for a Game.
void Game::runGame ( )

The main game loop.

Orders the game structure, such as inputs, updates, and rendering.

void Game::setState ( const GStates  state_)

Sets the current game state.

See Also
StateGame::load()
StateGame::unload()
Parameters
state_: The state you want to be changed into.
Todo:
Implement the transition between states.

Member Data Documentation

AudioHandler* Game::audioHandler
private
StateGame* Game::currentState
private

The current state, which the game is in.

FPSmanager Game::fpsManager
private

The FPSManager from SDL2_GFX.

Handles the framerate capping.

InputHandler* Game::inputHandler
private
bool Game::isRunning
private

Whether the game is currently running/looping or not.

ResourceManager* Game::resourceManager
private
std::map<GStates, StateGame*> Game::statesMap
private

Map containing all possible states.

Window* Game::window
private

The game Window.


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