summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bytepusher.scm20
1 files changed, 13 insertions, 7 deletions
diff --git a/bytepusher.scm b/bytepusher.scm
index 0db879b..fde6230 100644
--- a/bytepusher.scm
+++ b/bytepusher.scm
@@ -183,13 +183,19 @@
(load-display! texture)
(render-copy renderer texture)
(present-renderer renderer)
- (let ((t1 (sdl-ticks)))
- (unless (> t1 (+ t0 1000/60))
- (usleep (floor (* 1000 (- (+ t0 1000/60) t1))))))
- (display (string-append
- "FPS: "
- (number->string
- (exact->inexact (/ 1000 (- (sdl-ticks) t0)))) "\n")))
+ (let* ((t1 (sdl-ticks))
+ (frame-time (exact->inexact 1000/60))
+ (max-time (+ t0 frame-time)))
+ (when (> max-time t1)
+ (usleep (inexact->exact (floor (* 1000 (- max-time t1))))))
+ (display (string-append
+ "FPS: "
+ (number->string
+ (exact->inexact (/ 1000 (- (sdl-ticks) t0))))
+ "("
+ (number->string
+ (exact->inexact (/ 1000 (- t1 t0))))
+ ")\n"))))
(loop)))
(define (main)