summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Thompson <dthompson2@worcester.edu>2020-12-15 21:53:10 -0500
committerDavid Thompson <dthompson2@worcester.edu>2020-12-15 21:53:10 -0500
commita39342d1a7e690d6591a06fe641e5c5702dad5b9 (patch)
tree6e70d3f09393126f400a018309f57ea4c8fa0aec
parent8726cc42e3e7e5e6f34f7328898e35ed207bfb08 (diff)
game-loop: Sleep after rendering a frame, not after update.
-rw-r--r--chickadee/game-loop.scm14
1 files changed, 7 insertions, 7 deletions
diff --git a/chickadee/game-loop.scm b/chickadee/game-loop.scm
index 6a14fab..1d0c679 100644
--- a/chickadee/game-loop.scm
+++ b/chickadee/game-loop.scm
@@ -72,7 +72,7 @@
;; the game on a fixed timestep like this yields a
;; stable simulation.
(let loop ((previous-time (time))
- (buffer 0))
+ (buffer 0.0))
(let* ((current-time (time))
(delta (- current-time previous-time)))
(let update-loop ((buffer (+ buffer delta)))
@@ -82,17 +82,17 @@
;; order to discard the undefined amount of time
;; that was spent handling the error.
(if (with-error-handling error (update timestep))
- (loop (time) 0)
- (begin
- (usleep 1)
- (update-loop (- buffer timestep))))
+ (loop (time) 0.0)
+ (update-loop (- buffer timestep)))
(begin
;; We render upon every iteration of the loop, and
;; thus rendering is decoupled from updating.
;; It's possible to render multiple times before
;; an update is performed.
- (if (with-error-handling error (render (/ buffer timestep)))
- (loop (time) 0)
+ (if (with-error-handling error
+ (render (/ buffer timestep))
+ (usleep 1))
+ (loop (time) 0.0)
(loop current-time buffer))))))))
(lambda (cont callback)
#f))))