From b81b62e47c1367f0fb170baf7f9c509b65109cf9 Mon Sep 17 00:00:00 2001 From: Ricardo Wurmus Date: Fri, 27 Jul 2018 12:33:39 +0200 Subject: Fade out on death. --- scenes/game.scm | 17 +++++++++++++++-- 1 file 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 )) + "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 ) 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 #:children (list game + (make + #:name 'fade-box + #:region (make-rect 0.0 0.0 %width %height) + #:color (make-color 0 0 0 0)) (make #:name 'text-bubble #:position (vec2 0 0) -- cgit v1.2.3