Quellcode durchsuchen

*** empty log message ***

David Rose vor 25 Jahren
Ursprung
Commit
b8d81e561e
1 geänderte Dateien mit 11 neuen und 7 gelöschten Zeilen
  1. 11 7
      direct/src/task/Task.py

+ 11 - 7
direct/src/task/Task.py

@@ -21,10 +21,6 @@ def getTimeFrame():
 
 
     # Ask for the time last frame
     # Ask for the time last frame
     t = globalClock.getTime()
     t = globalClock.getTime()
-
-    # Set the clock to have last frame's time in case we were
-    # Paused at the prompt for a long time
-    globalClock.setTime(t)
     
     
     # Get the new frame count
     # Get the new frame count
     f = globalClock.getFrameCount()
     f = globalClock.getFrameCount()
@@ -259,16 +255,24 @@ class TaskManager:
         return len(self.taskList)
         return len(self.taskList)
 
 
     def run(self):
     def run(self):
+
+        # Set the clock to have last frame's time in case we were
+        # Paused at the prompt for a long time
+        t = globalClock.getTime()
+        globalClock.setTime(t)
+        
         self.running = 1
         self.running = 1
         while self.running:
         while self.running:
             try:
             try:
-                startTime = time.time()
+                startTime = globalClock.getRealTime()
                 self.step()
                 self.step()
-                finishTime = time.time()
+                finishTime = globalClock.getRealTime()
                 # Max out the frame rate so we do not starve the cpu
                 # Max out the frame rate so we do not starve the cpu
                 if (maxFps > 0):
                 if (maxFps > 0):
                     dt = finishTime - startTime
                     dt = finishTime - startTime
-                    time.sleep(max(0, (1.0/maxFps)-dt))
+                    length = (1.0/maxFps)-dt
+                    if (length > 0):
+                        time.sleep(length)
             except KeyboardInterrupt:
             except KeyboardInterrupt:
                 self.stop()
                 self.stop()
             except:
             except: