Changeset 1674 for code/branches/gui/src/core
- Timestamp:
- Aug 28, 2008, 8:30:25 PM (16 years ago)
- Location:
- code/branches/gui/src/core
- Files:
-
- 2 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/gui/src/core/CorePrereqs.h
r1672 r1674 162 162 163 163 // game states 164 class BaseGameState;165 164 class GameState; 166 165 class RootGameState; -
code/branches/gui/src/core/GameState.cc
r1672 r1674 34 34 35 35 #include "GameState.h" 36 #include <cassert>37 36 #include "Debug.h" 38 37 #include "Exception.h" … … 359 358 This method is not virtual! You cannot override it therefore. 360 359 */ 361 void GameState::tick( float dt, uint64_ttime)360 void GameState::tick(const Clock& time) 362 361 { 363 362 this->operation_.running = true; 364 this->ticked( dt,time);363 this->ticked(time); 365 364 this->operation_.running = false; 366 365 } -
code/branches/gui/src/core/GameState.h
r1672 r1674 42 42 #include <map> 43 43 #include "util/Integers.h" 44 #include "Clock.h" 44 45 45 46 namespace orxonox … … 100 101 virtual void enter() = 0; 101 102 virtual void leave() = 0; 102 virtual void ticked( float dt, uint64_ttime) = 0;103 virtual void ticked(const Clock& time) = 0; 103 104 104 105 GameState* getActiveChild() { return this->activeChild_; } 105 106 106 void tickChild( float dt, uint64_t time) { if (this->getActiveChild()) this->getActiveChild()->tick(dt,time); }107 void tickChild(const Clock& time) { if (this->getActiveChild()) this->getActiveChild()->tick(time); } 107 108 108 109 private: … … 113 114 void grandchildRemoved(GameState* grandchild); 114 115 115 void tick( float dt, uint64_ttime);116 void tick(const Clock& time); 116 117 void activate(); 117 118 void deactivate(); -
code/branches/gui/src/core/RootGameState.cc
r1673 r1674 29 29 #include "RootGameState.h" 30 30 31 #include <OgreTimer.h> 32 #include "util/Integers.h" 31 #include "Clock.h" 33 32 #include "Debug.h" 34 33 #include "Exception.h" … … 95 94 if (current) 96 95 { 97 //OrxAssert(dynamic_cast<GameState*>(current),98 // "RootGameState: There was a RootGameState in the subtree of Root");99 //GameState* currentGS = static_cast<GameState*>(current);100 //currentGS->makeTransition(this, request);101 96 current->makeTransition(0, request); 102 97 } … … 141 136 gotoState(initialState); 142 137 143 Ogre::Timer timer; 144 uint64_t storedTime = 0; 145 unsigned long lastTimersTime = 1; 146 timer.reset(); 138 Clock clock; 147 139 while (this->activeChild_) 148 140 { 149 // get current time 150 unsigned long timersTime = timer.getMicroseconds(); 151 uint64_t realTime = storedTime + timersTime; 152 float dt = (float)(timersTime - lastTimersTime)/1000000.0f; 153 if (timersTime > 7000000) 154 { 155 // Under worst condition, the ogre timer will overflow right after 7 seconds 156 storedTime += timersTime; 157 lastTimersTime = 0; 158 timer.reset(); 159 } 160 else 161 { 162 lastTimersTime = timersTime; 163 } 141 clock.capture(); 164 142 165 this->tick( dt, realTime);143 this->tick(clock); 166 144 167 145 if (this->stateRequest_ != "") -
code/branches/gui/src/core/RootGameState.h
r1672 r1674 31 31 32 32 #include "CorePrereqs.h" 33 #include <OgrePrerequisites.h>34 33 #include "GameState.h" 35 34 … … 38 37 class _CoreExport RootGameState : public GameState 39 38 { 40 //friend class GameState;41 42 39 public: 43 40 RootGameState(const std::string& name); … … 46 43 void requestState(const std::string& name); 47 44 void start(); 48 49 protected:50 //virtual void ticked(float dt) = 0;51 //virtual void enter() = 0;52 //virtual void leave() = 0;53 45 54 46 private:
Note: See TracChangeset
for help on using the changeset viewer.