From 460ec9e2e0df67927e2afb742af15edf46c4182e Mon Sep 17 00:00:00 2001 From: David Thompson Date: Wed, 31 Jul 2013 23:31:21 -0400 Subject: Move game-loop procedure out of run-game-loop. --- 2d/game-loop.scm | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to '2d/game-loop.scm') 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))) -- cgit v1.2.3