wiki:cgame

Version 2 (modified by chlin, 3 years ago) (diff)

--

ps/Game.h

class CGame
{
        ...
        CWorld *m_World;
        CSimulation2 *m_Simulation2;

        ...

        enum EOG
        {
                EOG_NEUTRAL,    /// Game is in progress
                EOG_DRAW,               /// Game is over as a Draw by means of agreement of civilizations
                EOG_SPECIAL_DRAW,       /// Game is over by players dying at the same time...?
                EOG_LOSE,               /// Game is over, local player loses
                EOG_WIN                 /// Game is over, local player wins
        } GameStatus;
        
        ...

public:
        CGame();
        ~CGame();

        PSRETURN StartGame(CGameAttributes *pGameAttributes);
        PSRETURN ReallyStartGame();

        bool Update(double deltaTime, bool doInterpolate = true);

        void Interpolate(float frameLength);

        void UpdateGameStatus();
        void EndGame();

        ...

        CPlayer *GetPlayer(size_t idx);

        ...

        inline std::vector<CPlayer*>* GetPlayers()
        {       return( &m_Players ); }

private:
        PSRETURN RegisterInit(CGameAttributes* pAttribs);
};

extern CGame *g_Game;
          

ps/Game.cpp

CGame::CGame():
        m_World(new CWorld(this)),
        m_Simulation2(new CSimulation2(&m_World->GetUnitManager(), m_World->GetTerrain())),
        m_GameView(new CGameView(this)),
        m_pLocalPlayer(NULL),
        m_GameStarted(false),
        m_Paused(false),
        m_SimRate(1.0f)
{

        m_World->GetUnitManager().SetObjectManager(m_GameView->GetObjectManager());

        ...

        m_Simulation2->LoadDefaultScripts();
        m_Simulation2->ResetState();

        ...
 
        m_Simulation2->InitGame(initData);
}