diff options
-rw-r--r-- | test-subject/game.scm | 75 |
1 files changed, 47 insertions, 28 deletions
diff --git a/test-subject/game.scm b/test-subject/game.scm index 4a03343..133fb0c 100644 --- a/test-subject/game.scm +++ b/test-subject/game.scm @@ -50,7 +50,7 @@ (terminal-channel #:accessor terminal-channel #:init-thunk make-channel) (terminal-lines #:accessor terminal-lines #:init-form (make-ring-buffer 17)) (key-pad-locked? #:accessor key-pad-locked? #:init-value #t) - (audio-source #:accessor audio-source #:init-form (make-source #:loop? #t))) + (audio-source #:accessor audio-source #:init-thunk make-source)) (define-method (subject-name (game <game>)) (if (subject-name-known? game) @@ -150,8 +150,8 @@ (define-method (increment-friendship (game <game>)) (set! (friendship game) (+ (friendship game) 1))) -(define-method (intro (game <game>)) - (set! (state game) 'intro) +(define-method (splash (game <game>)) + (set! (state game) 'splash) (attach-to game (make <sprite> #:name 'intro-lightness @@ -163,9 +163,9 @@ #:align 'center #:vertical-align 'center #:position (vec2 (/ game-width 2.0) (/ game-height 2.0)))) - (set! (text (& game intro-splash)) "a nonexistent game studio presents") + (set! (text (& game intro-splash)) "Nonexistent Game Studio sheepishly presents") (sleep 120) - (set! (text (& game intro-splash)) "a lisp game jam entry") + (set! (text (& game intro-splash)) "The Test Subject - A Spring Lisp Game Jam 2021 submission") (sleep 120) (tween 120 white black (lambda (color) @@ -173,6 +173,10 @@ #:interpolate color-lerp) (detach (& game intro-lightness) (& game intro-splash)) + (intro game)) + +(define-method (intro (game <game>)) + (set! (state game) 'intro) (attach-to game (make <sprite> #:name 'intro-darkness @@ -717,20 +721,19 @@ diz--")) "> Enter a code?" '(("Yes" #t) ("No" #f))) - (let ((g (& game explore-group))) - (detach g) - (if (string=? (pin-entry game) "181816") - (begin - (attach-to game g) - (dialog game player-display-name - "> It worked! The tray below opens to reveal a key inside.") - (dialog game player-display-name - "> You put the key in your pocket.") - (set! (has-fridge-key? game) #t)) - (begin - (attach-to game g) - (dialog game player-display-name - "> Hmm, that wasn't right.")))))) + (hide (& game background)) + (if (string=? (pin-entry game) "181816") + (begin + (show (& game background)) + (dialog game player-display-name + "> It worked! The tray below opens to reveal a key inside.") + (dialog game player-display-name + "> You put the key in your pocket.") + (set! (has-fridge-key? game) #t)) + (begin + (show (& game background)) + (dialog game player-display-name + "> Hmm, that wasn't right."))))) ((receptacle) (if (eq? (cartridge game) 'in-hand) (begin @@ -751,14 +754,17 @@ what.")))) (define-method (explore (game <game>)) (define (tint-all color) - (set! (tint (& game explore-group room-background)) color) - (set! (tint (& game explore-group door-lock sprite)) color) - (set! (tint (& game explore-group door sprite)) color) - (set! (tint (& game explore-group control-panel sprite)) color) - (set! (tint (& game explore-group terminal sprite)) color) - (set! (tint (& game explore-group fridge sprite)) color) - (set! (tint (& game explore-group window sprite)) color) - (set! (tint (& game explore-group notebook sprite)) color)) + ;; No-op if the user has done something to change state before the fade + ;; in/out is done. + (when (eq? (state game) 'explore) + (set! (tint (& game explore-group room-background)) color) + (set! (tint (& game explore-group door-lock sprite)) color) + (set! (tint (& game explore-group door sprite)) color) + (set! (tint (& game explore-group control-panel sprite)) color) + (set! (tint (& game explore-group terminal sprite)) color) + (set! (tint (& game explore-group fridge sprite)) color) + (set! (tint (& game explore-group window sprite)) color) + (set! (tint (& game explore-group notebook sprite)) color))) (define (fade-in) (tween 120 black white tint-all #:interpolate color-lerp)) @@ -896,6 +902,7 @@ if you would just open the door.") (lambda () (play-device-sound) (proc)))) + (set! (state game) 'explore) (attach-to game (make <widget> #:name 'explore-group @@ -952,6 +959,7 @@ if you would just open the door.") #:position (vec2 109.0 40.0) #:listeners `((click . ,(run-on-left-click* game open-terminal))))))) + (set-source-loop! (audio-source game) #t) (set-source-audio! (audio-source game) (asset-ref gameplay-music)) (source-play (audio-source game)) (fade-in)) @@ -1003,6 +1011,15 @@ if you would just open the door.") "> You begin to smell something... different.") (dialog game player-display-name "> The room becomes hazy. You feel light headed.") + (attach-to game + (make <sprite> + #:name 'bad-ending-2-background + #:rank 99 + #:texture darkness)) + (tween 120 (transparency 0.0) (transparency 1.0) + (lambda (color) + (set! (tint (& game bad-ending-2-background)) color)) + #:interpolate color-lerp) (dialog game (subject-name game) "It didn't work the first time. Did you really think it would work the second time?") @@ -1020,6 +1037,7 @@ time?") (set! (text (& game credits)) line) (sleep 120)) (set! (state game) 'credits) + (set-source-loop! (audio-source game) #f) (set-source-audio! (audio-source game) (asset-ref credits-music)) (source-play (audio-source game)) (attach-to game @@ -1054,6 +1072,7 @@ time?") (set! (tint (& game background)) color)) #:interpolate color-lerp) (detach-all game) + (source-stop (audio-source game)) (reset-game game) (intro game)) @@ -1083,7 +1102,7 @@ time?") #:width (round (* game-width .75)) #:height 60.0))))) (run-script game - (intro game))) + (splash game))) (define-method (on-mouse-move (game <game>) x y x-rel y-rel buttons) (case (state game) |