summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--scenes/game.scm78
1 files changed, 50 insertions, 28 deletions
diff --git a/scenes/game.scm b/scenes/game.scm
index fae998d..2533310 100644
--- a/scenes/game.scm
+++ b/scenes/game.scm
@@ -19,6 +19,7 @@
(define-module (scenes game)
#:use-module (chickadee audio)
#:use-module (chickadee input keyboard)
+ #:use-module (chickadee math easings)
#:use-module (chickadee math rect)
#:use-module (chickadee math vector)
#:use-module (chickadee render color)
@@ -210,6 +211,7 @@ positions layer."
(define-method (die (game <game>))
"Fade out and switch to death scene."
(let ((fade (child-ref (parent game) 'fade-box)))
+ (set! (status game) 'dying)
(script
(tween 60 0.0 1.0
(lambda (alpha)
@@ -218,14 +220,15 @@ positions layer."
(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) (die game))
- (let ((who (talking? player)))
- (cond
- ((and (not who) (eq? 'space key))
- (handle-action player))
- ((and who (not repeat?))
- (handle-talking player key))))))
+ (when (eq? (status game) 'playing)
+ (let ((player (child-ref game 'player)))
+ (when (eq? key 'q) (die game))
+ (let ((who (talking? player)))
+ (cond
+ ((and (not who) (eq? 'space key))
+ (handle-action player))
+ ((and who (not repeat?))
+ (handle-talking player key)))))))
(define (handle-action player)
"Check if the PLAYER is on any region of the map where an action can
@@ -453,23 +456,42 @@ conversation."
(let* ((player (child-ref game 'player))
(current-lifetime (lifetime player)))
(if (< current-lifetime 0)
- (set! (status game) 'game-over)
- (set! (lifetime player) (- current-lifetime 1)))))))
- (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)
- #:visible? #f
- #:children
- (list (make <filled-rect>
- #:name 'text-bubble-box
- #:region (make-rect 0.0 0.0 %width 80)
- #:position (vec2 0 0)
- #:rank -10 ; background
- #:color (make-color 0 0 0 0.5))))))))
+ (die game)
+ (set! (lifetime player) (- current-lifetime 1))))))
+ (script
+ (tween 60 0.0 1.0
+ (lambda (a)
+ (set-music-volume! a)
+ (sleep 10))
+ #:ease ease-out-sine)))
+ (let ((container
+ (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 <sprite>
+ #:name 'vignette
+ #:texture (asset-ref vignette-image))
+ (make <node-2d>
+ #:name 'text-bubble
+ #:position (vec2 0 0)
+ #:visible? #f
+ #:children
+ (list (make <filled-rect>
+ #:name 'text-bubble-box
+ #:region (make-rect 0.0 0.0 %width 80)
+ #:position (vec2 0 0)
+ #:rank -10 ; background
+ #:color (make-color 0 0 0 0.5))))))))
+ (with-agenda
+ (agenda container)
+ (let ((fade (child-ref container 'fade-box)))
+ (script
+ (tween 15 1.0 0.0
+ (lambda (alpha)
+ (set! (color fade)
+ (make-color 0 0 0 alpha)))))))
+ container)))