|
@@ -55,11 +55,17 @@ void application::update()
|
|
|
/* Let's make sure we are running at the expected framerate */
|
|
|
uint32_t now = SDL_GetTicks();
|
|
|
int32_t timeToWait = MILLISECS_PER_FRAME - (now - this->millisecsPreviousFrame);
|
|
|
- if (timeToWait > 0) // && timeToWait <= MILLISECS_PER_FRAME)
|
|
|
+ if ((timeToWait > 0) && (timeToWait <= MILLISECS_PER_FRAME))
|
|
|
{
|
|
|
SDL_Delay(timeToWait);
|
|
|
}
|
|
|
double deltaTime = (SDL_GetTicks() - this->millisecsPreviousFrame) / 1000.0;
|
|
|
+
|
|
|
+ /* clamp maximum deltatime to avoid weird behaviours */
|
|
|
+ if (deltaTime > 0.016)
|
|
|
+ {
|
|
|
+ deltaTime = 0.016;
|
|
|
+ }
|
|
|
this->millisecsPreviousFrame = SDL_GetTicks();
|
|
|
|
|
|
|