Browse Source

Lessson 7.2

Godzil 3 years ago
parent
commit
023f202279
1 changed files with 6 additions and 3 deletions
  1. 6 3
      source/main.c

+ 6 - 3
source/main.c

@@ -121,11 +121,14 @@ void update()
 {
     int i;
 
-    while(!SDL_TICKS_PASSED(SDL_GetTicks(), previousFrameTime + FRAME_TARGET_TIME));
-
+    uint32_t timeToWait = FRAME_TARGET_TIME - (SDL_GetTicks() - previousFrameTime);
+    if (timeToWait <= FRAME_TARGET_TIME)
+    {
+        SDL_Delay(timeToWait);
+    }
     previousFrameTime = SDL_GetTicks();
 
-    cubeRotation.x += 0.01;
+    cubeRotation.@x += 0.01;
     cubeRotation.y += 0.01;
     cubeRotation.z += 0.01;