Changeset 916 for code/branches/input/src/orxonox/tools
- Timestamp:
- Mar 21, 2008, 3:50:44 PM (17 years ago)
- Location:
- code/branches/input/src/orxonox/tools
- Files:
-
- 2 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/input/src/orxonox/tools/Timer.cc
r893 r916 46 46 this->time_ = 0; 47 47 } 48 49 /** 50 @brief Updates the timer before the frames are rendered. 51 */ 52 void TimerBase::tick(float dt) 53 { 54 if (this->bActive_) 55 { 56 // If active: Decrease the timer by the duration of the last frame 57 this->time_ -= dt; 58 59 if (this->time_ <= 0) 60 { 61 // It's time to call the function 62 if (this->bLoop_) 63 // Q: Why '+=' and not '='? A: Think about it. It's more accurate like that. Seriously. 64 this->time_ += this->interval_; 65 else 66 this->stopTimer(); // Stop the timer if we don't want to loop 67 68 this->run(); 69 } 70 } 71 } 72 48 73 } -
code/branches/input/src/orxonox/tools/Timer.h
r900 r916 58 58 #define _Timer_H__ 59 59 60 #include <OgreFrameListener.h>61 60 #include "../OrxonoxPrereqs.h" 61 #include "objects/Tickable.h" 62 62 63 63 namespace orxonox 64 64 { 65 65 //! TimerBase is the parent of the Timer class. 66 class _OrxonoxExport TimerBase : public OrxonoxClass66 class _OrxonoxExport TimerBase : public Tickable 67 67 { 68 //friend class TimerFrameListener;69 friend class Orxonox;70 71 68 public: 72 69 TimerBase(); … … 84 81 /** @brief Returns true if the Timer is active (= not stoped, not paused). @return True = Time is active */ 85 82 inline bool isActive() const { return this->bActive_; } 83 84 void tick(float dt); 86 85 87 86 protected: … … 146 145 }; 147 146 148 #if 0149 //! The TimerFrameListener manages all Timers in the game.150 class TimerFrameListener : public Ogre::FrameListener151 {152 private:153 /** @brief Gets called before a frame gets rendered. */154 bool frameStarted(const Ogre::FrameEvent &evt)155 {156 // Iterate through all Timers157 for (Iterator<TimerBase> it = ObjectList<TimerBase>::start(); it; )158 {159 if (it->isActive())160 {161 // If active: Decrease the timer by the duration of the last frame162 it->time_ -= evt.timeSinceLastFrame;163 164 if (it->time_ <= 0)165 {166 // It's time to call the function167 if (it->bLoop_)168 it->time_ += it->interval_; // Q: Why '+=' and not '='? A: Think about it. It's more accurate like that. Seriously.169 else170 it->stopTimer(); // Stop the timer if we don't want to loop171 172 (it++)->run();173 }174 else175 ++it;176 }177 else178 ++it;179 }180 181 return FrameListener::frameStarted(evt);182 }183 };184 #endif185 147 } 186 148
Note: See TracChangeset
for help on using the changeset viewer.