summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--scenes/game.scm17
1 files changed, 15 insertions, 2 deletions
diff --git a/scenes/game.scm b/scenes/game.scm
index d2e8450..7ec2306 100644
--- a/scenes/game.scm
+++ b/scenes/game.scm
@@ -206,10 +206,19 @@ positions layer."
(when (collides? player game "collision")
(vec2-sub! pos vel)))))))
+(define-method (die (game <game>))
+ "Fade out and switch to death scene."
+ (let ((fade (child-ref (parent game) 'fade-box)))
+ (script
+ (tween 60 0.0 1.0
+ (lambda (alpha)
+ (set! (color fade)
+ (make-color 0 0 0 alpha))))
+ (switch-scene (root-node) (death)))))
+
(define-method (on-key-press (game <game>) key modifiers repeat?)
(let ((player (child-ref game 'player)))
- (when (eq? key 'q)
- (switch-scene (root-node) (death)))
+ (when (eq? key 'q) (die game))
(let ((who (talking? player)))
(cond
((and (not who) (eq? 'space key))
@@ -429,6 +438,10 @@ conversation."
(make <node-2d>
#:children
(list game
+ (make <filled-rect>
+ #:name 'fade-box
+ #:region (make-rect 0.0 0.0 %width %height)
+ #:color (make-color 0 0 0 0))
(make <node-2d>
#:name 'text-bubble
#:position (vec2 0 0)