summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Thompson <dthompson@member.fsf.org>2013-09-04 22:59:40 -0400
committerDavid Thompson <dthompson@member.fsf.org>2013-09-06 00:09:29 -0400
commit96dc9f16e85de2132fc2c640dcefe3d560f23ae7 (patch)
treeca9c94b11ee9ab500db04caec7cd945d8105e11d
parent0ae7fe04d628cc7fc98e785d3808c8571ef202fb (diff)
Add the beginnings of game scene management.
-rw-r--r--2d/game-loop.scm15
1 files changed, 13 insertions, 2 deletions
diff --git a/2d/game-loop.scm b/2d/game-loop.scm
index 994167c..aeb8889 100644
--- a/2d/game-loop.scm
+++ b/2d/game-loop.scm
@@ -52,6 +52,7 @@
(define game-fps 0)
(define game-running #f)
(define game-scene #f)
+(define game-next-scene #f)
;;;
;;; Event Handling
@@ -183,7 +184,17 @@ INPUT, OUTPUT, and ERROR ports."
"Execute a thunk from the REPL is there is one."
(unless (mvar-empty? repl-input-mvar)
(and-let* ((vals (try-take-mvar repl-input-mvar)))
- (apply run-repl-thunk vals))))
+ (apply run-repl-thunk vals))))
+
+;;;
+;;; Scene management
+;;;
+
+(define (set-game-scene scene)
+ (when game-scene
+ (scene-trigger game-scene 'stop))
+ (scene-trigger scene 'start)
+ (set! game-scene scene))
;;;
;;; Game Loop
@@ -211,7 +222,7 @@ INPUT, OUTPUT, and ERROR ports."
(game-resolution game)
(game-fullscreen? game))
(set! game-running #t)
- (set! game-scene ((game-first-scene game)))
+ (set-game-scene ((game-first-scene game)))
(spawn-server)
(agenda-schedule show-fps)
(let ((time (SDL:get-ticks)))