00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef _GAME_
00019 #define _GAME_
00020
00021 #include <map>
00022 #include <hash_map>
00023 #include <vector>
00024
00025 #include "input/InputListener.h"
00026
00027 #include "ui/AbstractScreenElement.h"
00028
00029 #include "util/Macros.h"
00030
00031 class AbstractRenderer;
00032 class GameEntity;
00033 class Engine;
00034 class b2World;
00035
00041 class Game
00042 {
00043 private:
00044 typedef stdext::hash_map<UNIQUEID, GameEntity*> GameEntityMap;
00045 typedef GameEntityMap::const_iterator GameEntityMapIterator;
00046
00047 GameEntityMap m_gameEntities;
00048
00049 GameEntity * m_pPlayerEntity;
00050
00051 std::vector<std::string> m_mapCycle;
00052
00053 b2World* m_pPhysics;
00054 Engine* m_pEngine;
00055
00056 float m_fPhysicsStep;
00057 int m_nPhysicsIterations;
00058 int m_nCurrentStage;
00059
00060 UNIQUEID m_nNextFreeId;
00061 public:
00066 Game(Engine* pEngine);
00067
00071 ~Game();
00072
00077 void Initialize();
00078
00084 void Update(const int nDelta);
00085
00093 void Render(AbstractRenderer* pRenderer, const int nDelta);
00094
00102 void Save(const std::wstring& file);
00103
00112 bool Load(const std::wstring& file);
00113
00123 bool LoadStage(const int nStage);
00124
00129 bool LoadNextStage();
00130
00135 int GetCurrentStage() const { return m_nCurrentStage; }
00136
00141 void Clear();
00142
00149 GameEntity* CreateEntity();
00150
00159 void DestroyEntity(const UNIQUEID& id);
00160
00164 Engine* GetEngine() const { return m_pEngine; }
00165
00169 b2World* GetPhysics() const { return m_pPhysics; }
00170
00174 GameEntity * GetPlayer() const { return m_pPlayerEntity; }
00175 };
00176
00177 #endif