From 77a17d8a5514a0eb920a9d81bf5bf42a192d4266 Mon Sep 17 00:00:00 2001 From: David Thompson Date: Sun, 3 Nov 2013 18:11:23 -0500 Subject: Quit game when scene stack is empty. --- 2d/game-loop.scm | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to '2d') 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) -- cgit v1.2.3