OpenMortal Apocalypse mirror
Sourceforge mirror
SourceForge.net Logo
      News | Info | Characters | Arenas | Screenshots | Forums | Download  
Developer: Making of | Character-HOWTO | AI Design | Submit a Character
Documentation: Main Page | Modules | Class Hierarchy | Class List | File List

Game.h

Go to the documentation of this file.
00001 /***************************************************************************
00002                           Game.h  -  description
00003                              -------------------
00004     begin                : Mon Aug 27 2003
00005     copyright            : (C) 2003 by upi
00006     email                : upi@apocalypse.rulez.org
00007  ***************************************************************************/
00008 
00009 
00010 #ifndef GAME_H
00011 #define GAME_H
00012 
00020 #include <string>
00021 #include <vector>
00022 #include <list>
00023 
00024 struct SDL_Surface;
00025 class Background;
00026 
00027 
00028 
00029 
00045 class CKeyQueue
00046 {
00047 public:
00048     CKeyQueue();
00049     ~CKeyQueue();
00050 
00051     void Reset();
00052     void EnqueueKey( int a_iAtTime, int a_iPlayer, int a_iKey, bool a_bDown );
00053     void DequeueKeys( int a_iToTime );
00054 
00055 protected:
00056     struct SEnqueuedKey
00057     {
00058         int     iTime;
00059         int     iPlayer;
00060         int     iKey;
00061         bool    bDown;
00062     };
00063 
00064     typedef std::list<SEnqueuedKey> TEnqueuedKeyList;
00065     TEnqueuedKeyList m_oKeys;
00066 };
00067 
00068 
00069 
00070 
00080 class CGame
00081 {
00082 public:
00083     CGame( bool a_bIsReplay, bool m_bWide, bool a_bDebug );
00084     ~CGame();
00085     int Run();
00086     std::string& GetReplay();
00087     void DoReplay( const char* a_pcReplayFile );
00088     static int GetBackgroundNumber();
00089     
00090 protected:
00091     void Draw();
00092     void DrawHitPointDisplay( int a_iPlayer);
00093     void DrawHitPointDisplays();
00094     void DrawBackground();
00095     void DrawDoodads();
00096     void DrawPoly( const char* a_pcName, int a_iColor );
00097     void AddBodyToBackground( int a_iPlayer );
00098     
00099     void DoOneRound();
00100     
00101     void Advance( int a_iNumFrames );
00102     int ProcessEvents();
00103     void HandleKey( int a_iPlayer, int a_iKey, bool a_bDown );
00104     void HandleKO();
00105     
00106     void HurryUp();
00107     void TimeUp();
00108     void InstantReplay( int a_iKoAt );
00109 
00110     bool IsTeamMode();
00111     bool IsNetworkGame();
00112     bool IsMaster();
00113     void ReadKeysFromNetwork();
00114     
00115 protected:
00116     
00117     static int          mg_iBackgroundNumber;
00118 
00119     bool                m_bIsReplay;
00120     bool                m_bWide;        
00121     int                 m_iYOffset;     
00122     bool                m_bDebug;
00123     CBackground*        m_poBackground;
00124     SDL_Surface*        m_poDoodads;
00125 
00126     int                 m_aiHitPointDisplayX[MAXPLAYERS];
00127     int                 m_aiHitPointDisplayY[MAXPLAYERS];
00128     bool                m_abHitPointDisplayLeft[MAXPLAYERS];
00129     
00130     int                 m_aiRoundsWonByPlayer[MAXPLAYERS];
00131     int                 m_iNumberOfRounds;
00132     int                 m_iFrame;
00133     int                 m_iGameTime;
00134     CKeyQueue           m_oKeyQueue;
00135     int                 m_iEnqueueDelay;
00136     
00137     std::string         m_sReplayString;
00138     std::vector<int>    m_aReplayOffsets;
00139     
00140     enum TGamePhaseEnum     // This enum assumes its values during DoOneRound
00141     {
00142         Ph_START,           // "Round X" displayed, fighters getting ready
00143         Ph_NORMAL,          // During the fight
00144         Ph_TIMEUP,          // Time is up, no KO, no replay.
00145         Ph_KO,              // There is a KO, forward until the guy is down
00146         Ph_REWIND,          // There was a KO, rewinding until before the KO
00147         Ph_SLOWFORWARD,     // Playing back the KO
00148         
00149         Ph_REPLAY,          // Replay mode
00150     }                   m_enGamePhase;
00151     
00152     SState::TGameMode   m_enInitialGameMode;    // must make sure it's still the same.
00153 };
00154 
00155 #endif