diff options
author | David Thompson <dthompson2@worcester.edu> | 2013-11-03 18:11:23 -0500 |
---|---|---|
committer | David Thompson <dthompson2@worcester.edu> | 2013-11-03 18:11:23 -0500 |
commit | 77a17d8a5514a0eb920a9d81bf5bf42a192d4266 (patch) | |
tree | 3065c67a8d72aecb0a2a9ddd78e31c99d7abfd2b /2d | |
parent | 4848f16eec48b1597a882147aaafbfe937d5e321 (diff) |
Quit game when scene stack is empty.
Diffstat (limited to '2d')
-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) |