summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRicardo Wurmus <rekado@elephly.net>2018-08-08 18:54:29 +0200
committerRicardo Wurmus <rekado@elephly.net>2018-08-08 18:54:29 +0200
commitcc2ec6e8536752b5070cc264ce4fa42d62806b64 (patch)
tree29feba89e31a7c2a34dc216178b35a6cf42063b0
parent1d173d537521db459fb48fa7666e571f932072ce (diff)
death: Trigger fade out only once.
-rw-r--r--scenes/death.scm15
1 files changed, 9 insertions, 6 deletions
diff --git a/scenes/death.scm b/scenes/death.scm
index 1e35563..8f7048a 100644
--- a/scenes/death.scm
+++ b/scenes/death.scm
@@ -43,6 +43,7 @@
(define-asset vignette-image (load-image "assets/images/vignette.png"))
(define-class <death> (<scene>)
+ (quitting? #:accessor quitting? #:init-form #f)
(tile-map #:accessor tile-map #:init-form death-map)
(pretend-walking? #:accessor pretend-walking? #:init-form #f))
@@ -200,12 +201,14 @@ void main (void) {
(define-method (on-key-press (death <death>) key mods repeat?)
;; Fade out
- (script
- (tween 60 0.0 1.0
- (lambda (alpha)
- (set! (color (child-ref (parent death) 'fade-all))
- (make-color 0 0 0 alpha))))
- (abort-game)))
+ (unless (quitting? death)
+ (set! (quitting? death) #t)
+ (script
+ (tween 60 0.0 1.0
+ (lambda (alpha)
+ (set! (color (child-ref (parent death) 'fade-all))
+ (make-color 0 0 0 alpha))))
+ (abort-game))))
(define-method (update (game <death>) dt)
;; Keep the player (and the fade box) in the centre