PROTO::KLUDGE  0.1
Quick prototyping library for games using SDL and OpenGL.
Game.hpp
Go to the documentation of this file.
1 #ifndef GAME_HPP
2 #define GAME_HPP
3 
4 #include "core/Window.hpp"
5 #include "states/ScreenState.hpp"
6 
7 namespace pk
8 {
9 
16 class Game
17 {
18  private:
19  //Inaccessible constructor
22  Game(){};
23  public:
24  virtual ~Game();
25 
30  enum gameState
31  {
39  };
40 
41  //These functions are deleted so that
42  //copies cannot be made.
43  //Singleton pattern depends on this.
46  Game(Game const&) = delete;
49  void operator=(Game const&) = delete;
50 
55  static void init();
56 
61  static Game& getInstance();
62 
67  static Window * const getWindow(){return m_window;};
68 
73  static void run();
74 
79  static void setScreenState(ScreenState * const state){ m_state = state; };
80 
86  static ScreenState * const getMenuScreenState(){ return m_menu; };
87 
93  static ScreenState * const getLevelScreenState(){ return m_level; };
94 
99  static void menu();
100 
105  static void options();
106 
111  static void levelSelect();
112 
117  static void characterSelect();
118 
123  static void level();
124 
130  static bool isRunning(){ return m_running; };
131 
139  static glm::vec2 getScalingFactor(){ return m_scalingFactor; };
140 
146  static void setScalingFactor(glm::vec2 f){ m_scalingFactor = f; };
151  static int getMusicVolume(){ return m_musicVolume; };
152 
158  static void setMusicVolume(int v){ m_musicVolume = v; };
159 
164  static int getSoundEffectVolume(){ return m_soundEffectVolume; };
165 
171  static void setSoundEffectVolume(int v){ m_soundEffectVolume = v; };
172 
173  private:
174  static Window *m_window;
175  static ScreenState *m_menu;
181  static Uint32 m_gameState;
182  static bool m_running;
183  static glm::vec2 m_scalingFactor;
184  static int m_musicVolume;
185  static int m_soundEffectVolume;
186  static Uint32 m_levelSelected;
187 };
188 
189 } // end namespace pk
190 
191 #endif // GAME_HPP
static ScreenState *const getLevelScreenState()
Get a pointer to the Level ScreenState.
Definition: Game.hpp:93
static ScreenState * m_menu
Main menu state instance.
Definition: Game.hpp:175
Definition: Game.hpp:7
static void level()
Run the LevelScreen state.
gameState
Internal states of the game.
Definition: Game.hpp:30
Class for storing and managing all game data and states. Game is implemented as a Singleton and also ...
Definition: Game.hpp:16
static int m_soundEffectVolume
The current setting for sound effect volume.
Definition: Game.hpp:185
static void run()
Runs the game - call to get everything going.
Definition: Game.hpp:67
static void setMusicVolume(int v)
Set the global music volume.
Definition: Game.hpp:158
static glm::vec2 getScalingFactor()
Get the scaling factor according to the user's currently selected screen resolution relative to 800 x...
Definition: Game.hpp:139
Definition: Game.hpp:36
static Window *const getWindow()
Retrieve the SDL window from the Game object.
Definition: Game.hpp:67
static void init()
Initialization routine for Game ScreenStates.
static Game & getInstance()
Retrieve the Singleton Game object.
static void setScreenState(ScreenState *const state)
Set the current ScreenState of the Game.
Definition: Game.hpp:79
static void menu()
Run the MenuScreen state.
Definition: Game.hpp:93
Game()
Inaccessible - Game is a Singleton.
Definition: Game.hpp:22
static void options()
Run the OptionsScreen state.
Definition: Game.hpp:37
static ScreenState * m_level
Level state instance.
Definition: Game.hpp:179
static void characterSelect()
Run the CharacterSelect state.
Definition: Game.hpp:35
static Uint32 m_gameState
Game object state (not screen state...but related).
Definition: Game.hpp:181
Definition: Game.hpp:38
Abstract class for screen states, necessary for implementing the State pattern along with the Game cl...
Definition: ScreenState.hpp:14
static int getSoundEffectVolume()
Get the global setting for sound effect volume.
Definition: Game.hpp:164
Definition: Game.hpp:33
void operator=(Game const &)=delete
Inaccessible - Game is a Singleton.
static void setSoundEffectVolume(int v)
Set the global sound effect volume.
Definition: Game.hpp:171
static Window * m_window
Window object for context and rendering.
Definition: Game.hpp:171
virtual ~Game()
static ScreenState * m_levelSelect
LevelSelect state instance.
Definition: Game.hpp:177
static glm::vec2 m_scalingFactor
The scaling factor according to the current resolution relative to 800 x 600.
Definition: Game.hpp:183
Class for SDL window creation and management, implemented using the Facade pattern to provide a more ...
Definition: Window.hpp:24
static int m_musicVolume
The current setting for music volume.
Definition: Game.hpp:184
Definition: Game.hpp:34
static ScreenState * m_characterSelect
CharacterSelect state instance.
Definition: Game.hpp:178
static bool m_running
Check if Game is running.
Definition: Game.hpp:182
static ScreenState * m_options
Options menu state instance.
Definition: Game.hpp:176
Definition: Game.hpp:32
static ScreenState *const getMenuScreenState()
Get a pointer to the Menu ScreenState.
Definition: Game.hpp:86
static int getMusicVolume()
Get the global setting for music volume.
Definition: Game.hpp:151
static void setScalingFactor(glm::vec2 f)
Set the global scaling factor for drawing.
Definition: Game.hpp:146
static void levelSelect()
Run the LevelSelect state.
static ScreenState * m_state
Current state instance.
Definition: Game.hpp:180
static bool isRunning()
Check if the Game is running.
Definition: Game.hpp:130
static Uint32 m_levelSelected
The current level selected by the player.
Definition: Game.hpp:186