summaryrefslogtreecommitdiff
path: root/2d
diff options
context:
space:
mode:
authorDavid Thompson <dthompson2@worcester.edu>2013-07-31 23:31:21 -0400
committerDavid Thompson <dthompson2@worcester.edu>2013-07-31 23:31:21 -0400
commit460ec9e2e0df67927e2afb742af15edf46c4182e (patch)
treeb26f89095a81a979eababa4386ef1bc4634d0f00 /2d
parent4ea336421278bc50c6621c86fd8310c75d47de62 (diff)
Move game-loop procedure out of run-game-loop.
Diffstat (limited to '2d')
-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)))