Changeset 7159 in orxonox.OLD for trunk/src/subprojects
- Timestamp:
- Feb 18, 2006, 1:50:59 AM (19 years ago)
- Location:
- trunk/src/subprojects
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/subprojects/framework.cc
r7158 r7159 66 66 { 67 67 Framework* framework = Framework::getInstance(); 68 69 // initialize Timing 70 framework->cycle = 0; 71 for (unsigned int i = 0; i < TICK_SMOOTH_VALUE; i++) 72 framework->frameTimes[i] = 100; 73 framework->dtS = 0.0f; 74 framework->lastFrame = SDL_GetTicks (); 75 76 68 77 while(!framework->isFinished) 69 78 { … … 103 112 float Framework::tick() 104 113 { 105 currFrame = SDL_GetTicks(); 106 float dt = (float)(currFrame - lastFrame) / 1000.0; 107 lastFrame = currFrame; 108 this->camera->tick(dt); 109 110 this->moduleTick(dt); 111 112 return dt; 114 // CALCULATE FRAMERATE 115 Uint32 frameTimesIndex; 116 Uint32 getTicks; 117 Uint32 i; 118 119 frameTimesIndex = this->cycle % TICK_SMOOTH_VALUE; 120 getTicks = SDL_GetTicks(); 121 this->frameTimes[frameTimesIndex] = getTicks - this->lastFrame; 122 this->lastFrame = getTicks; 123 ++this->cycle; 124 this->dtS = 0; 125 for (i = 0; i < TICK_SMOOTH_VALUE; i++) 126 this->dtS += this->frameTimes[i]; 127 this->dtS = this->dtS / TICK_SMOOTH_VALUE / 1000.0f * speed; 128 129 this->camera->tick(dtS); 130 131 this->moduleTick(dtS); 132 133 return dtS; 113 134 } 114 135 -
trunk/src/subprojects/framework.h
r6981 r7159 12 12 13 13 #define MOUSE_BUTTON_COUNT 3 14 15 #define TICK_SMOOTH_VALUE 10 14 16 15 17 class Camera; … … 59 61 float backgroundColor[4]; 60 62 61 Uint32 lastFrame; 62 Uint32 currFrame; 63 /* world timing */ 64 Uint32 lastFrame; //!< last time of frame (in MiliSeconds) 65 Uint32 cycle; //!< The cycle we are in (starts with 0 and rises with every frame) 66 float dtS; //!< The time needed for caluculations in seconds 67 float speed; //!< how fast the game flows 68 double gameTime; //!< this is where the game time is saved 69 Uint32 frameTimes[TICK_SMOOTH_VALUE];//!< The time used for the last TICK_SMOOTH_VALUE's frames. 63 70 64 71 Uint8* keys; // This variable will be used in the keyboard routine
Note: See TracChangeset
for help on using the changeset viewer.