Dragonfly 4.20
A text-based game engine
GameManager.h
1///
2/// The game manager
3///
4
5#ifndef __GAME_MANAGER_H__
6#define __GAME_MANAGER_H__
7
8#include "Manager.h"
9
10#define DF_VERSION 4.20 /// Dragonfly version
11
12// Two-letter acronym for easier access to manager.
13#define GM df::GameManager::getInstance()
14
15namespace df {
16
17/// Default Dragonfly cofiguration file.
18/// Override with DRAGONFLY_CONFIG environment variable.
19const std::string CONFIG_FILENAME = "df-config.txt";
20
21/// Default frame time (game loop time) in milliseconds (33 ms == 30 f/s).
22const int FRAME_TIME_DEFAULT = 33;
23
24class GameManager : public Manager {
25
26 private:
27 GameManager(); ///< Private since a singleton.
28 GameManager(GameManager const&); ///< Don't allow copy.
29 void operator=(GameManager const&); ///< Don't allow assignment.
30 bool m_game_over; ///< True -> game loop should stop.
31 int m_frame_time; ///< Target time per game loop, in millisec.
32 int m_step_count; ///< Count of game loop iterations.
33
34 public:
35 /// Get the singleton instance of the GameManager.
37
38 /// Startup all GameManager services.
39 int startUp() override;
40
41 /// Game manager only accepts step events.
42 /// Return false if other event.
43 bool isValid(std::string event_name) const override;
44
45 /// Shut down GameManager services.
46 void shutDown() override;
47
48 /// Run game loop.
49 void run();
50
51 /// Set game over status to indicated value.
52 /// If true (default), will stop game loop.
53 void setGameOver(bool game_over=true);
54
55 /// Get game over status.
56 bool getGameOver() const;
57
58 /// Return frame time.
59 /// Frame time is target time for each game loop, in milliseconds.
60 int getFrameTime() const;
61
62 /// Return game loop step count.
63 int getStepCount() const;
64};
65
66} // end of namespace df
67#endif // __GAME_MANAGER_H__
Definition: GameManager.h:24
void operator=(GameManager const &)
Don't allow assignment.
static GameManager & getInstance()
Get the singleton instance of the GameManager.
int m_frame_time
Target time per game loop, in millisec.
Definition: GameManager.h:31
int getStepCount() const
Return game loop step count.
bool getGameOver() const
Get game over status.
GameManager()
Private since a singleton.
void run()
Run game loop.
int getFrameTime() const
Return frame time.
int startUp() override
Startup all GameManager services.
int m_step_count
Count of game loop iterations.
Definition: GameManager.h:32
bool m_game_over
True -> game loop should stop.
Definition: GameManager.h:30
void setGameOver(bool game_over=true)
Set game over status to indicated value.
void shutDown() override
Shut down GameManager services.
GameManager(GameManager const &)
Don't allow copy.
bool isValid(std::string event_name) const override
Game manager only accepts step events.
Definition: Manager.h:24
An animation for a sprite.
Definition: Animation.h:15
const std::string CONFIG_FILENAME
Default Dragonfly cofiguration file.
Definition: GameManager.h:19
const int FRAME_TIME_DEFAULT
Default frame time (game loop time) in milliseconds (33 ms == 30 f/s).
Definition: GameManager.h:22