summaryrefslogtreecommitdiff
path: root/scenes
diff options
context:
space:
mode:
Diffstat (limited to 'scenes')
-rw-r--r--scenes/death.scm1
-rw-r--r--scenes/game.scm29
-rw-r--r--scenes/intro.scm23
3 files changed, 33 insertions, 20 deletions
diff --git a/scenes/death.scm b/scenes/death.scm
index 3c1377e..21e18b2 100644
--- a/scenes/death.scm
+++ b/scenes/death.scm
@@ -140,7 +140,6 @@ quite short."))
(define (load-scene)
(set! death-text (list-ref texts (random (length texts))))
- (source-stop)
(source-play
(make-source #:audio (asset-ref music)
#:loop? #true))
diff --git a/scenes/game.scm b/scenes/game.scm
index 2f6fc33..3e95fe5 100644
--- a/scenes/game.scm
+++ b/scenes/game.scm
@@ -82,15 +82,15 @@ map's positions layer."
(define player-grid-x-offset 8)
(define player-grid-y-offset 0)
+(define *background-music* #false)
(define (load-scene)
- (source-stop)
- (source-play
- (make-source #:audio
- (asset-ref music)
- #:loop? #false ; TODO: loops only first chunk!
- ))
+ (set! *background-music*
+ (make-source #:audio (asset-ref music)
+ #:loop? #true))
+ (source-play *background-music*)
+
(set! *player* (lorenzo #:start-position
(location "player")))
(update-animated-sprite *player*)
@@ -182,7 +182,7 @@ map's positions layer."
(lambda ()
(tween 2 0.0 1.0
(lambda (a)
- (set-source-volume! background-music a))
+ (set-source-volume! *background-music* a))
#:ease ease-out-sine)))
;; Fade in
@@ -251,7 +251,14 @@ map's positions layer."
(define scene
- `(#:name "game"
- #:load ,load-scene
- #:draw ,draw-scene
- #:update ,update-scene))
+ (list
+ #:name "game"
+ #:load load-scene
+ #:draw draw-scene
+ #:update update-scene
+ #:quit
+ (lambda ()
+ (and *background-music*
+ ;; XXX This crashes so we just turn down the volume.
+ ;;(source-stop *background-music*)
+ (set-source-volume! *background-music* 0)))))
diff --git a/scenes/intro.scm b/scenes/intro.scm
index 422d2ec..68d5b79 100644
--- a/scenes/intro.scm
+++ b/scenes/intro.scm
@@ -67,15 +67,17 @@ The sunshine warms and blinds.
The leaf begins to dry."))
(define welcome-text #false)
+(define *background-music* #false)
(define (load-scene)
(set! *random-state* (random-state-from-platform))
(set! welcome-text (list-ref texts (random (length texts))))
- (source-play
- (make-source #:audio
- (asset-ref music)
- #:loop? #false))
+
+ (set! *background-music*
+ (make-source #:audio (asset-ref music)
+ #:loop? #false))
+ (source-play *background-music*)
(with-agenda
agenda
@@ -131,7 +133,12 @@ The leaf begins to dry."))
(define scene
- `(#:name "intro"
- #:load ,load-scene
- #:draw ,draw-scene
- #:update ,update-scene))
+ (list
+ #:name "intro"
+ #:load load-scene
+ #:draw draw-scene
+ #:update update-scene
+ #:quit
+ (lambda ()
+ (and *background-music*
+ (source-stop *background-music*)))))