summaryrefslogtreecommitdiff
path: root/scenes
diff options
context:
space:
mode:
authorRicardo Wurmus <rekado@elephly.net>2018-07-27 12:33:39 +0200
committerRicardo Wurmus <rekado@elephly.net>2018-07-27 17:15:50 +0200
commitb81b62e47c1367f0fb170baf7f9c509b65109cf9 (patch)
tree8581b044bb151184af971e1bc0608083afa787cd /scenes
parentfe9163e763e1478f64f2f729e7175dba1287e408 (diff)
Fade out on death.
Diffstat (limited to 'scenes')
-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)