1. Christian Kellermann
  2. doodle

Commits

Scott Tincman  committed 44ca328

Fix event-handler timer logic. This makes minimum wait work properly and dt report the right values. This also changes the timers to work on seconds across the board (love does this for dt, and chicken's srfi-18 uses seconds for thread-sleep)

  • Participants
  • Parent commits 688499a
  • Branches master

Comments (0)

Files changed (1)

File doodle.scm

View file
  • Ignore whitespace
 
 (define (event-handler minimum-wait)
   (lambda ()
-    (let ((last (current-milliseconds)))
+    (let ((last (time->seconds (current-time))))
       (call-with-current-continuation
        (lambda (escape)
          (let loop ()
-           (let* ((now (current-milliseconds))
-                  (dt (min (/ 1 30) (/ (- now last)
-                                       1000))))
+           (let* ((now (time->seconds (current-time)))
+                  (dt (- now last)))
              (call-with-current-continuation
               (lambda (k)
                 (with-exception-handler
                     escape)))))
              (show!)
              (set! last now)
-             (when (< (- now last) minimum-wait)
-               (thread-sleep! (- minimum-wait (- now last))))
+	     (let ((duration (- (time->seconds (current-time)) last)))
+	       (when (< duration minimum-wait)
+		     (thread-sleep! (- minimum-wait duration))))
              (loop)))))
              (call-with-current-continuation
               (lambda (k)