SDL Breakout Engine  0.1.0
An implementation of a Breakout game using sdl, implemented with efficient resource management.
GameManager.hpp
Go to the documentation of this file.
1 #ifndef GAME_MANAGER_HPP
2 #define GAME_MANAGER_HPP
3 
8 {
9  WIN,
10  LOSS,
12 };
13 
17 enum Button
18 {
19  QUIT = 0,
23 };
24 
29 {
30 public:
34  static GameManager &instance();
35 
41  int startUp(const int &numBricks);
42 
46  GameState GameOver() const;
47 
51  int GetScore() const;
52 
56  int GetLives() const;
57 
61  void ScorePoint();
62 
66  void LoseLife();
67 
73  void PressButton(const Button &b);
74 
80  void ReleaseButton(const Button &b);
81 
87  void ToggleButton(const Button &b);
88 
94  bool ButtonState(const Button &b) const;
95 
96  GameManager(const GameManager &) = delete;
97  void operator=(GameManager const &) = delete;
98 
99 private:
100  int score = 0;
101  int numBricks = 0;
102  int lives = 3;
103  bool buttons[4] = {false, false, false, false};
104  GameManager(){};
105 };
106 
107 #endif
void operator=(GameManager const &) = delete
GameManager is a singleton.
bool ButtonState(const Button &b) const
Definition: GameManager.cpp:67
void ReleaseButton(const Button &b)
Definition: GameManager.cpp:57
void PressButton(const Button &b)
Definition: GameManager.cpp:52
GameState
Definition: GameManager.hpp:7
void LoseLife()
Definition: GameManager.cpp:47
Game has been lost.
Definition: GameManager.hpp:10
Game is in progress.
Definition: GameManager.hpp:11
Paddle is going right.
Definition: GameManager.hpp:21
Button
Definition: GameManager.hpp:17
Game has been quit.
Definition: GameManager.hpp:19
Game has been won.
Definition: GameManager.hpp:9
Whether to use the mouse or arrow keys to move the paddle.
Definition: GameManager.hpp:22
Paddle is going left.
Definition: GameManager.hpp:20
Definition: GameManager.hpp:28
static GameManager & instance()
Definition: GameManager.cpp:3
int startUp(const int &numBricks)
Definition: GameManager.cpp:9
void ToggleButton(const Button &b)
Definition: GameManager.cpp:62
int GetScore() const
Definition: GameManager.cpp:31
GameState GameOver() const
Definition: GameManager.cpp:15
int GetLives() const
Definition: GameManager.cpp:36
void ScorePoint()
Definition: GameManager.cpp:41