summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Thompson <dthompson2@worcester.edu>2013-11-03 20:02:44 -0500
committerDavid Thompson <dthompson2@worcester.edu>2013-11-03 20:02:44 -0500
commit49f93e5fe7261dd520a0013508fd02086af6ae17 (patch)
tree47c7fd2d368974bd1975e497e1b7108cf79b5803
parent77a17d8a5514a0eb920a9d81bf5bf42a192d4266 (diff)
Pass scene state to all observer event handlers.
-rw-r--r--2d/game-loop.scm5
-rw-r--r--2d/scene.scm4
-rw-r--r--2d/stage.scm8
3 files changed, 11 insertions, 6 deletions
diff --git a/2d/game-loop.scm b/2d/game-loop.scm
index a6cd669..a14459e 100644
--- a/2d/game-loop.scm
+++ b/2d/game-loop.scm
@@ -130,10 +130,11 @@ time in milliseconds that has passed since the last game update."
;; By default, pressing the escape key will pop the current scene, and
;; closing the window will quit the game.
-(default-events `((key-down . ,(lambda (key mod unicode)
+(default-events `((key-down . ,(lambda (state key mod unicode)
(when (eq? key 'escape)
(pop-scene))))
- (quit . ,quit-game)))
+ (quit . ,(lambda (state)
+ (quit-game)))))
(define handle-events
(let ((e (SDL:make-event)))
diff --git a/2d/scene.scm b/2d/scene.scm
index 7415f80..cb053b7 100644
--- a/2d/scene.scm
+++ b/2d/scene.scm
@@ -89,5 +89,5 @@ SCENE."
"Call the update callback for SCENE with STATE."
((scene-update scene) state))
-(define (scene-trigger scene event . args)
- (apply observer-trigger (scene-observer scene) event args))
+(define (scene-trigger scene state event . args)
+ (apply observer-trigger (scene-observer scene) event state args))
diff --git a/2d/stage.scm b/2d/stage.scm
index fee18a3..bf966ab 100644
--- a/2d/stage.scm
+++ b/2d/stage.scm
@@ -87,7 +87,11 @@
(define (stage-trigger stage event . args)
(with-agenda (stage-agenda stage)
- (apply scene-trigger (stage-scene stage) event args)))
+ (apply scene-trigger
+ (stage-scene stage)
+ (stage-state stage)
+ event
+ args)))
;;;
;;; Stage management
@@ -116,7 +120,7 @@ present."
(exit-stage prev-stage))
(set! stack (cdr stack))
(when (current-stage)
- (enter-stage (car stack)))))
+ (enter-stage (current-stage)))))
(define (replace-scene scene)
"Replace the current stage with STAGE."