summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Thompson <dthompson2@worcester.edu>2018-08-30 08:12:28 -0400
committerDavid Thompson <dthompson2@worcester.edu>2018-08-30 08:13:12 -0400
commit9b5bec99454995b40713e8af03b5853a609f2f25 (patch)
tree34e925628bb2e6b76c2ba2650842bc02a7f56c2e
parenta5e0a9378daaee6a04ce8e2298e9d87137ee6048 (diff)
kernel: Add previous-scene procedure.
* starling/kernel.scm (previous-scene): New procedure.
-rw-r--r--starling/kernel.scm13
1 files changed, 10 insertions, 3 deletions
diff --git a/starling/kernel.scm b/starling/kernel.scm
index 25e92b6..078b6df 100644
--- a/starling/kernel.scm
+++ b/starling/kernel.scm
@@ -58,6 +58,7 @@
elapsed-time
fps
current-scene
+ previous-scene
push-scene
pop-scene
replace-scene)
@@ -282,10 +283,16 @@
(deactivate kernel)
(close-window! (window kernel))))))
-(define-method (current-scene)
+(define (current-scene)
"Return the currently active scene"
- (and (not (null? (scenes (current-kernel))))
- (car (scenes (current-kernel)))))
+ (match (scenes (current-kernel))
+ (() #f)
+ ((scene . rest) scene)))
+
+(define (previous-scene)
+ (match (scenes (current-kernel))
+ ((or () (_)) #f)
+ ((_ scene . rest) scene)))
(define-method (push-scene (scene <scene>))
"Make SCENE the currently active scene and remember the previously