Dragonfly 4.20
A text-based game engine
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
df::GameManager Class Reference
Inheritance diagram for df::GameManager:
Inheritance graph

Public Member Functions

int startUp () override
 
bool isValid (std::string event_name) const override
 
void shutDown () override
 
void run ()
 
void setGameOver (bool game_over=true)
 
bool getGameOver () const
 
int getFrameTime () const
 
int getStepCount () const
 
- Public Member Functions inherited from df::Manager
std::string getType () const
 
virtual int startUp ()
 
virtual void shutDown ()
 
bool isStarted () const
 
int onEvent (const Event *p_event) const
 
int registerInterest (Object *p_o, std::string event_type)
 
int unregisterInterest (Object *p_o, std::string event_type)
 

Static Public Member Functions

static GameManagergetInstance ()
 

Private Member Functions

 GameManager ()
 
 GameManager (GameManager const &)
 
void operator= (GameManager const &)
 

Private Attributes

bool m_game_over
 
int m_frame_time
 
int m_step_count
 

Additional Inherited Members

- Protected Member Functions inherited from df::Manager
void setType (std::string new_type)
 

Constructor & Destructor Documentation

◆ GameManager() [1/2]

df::GameManager::GameManager ( )
private

Private since a singleton.

◆ GameManager() [2/2]

df::GameManager::GameManager ( GameManager const &  )
private

Don't allow copy.

Member Function Documentation

◆ getFrameTime()

int df::GameManager::getFrameTime ( ) const

Return frame time.


Frame time is target time for each game loop, in milliseconds.

◆ getGameOver()

bool df::GameManager::getGameOver ( ) const

Get game over status.

◆ getInstance()

static GameManager & df::GameManager::getInstance ( )
static

Get the singleton instance of the GameManager.

◆ getStepCount()

int df::GameManager::getStepCount ( ) const

Return game loop step count.

◆ isValid()

bool df::GameManager::isValid ( std::string  event_name) const
overridevirtual

Game manager only accepts step events.

Return false if other event.

Reimplemented from df::Manager.

◆ operator=()

void df::GameManager::operator= ( GameManager const &  )
private

Don't allow assignment.

◆ run()

void df::GameManager::run ( )

Run game loop.

◆ setGameOver()

void df::GameManager::setGameOver ( bool  game_over = true)

Set game over status to indicated value.

If true (default), will stop game loop.

◆ shutDown()

void df::GameManager::shutDown ( )
overridevirtual

Shut down GameManager services.

Reimplemented from df::Manager.

◆ startUp()

int df::GameManager::startUp ( )
overridevirtual

Startup all GameManager services.

Reimplemented from df::Manager.

Member Data Documentation

◆ m_frame_time

int df::GameManager::m_frame_time
private

Target time per game loop, in millisec.

◆ m_game_over

bool df::GameManager::m_game_over
private

True -> game loop should stop.

◆ m_step_count

int df::GameManager::m_step_count
private

Count of game loop iterations.