summaryrefslogtreecommitdiff
path: root/scenes/game.scm
diff options
context:
space:
mode:
Diffstat (limited to 'scenes/game.scm')
-rw-r--r--scenes/game.scm29
1 files changed, 18 insertions, 11 deletions
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)))))