diff options
Diffstat (limited to '2d/game-loop.scm')
-rw-r--r-- | 2d/game-loop.scm | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/2d/game-loop.scm b/2d/game-loop.scm index 78a5655..a6cd669 100644 --- a/2d/game-loop.scm +++ b/2d/game-loop.scm @@ -51,6 +51,12 @@ (define running? #f) (define paused? #f) +(define (update-and-render stage dt accumulator) + (let ((remainder (update stage accumulator))) + (run-repl) + (render stage dt) + remainder)) + (define (tick dt accumulator) "Advance the game by one frame." (if paused? @@ -60,11 +66,10 @@ accumulator) (catch #t (lambda () - (let* ((stage (current-stage)) - (remainder (update stage accumulator))) - (run-repl) - (render stage dt) - remainder)) + (let ((stage (current-stage))) + (if stage + (update-and-render stage dt accumulator) + (quit-game)))) (lambda (key . args) (pause-game) accumulator) |