summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--2d/game-loop.scm32
1 files changed, 16 insertions, 16 deletions
diff --git a/2d/game-loop.scm b/2d/game-loop.scm
index a4c6e29..1c22ffc 100644
--- a/2d/game-loop.scm
+++ b/2d/game-loop.scm
@@ -162,23 +162,23 @@ is the unused accumulator time."
;;; Game Loop
;;;
+(define (game-loop last-time next-time accumulator)
+ "Runs input, render, and update hooks."
+ (handle-events)
+ (let* ((time (SDL:get-ticks))
+ (dt (- time last-time))
+ (accumulator (+ accumulator dt))
+ (remainder (update accumulator)))
+ (render)
+ (accumulate-fps! dt)
+ ;; Sleep for a bit if there's time in between frames
+ (SDL:delay (time-left (SDL:get-ticks) next-time))
+ (game-loop time
+ (+ next-time tick-interval)
+ remainder)))
+
(define (run-game-loop)
- "Runs event handling, update, and render loop."
- (define (game-loop last-time next-time accumulator)
- (handle-events)
- (let* ((time (SDL:get-ticks))
- (dt (- time last-time))
- (accumulator (+ accumulator dt))
- (remainder (update accumulator)))
- (render)
- (accumulate-fps! dt)
- ;; Sleep for a bit if there's time in between frames
- (SDL:delay (time-left (SDL:get-ticks) next-time))
- (game-loop time
- (+ next-time tick-interval)
- remainder)))
-
- ;; Start REPL for live coding wonders.
+ "Spawns a REPL server and starts the main game loop."
(spawn-server)
(agenda-schedule show-fps)
(let ((time (SDL:get-ticks)))