Changeset 7900 in orxonox.OLD for branches/gui/src
- Timestamp:
- May 27, 2006, 1:09:35 PM (19 years ago)
- Location:
- branches/gui/src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/gui/src/lib/gui/gl_gui/glgui_inputline.cc
r7896 r7900 48 48 49 49 this->setFocusable(true); 50 this->setClickable(true);51 50 52 51 this->text.setParent2D(this); -
branches/gui/src/lib/util/timer.cc
r7899 r7900 12 12 #include <sys/time.h> 13 13 14 14 /** 15 * @returns the current time in Second exact to the micro-second 16 */ 15 17 double Timer::getNow() { 16 18 -
branches/gui/src/lib/util/timer.h
r7899 r7900 13 13 class Timer 14 14 { 15 public: 15 16 static double getNow(); 16 17 -
branches/gui/src/story_entities/game_world.cc
r7840 r7900 25 25 26 26 #include "util/loading/game_loader.h" 27 #include "util/timer.h" 27 28 28 29 #include "player.h" … … 259 260 this->cycle = 0; 260 261 for (unsigned int i = 0; i < TICK_SMOOTH_VALUE; i++) 261 this->frameTimes[i] = 100;262 this->frameTimes[i] = 0.01f; 262 263 this->dtS = 0.0f; 263 this->lastFrame = SDL_GetTicks();264 this->lastFrame = Timer::getNow(); 264 265 265 266 if (this->dataTank->music != NULL) … … 356 357 void GameWorld::tick () 357 358 { 358 Uint32 currentFrame = SDL_GetTicks();359 360 359 if( !this->bPaused) 361 360 { 362 361 // CALCULATE FRAMERATE 363 362 Uint32 frameTimesIndex; 364 Uint32 getTicks;365 363 Uint32 i; 364 double currentFrame = Timer::getNow(); 366 365 367 366 frameTimesIndex = this->cycle % TICK_SMOOTH_VALUE; 368 getTicks = SDL_GetTicks(); 369 this->frameTimes[frameTimesIndex] = getTicks - this->lastFrame; 370 this->lastFrame = getTicks; 367 this->frameTimes[frameTimesIndex] = currentFrame - this->lastFrame; 368 this->lastFrame = currentFrame; 371 369 ++this->cycle; 372 this->dtS = 0 ;370 this->dtS = 0.0; 373 371 for (i = 0; i < TICK_SMOOTH_VALUE; i++) 374 372 this->dtS += this->frameTimes[i]; 375 this->dtS = this->dtS / TICK_SMOOTH_VALUE / 1000.0f* speed;373 this->dtS = this->dtS / TICK_SMOOTH_VALUE * speed; 376 374 377 375 // TICK everything … … 390 388 this->dataTank->gameRule->tick(this->dtS); 391 389 } 392 this->lastFrame = currentFrame;393 390 } 394 391 -
branches/gui/src/story_entities/game_world.h
r7785 r7900 93 93 94 94 /* world timing */ 95 Uint32lastFrame; //!< last time of frame (in MiliSeconds)95 double lastFrame; //!< last time of frame (in MiliSeconds) 96 96 Uint32 cycle; //!< The cycle we are in (starts with 0 and rises with every frame) 97 97 float dtS; //!< The time needed for caluculations in seconds 98 98 float speed; //!< how fast the game flows 99 99 double gameTime; //!< this is where the game time is saved 100 Uint32frameTimes[TICK_SMOOTH_VALUE];//!< The time used for the last TICK_SMOOTH_VALUE's frames.100 double frameTimes[TICK_SMOOTH_VALUE];//!< The time used for the last TICK_SMOOTH_VALUE's frames. 101 101 102 102 GameRules* gameRules; //!< Pointer to the data structure containig the game rules
Note: See TracChangeset
for help on using the changeset viewer.