From c53efe4e4f8c3c08ac3d0e256013785f54498f73 Mon Sep 17 00:00:00 2001 From: Ricardo Wurmus Date: Mon, 6 Nov 2023 13:33:38 +0100 Subject: death: Detune music on end. --- scenes/death.scm | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) (limited to 'scenes') diff --git a/scenes/death.scm b/scenes/death.scm index 7ee3674..afa3981 100644 --- a/scenes/death.scm +++ b/scenes/death.scm @@ -19,6 +19,7 @@ #:use-module (chickadee) #:use-module (chickadee audio) #:use-module (chickadee math) + #:use-module (chickadee math easings) #:use-module (chickadee math vector) #:use-module ((chickadee graphics color) #:select (make-color)) #:use-module (chickadee graphics text) @@ -139,11 +140,11 @@ quite short.")) (define (load-scene) + (define background-music + (make-source #:audio (asset-ref music) + #:loop? #true)) (set! death-text (list-ref texts (random (length texts)))) - (source-play - (make-source #:audio (asset-ref music) - #:loop? #true)) - + (source-play background-music) (set! *player* (lorenzo #:start-position (vec2 (+ (/ %width 2) 25) (- (/ %height 2) 20)) @@ -157,6 +158,8 @@ quite short.")) (update-animated-sprite *reaper*) (set! (walk-speed *reaper*) 0.3) + (define detune-music (make-channel)) + (with-agenda agenda (spawn-script @@ -170,6 +173,19 @@ quite short.")) (make-color 0 0 0 alpha)))) (abort-game))) + (spawn-script + (lambda () + (wait-until (channel-get detune-music)) + (tween 20 1.0 0.0 + (lambda (a) + (set-source-pitch! background-music a) + (set-source-volume! background-music a) + (set! fade-box-fill + (make-color 0 0 0 a))) + #:ease ease-out-sine) + (source-stop background-music) + (abort-game))) + (script ;; Fade in (tween 0.25 1.0 0.0 @@ -220,7 +236,6 @@ quite short.")) labels))) credits) (sleep 5) - (for-each (lambda (text) (let ((label (make