PROTO::KLUDGE  0.1
Quick prototyping library for games using SDL and OpenGL.
pk::Game Class Reference

Class for storing and managing all game data and states. Game is implemented as a Singleton and also uses the State pattern along with ScreenState subclasses. More...

#include <Game.hpp>

Collaboration diagram for pk::Game:
Collaboration graph

Public Types

enum  gameState {
  s_uninitialized, s_menu, s_options, s_levelSelect,
  s_characterSelect, s_level, s_quit
}
 Internal states of the game. More...
 

Public Member Functions

virtual ~Game ()
 
 Game (Game const &)=delete
 Inaccessible - Game is a Singleton. More...
 
void operator= (Game const &)=delete
 Inaccessible - Game is a Singleton. More...
 

Static Public Member Functions

static void init ()
 Initialization routine for Game ScreenStates. More...
 
static GamegetInstance ()
 Retrieve the Singleton Game object. More...
 
static Window *const getWindow ()
 Retrieve the SDL window from the Game object. More...
 
static void run ()
 Runs the game - call to get everything going. More...
 
static void setScreenState (ScreenState *const state)
 Set the current ScreenState of the Game. More...
 
static ScreenState *const getMenuScreenState ()
 Get a pointer to the Menu ScreenState. More...
 
static ScreenState *const getLevelScreenState ()
 Get a pointer to the Level ScreenState. More...
 
static void menu ()
 Run the MenuScreen state. More...
 
static void options ()
 Run the OptionsScreen state. More...
 
static void levelSelect ()
 Run the LevelSelect state. More...
 
static void characterSelect ()
 Run the CharacterSelect state. More...
 
static void level ()
 Run the LevelScreen state. More...
 
static bool isRunning ()
 Check if the Game is running. More...
 
static glm::vec2 getScalingFactor ()
 Get the scaling factor according to the user's currently selected screen resolution relative to 800 x 600. Useful for scaling content with screen resolution. More...
 
static void setScalingFactor (glm::vec2 f)
 Set the global scaling factor for drawing. More...
 
static int getMusicVolume ()
 Get the global setting for music volume. More...
 
static void setMusicVolume (int v)
 Set the global music volume. More...
 
static int getSoundEffectVolume ()
 Get the global setting for sound effect volume. More...
 
static void setSoundEffectVolume (int v)
 Set the global sound effect volume. More...
 

Private Member Functions

 Game ()
 Inaccessible - Game is a Singleton. More...
 

Static Private Attributes

static Windowm_window
 Window object for context and rendering. More...
 
static ScreenStatem_menu
 Main menu state instance. More...
 
static ScreenStatem_options
 Options menu state instance. More...
 
static ScreenStatem_levelSelect
 LevelSelect state instance. More...
 
static ScreenStatem_characterSelect
 CharacterSelect state instance. More...
 
static ScreenStatem_level
 Level state instance. More...
 
static ScreenStatem_state
 Current state instance. More...
 
static Uint32 m_gameState
 Game object state (not screen state...but related). More...
 
static bool m_running
 Check if Game is running. More...
 
static glm::vec2 m_scalingFactor
 The scaling factor according to the current resolution relative to 800 x 600. More...
 
static int m_musicVolume
 The current setting for music volume. More...
 
static int m_soundEffectVolume
 The current setting for sound effect volume. More...
 
static Uint32 m_levelSelected
 The current level selected by the player. More...
 

Detailed Description

Class for storing and managing all game data and states. Game is implemented as a Singleton and also uses the State pattern along with ScreenState subclasses.

Member Enumeration Documentation

◆ gameState

Internal states of the game.

Enumerator
s_uninitialized 
s_menu 
s_options 
s_levelSelect 
s_characterSelect 
s_level 
s_quit 

Constructor & Destructor Documentation

◆ Game() [1/2]

pk::Game::Game ( )
inlineprivate

Inaccessible - Game is a Singleton.

◆ ~Game()

virtual pk::Game::~Game ( )
virtual

◆ Game() [2/2]

pk::Game::Game ( Game const &  )
delete

Inaccessible - Game is a Singleton.

Member Function Documentation

◆ characterSelect()

static void pk::Game::characterSelect ( )
static

Run the CharacterSelect state.

◆ getInstance()

static Game & pk::Game::getInstance ( )
static

Retrieve the Singleton Game object.

◆ getLevelScreenState()

static ScreenState *const pk::Game::getLevelScreenState ( )
inlinestatic

Get a pointer to the Level ScreenState.

Returns
ScreenState * const - a const pointer to the Level ScreenState.

◆ getMenuScreenState()

static ScreenState *const pk::Game::getMenuScreenState ( )
inlinestatic

Get a pointer to the Menu ScreenState.

Returns
ScreenState * const - a const pointer to the Menu ScreenState.

◆ getMusicVolume()

static int pk::Game::getMusicVolume ( )
inlinestatic

Get the global setting for music volume.

◆ getScalingFactor()

static glm::vec2 pk::Game::getScalingFactor ( )
inlinestatic

Get the scaling factor according to the user's currently selected screen resolution relative to 800 x 600. Useful for scaling content with screen resolution.

Returns
glm::vec2 - a vector of floats.

◆ getSoundEffectVolume()

static int pk::Game::getSoundEffectVolume ( )
inlinestatic

Get the global setting for sound effect volume.

◆ getWindow()

static Window *const pk::Game::getWindow ( )
inlinestatic

Retrieve the SDL window from the Game object.

◆ init()

static void pk::Game::init ( )
static

Initialization routine for Game ScreenStates.

◆ isRunning()

static bool pk::Game::isRunning ( )
inlinestatic

Check if the Game is running.

Returns
bool

◆ level()

static void pk::Game::level ( )
static

Run the LevelScreen state.

◆ levelSelect()

static void pk::Game::levelSelect ( )
static

Run the LevelSelect state.

◆ menu()

static void pk::Game::menu ( )
static

Run the MenuScreen state.

◆ operator=()

void pk::Game::operator= ( Game const &  )
delete

Inaccessible - Game is a Singleton.

◆ options()

static void pk::Game::options ( )
static

Run the OptionsScreen state.

◆ run()

static void pk::Game::run ( )
static

Runs the game - call to get everything going.

◆ setMusicVolume()

static void pk::Game::setMusicVolume ( int  v)
inlinestatic

Set the global music volume.

Parameters
intv - integer specifying the music volume.

◆ setScalingFactor()

static void pk::Game::setScalingFactor ( glm::vec2  f)
inlinestatic

Set the global scaling factor for drawing.

Parameters
glm::vec2f - a scaling factor specified as a glm::vec2 of floats.

◆ setScreenState()

static void pk::Game::setScreenState ( ScreenState *const  state)
inlinestatic

Set the current ScreenState of the Game.

◆ setSoundEffectVolume()

static void pk::Game::setSoundEffectVolume ( int  v)
inlinestatic

Set the global sound effect volume.

Parameters
intv - integer specifying the music volume.

Member Data Documentation

◆ m_characterSelect

ScreenState* pk::Game::m_characterSelect
staticprivate

CharacterSelect state instance.

◆ m_gameState

Uint32 pk::Game::m_gameState
staticprivate

Game object state (not screen state...but related).

◆ m_level

ScreenState* pk::Game::m_level
staticprivate

Level state instance.

◆ m_levelSelect

ScreenState* pk::Game::m_levelSelect
staticprivate

LevelSelect state instance.

◆ m_levelSelected

Uint32 pk::Game::m_levelSelected
staticprivate

The current level selected by the player.

◆ m_menu

ScreenState* pk::Game::m_menu
staticprivate

Main menu state instance.

◆ m_musicVolume

int pk::Game::m_musicVolume
staticprivate

The current setting for music volume.

◆ m_options

ScreenState* pk::Game::m_options
staticprivate

Options menu state instance.

◆ m_running

bool pk::Game::m_running
staticprivate

Check if Game is running.

◆ m_scalingFactor

glm::vec2 pk::Game::m_scalingFactor
staticprivate

The scaling factor according to the current resolution relative to 800 x 600.

◆ m_soundEffectVolume

int pk::Game::m_soundEffectVolume
staticprivate

The current setting for sound effect volume.

◆ m_state

ScreenState* pk::Game::m_state
staticprivate

Current state instance.

◆ m_window

Window* pk::Game::m_window
staticprivate

Window object for context and rendering.


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