Claypool

Courses

Publications

Students

Projects

Service

Downloads

Misc


Dragonfly: GameManager.h Source File
Dragonfly 2.2
A text-based game engine

GameManager.h

00001 ///
00002 /// The game manager
00003 ///
00004 
00005 #ifndef __GAME_MANAGER_H__
00006 #define __GAME_MANAGER_H__
00007 
00008 #include <time.h>               ///< For time_t
00009 
00010 #include "Manager.h"
00011 
00012 #define DRAGONFLY_VERSION 2.2
00013 
00014 #define DEFAULT_FRAME_TIME 33   ///< In milliseconds (33 ms == 30 fps).
00015 
00016 class GameManager : public Manager {
00017 
00018  private:
00019   GameManager();                       ///< Private since a singleton.
00020   GameManager (GameManager const&);    ///< Don't allow copy.
00021   void operator=(GameManager const&);  ///< Don't allow assignment.
00022 
00023  protected:
00024   bool game_over;               ///< True -> game loop should stop.
00025   int frame_time;               ///< Target time per game loop, in millisec.
00026 
00027  public:
00028   ~GameManager();
00029 
00030   /// Get the singleton instance of the GameManager.
00031   static GameManager &getInstance();
00032 
00033   /// Startup all the GameManager services.
00034   int startUp();
00035 
00036   /// Startup all the GameManager services.
00037   /// if flush is true, call fflush() after each write (default false).
00038   int startUp(bool flush);
00039 
00040   /// Startup all the GameManager services.
00041   /// if flush is true, call fflush() after each write (default false).
00042   /// seed = random seed (default is seed with system time).
00043   int startUp(bool flush, time_t seed);
00044 
00045   /// Shut down the GameManager services.
00046   void shutDown();
00047 
00048   /// Run the game loop.
00049   /// fr_time is time between frames
00050   void run(int fr_time=DEFAULT_FRAME_TIME);
00051 
00052   /// Indicate the game is over, which will stop the game loop.
00053   void setGameOver();
00054 
00055   /// Set game over status to indicated value.
00056   void setGameOver(bool new_game_over);
00057 
00058   /// Return frame time.  
00059   //  The frame time is the target for each game loop, in milliseconds.
00060   int getFrameTime();
00061 };
00062 
00063 #endif // __GAME_MANAGER_H__
 All Classes Functions Variables Friends