00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef TG_GAME_STATE_H
00019 #define TG_GAME_STATE_H
00020
00021 #include "Character.h"
00022 #include "Timer.h"
00023
00024 namespace tagGame
00025 {
00027 class GameState
00028 {
00029 public:
00030 inline GameState(RealVec const& worldDim);
00031 inline ~GameState();
00032
00033 inline ObstacleIterator getObstacleListBegin();
00034 inline ObstacleIterator getObstacleListEnd();
00035
00036 inline ObstacleIteratorConst getObstacleListBegin() const;
00037 inline ObstacleIteratorConst getObstacleListEnd() const;
00038
00039 inline CharacterIterator getCharacterListBegin();
00040 inline CharacterIterator getCharacterListEnd();
00041
00042 inline CharacterIteratorConst getCharacterListBegin() const;
00043 inline CharacterIteratorConst getCharacterListEnd() const;
00044
00045 inline ObstacleIterator getNonCharacterObstacleListBegin();
00046 inline ObstacleIterator getNonCharacterObstacleListEnd();
00047
00048 inline ObstacleIteratorConst getNonCharacterObstacleListBegin() const;
00049 inline ObstacleIteratorConst getNonCharacterObstacleListEnd() const;
00050
00051
00052 inline void addCharacter(CharacterPtr c);
00053 inline void addObstacle(ObstaclePtr o);
00054
00055 inline RealVec const& getWorldDim() const;
00056
00057 inline int getFrame() const;
00058 inline void incFrame();
00059
00060 inline int getLastTaggedTime();
00061 inline void setTagged();
00062
00063 protected:
00064 private:
00065
00066 ObstacleList obstacles;
00067
00068 int frame;
00069
00070
00071
00072
00073
00074
00075
00076 CharacterList characters;
00077 ObstacleList nonCharacterObstacles;
00078
00079 RealVec worldDim;
00080
00081 int lastTagTime;
00082 };
00083
00084 GameState::GameState(RealVec const& worldDim) :
00085 frame(0),
00086 worldDim(worldDim),
00087 lastTagTime(-1)
00088 {}
00089
00090 GameState::~GameState()
00091 {
00092 }
00093
00094 int GameState::getLastTaggedTime()
00095 {
00096 return lastTagTime;
00097 }
00098
00099 ObstacleIterator GameState::getObstacleListBegin()
00100 {
00101 return obstacles.begin();
00102 }
00103
00104 ObstacleIterator GameState::getObstacleListEnd()
00105 {
00106 return obstacles.end();
00107 }
00108
00109 ObstacleIteratorConst GameState::getObstacleListBegin() const
00110 {
00111 return obstacles.begin();
00112 }
00113
00114 ObstacleIteratorConst GameState::getObstacleListEnd() const
00115 {
00116 return obstacles.end();
00117 }
00118
00119 CharacterIterator GameState::getCharacterListBegin()
00120 {
00121 return characters.begin();
00122 }
00123
00124 CharacterIterator GameState::getCharacterListEnd()
00125 {
00126 return characters.end();
00127 }
00128
00129 CharacterIteratorConst GameState::getCharacterListBegin() const
00130 {
00131 return characters.begin();
00132 }
00133
00134 CharacterIteratorConst GameState::getCharacterListEnd() const
00135 {
00136 return characters.end();
00137 }
00138
00139 ObstacleIterator GameState::getNonCharacterObstacleListBegin()
00140 {
00141 return nonCharacterObstacles.begin();
00142 }
00143
00144 ObstacleIterator GameState::getNonCharacterObstacleListEnd()
00145 {
00146 return nonCharacterObstacles.end();
00147 }
00148
00149 ObstacleIteratorConst GameState::getNonCharacterObstacleListBegin() const
00150 {
00151 return nonCharacterObstacles.begin();
00152 }
00153
00154 ObstacleIteratorConst GameState::getNonCharacterObstacleListEnd() const
00155 {
00156 return nonCharacterObstacles.end();
00157 }
00158
00159 RealVec const& GameState::getWorldDim() const
00160 {
00161 return worldDim;
00162 }
00163
00164 int GameState::getFrame() const
00165 {
00166 return frame;
00167 }
00168
00169 void GameState::incFrame()
00170 {
00171 frame++;
00172 }
00173
00174 void GameState::setTagged()
00175 {
00176 lastTagTime = Timer::theTimer().gameTicks();
00177 }
00178
00179 void GameState::addCharacter(CharacterPtr c)
00180 {
00181 characters.push_back(c);
00182 addObstacle(c);
00183 }
00184
00185 void GameState::addObstacle(ObstaclePtr o)
00186 {
00187 obstacles.push_back(o);
00188 nonCharacterObstacles.push_back(o);
00189 }
00190 }
00191
00192 #endif