diff options
-rw-r--r-- | assets/images/button-press.png | bin | 0 -> 657 bytes | |||
-rw-r--r-- | assets/images/button-press.xcf | bin | 0 -> 903 bytes | |||
-rw-r--r-- | assets/images/control-panel.png | bin | 0 -> 1132 bytes | |||
-rw-r--r-- | assets/images/control-panel.xcf | bin | 0 -> 5179 bytes | |||
-rw-r--r-- | assets/images/door.png | bin | 0 -> 1174 bytes | |||
-rw-r--r-- | assets/images/door.xcf | bin | 0 -> 7031 bytes | |||
-rw-r--r-- | assets/images/fridge.png | bin | 0 -> 874 bytes | |||
-rw-r--r-- | assets/images/fridge.xcf | bin | 0 -> 4325 bytes | |||
-rw-r--r-- | assets/images/room.png | bin | 2034 -> 1947 bytes | |||
-rw-r--r-- | assets/images/room.xcf | bin | 5895 -> 4849 bytes | |||
-rw-r--r-- | assets/images/terminal-background.xcf | bin | 8671 -> 5705 bytes | |||
-rw-r--r-- | assets/images/window.png | bin | 0 -> 1272 bytes | |||
-rw-r--r-- | assets/images/window.xcf | bin | 0 -> 48387 bytes | |||
-rw-r--r-- | game.scm | 125 |
14 files changed, 114 insertions, 11 deletions
diff --git a/assets/images/button-press.png b/assets/images/button-press.png Binary files differnew file mode 100644 index 0000000..a53ac66 --- /dev/null +++ b/assets/images/button-press.png diff --git a/assets/images/button-press.xcf b/assets/images/button-press.xcf Binary files differnew file mode 100644 index 0000000..574be69 --- /dev/null +++ b/assets/images/button-press.xcf diff --git a/assets/images/control-panel.png b/assets/images/control-panel.png Binary files differnew file mode 100644 index 0000000..15c8026 --- /dev/null +++ b/assets/images/control-panel.png diff --git a/assets/images/control-panel.xcf b/assets/images/control-panel.xcf Binary files differnew file mode 100644 index 0000000..6da1bfb --- /dev/null +++ b/assets/images/control-panel.xcf diff --git a/assets/images/door.png b/assets/images/door.png Binary files differnew file mode 100644 index 0000000..9c47ecb --- /dev/null +++ b/assets/images/door.png diff --git a/assets/images/door.xcf b/assets/images/door.xcf Binary files differnew file mode 100644 index 0000000..4f782ac --- /dev/null +++ b/assets/images/door.xcf diff --git a/assets/images/fridge.png b/assets/images/fridge.png Binary files differnew file mode 100644 index 0000000..652a1b2 --- /dev/null +++ b/assets/images/fridge.png diff --git a/assets/images/fridge.xcf b/assets/images/fridge.xcf Binary files differnew file mode 100644 index 0000000..f473f0e --- /dev/null +++ b/assets/images/fridge.xcf diff --git a/assets/images/room.png b/assets/images/room.png Binary files differindex bece318..cbb89a3 100644 --- a/assets/images/room.png +++ b/assets/images/room.png diff --git a/assets/images/room.xcf b/assets/images/room.xcf Binary files differindex 9b8cde6..df7c083 100644 --- a/assets/images/room.xcf +++ b/assets/images/room.xcf diff --git a/assets/images/terminal-background.xcf b/assets/images/terminal-background.xcf Binary files differindex f04f029..1b07e7a 100644 --- a/assets/images/terminal-background.xcf +++ b/assets/images/terminal-background.xcf diff --git a/assets/images/window.png b/assets/images/window.png Binary files differnew file mode 100644 index 0000000..aba021e --- /dev/null +++ b/assets/images/window.png diff --git a/assets/images/window.xcf b/assets/images/window.xcf Binary files differnew file mode 100644 index 0000000..ebf54b3 --- /dev/null +++ b/assets/images/window.xcf @@ -28,6 +28,7 @@ (define game-width 640) (define game-height 360) (define player-display-name "") +(define thing-display-name "??????") ;;; @@ -35,11 +36,16 @@ ;;; (define-asset dialog-box-texture (load-image "assets/images/dialog-box.png")) +(define-asset button-press-texture (load-image "assets/images/button-press.png")) (define-asset darkness (load-image "assets/images/darkness.png")) (define-asset room-background (load-image "assets/images/room.png")) (define-asset door-lock-texture (load-image "assets/images/door-lock.png")) +(define-asset door-texture (load-image "assets/images/door.png")) (define-asset terminal-texture (load-image "assets/images/terminal.png")) (define-asset terminal-background (load-image "assets/images/terminal-background.png")) +(define-asset control-panel-texture (load-image "assets/images/control-panel.png")) +(define-asset fridge-texture (load-image "assets/images/fridge.png")) +(define-asset window-texture (load-image "assets/images/window.png")) (define-asset monogram-font (load-font "assets/fonts/monogram_extended.ttf" 12)) (define-asset monogram-font-big (load-font "assets/fonts/monogram_extended.ttf" 24)) @@ -121,7 +127,7 @@ (define-theme gui-theme (<widget> (font monogram-font)) (<button> (background dialog-box-texture) - (press-background dialog-box-texture)) + (press-background button-press-texture)) (<text-box> (background dialog-box-texture))) (define-class <game> (<gui-scene>) @@ -133,11 +139,15 @@ (terminal-channel #:accessor terminal-channel #:init-thunk make-channel) (terminal-lines #:accessor terminal-lines #:init-form (make-ring-buffer 17))) -(define-method (reboot (game <game>)) +(define-method (reset-game (game <game>)) + (set! (friendship game) 0) (set! (click-channel game) (make-channel)) (set! (terminal-locked? game) #t) (set! (terminal-channel game) (make-channel)) - (set! (terminal-lines game) (make-ring-buffer 17)) + (set! (terminal-lines game) (make-ring-buffer 17))) + +(define-method (reboot (game <game>)) + (reset-game game) (next-method)) (define-method (detach-all (game <game>)) @@ -151,16 +161,54 @@ #t) #f))) -(define-method (dialog (game <game>) name line) +(define-method (dialog (game <game>) name line choices) (let ((old-state (state game)) (c (dialog-container game))) - (set! (state game) 'dialog) (attach-to game c) (set! (text (& c name-margin name)) name) (set! (text (& c text-box)) line) - (channel-get (click-channel game)) - (detach c) - (set! (state game) old-state))) + (match choices + (() + (set! (state game) 'dialog) + (channel-get (click-channel game)) + (detach c) + (set! (state game) old-state) + #t) + ((_ ...) + (set! (state game) 'dialog-choice) + (let* ((choice-channel (make-channel)) + (choice-container + (parameterize ((current-theme gui-theme)) + (make <vertical-container> + #:name 'choices + #:rank 9 + #:position (vec2 (/ game-width 4.0) + 76.0) + #:children + (map (match-lambda + ((str value) + (make <margin-container> + #:margin 2.0 + #:children + (list (make <button> + #:width (/ game-width 2.0) + #:height 24.0 + #:text str + #:listeners + `((click . ,(run-on-left-click game + (lambda () + (channel-put! choice-channel + value)))))))))) + choices))))) + (attach-to game choice-container) + (let ((choice (channel-get choice-channel))) + (detach choice-container) + (detach c) + (set! (state game) old-state) + choice)))))) + +(define-method (dialog (game <game>) name line) + (dialog game name line '())) (define-method (intro (game <game>)) (set! (state game) 'intro) @@ -171,6 +219,15 @@ (dialog game player-display-name "> ...") (dialog game player-display-name "> Where am I?") (dialog game player-display-name "> What is this place?") + (let ((choice (dialog game thing-display-name + "Coke or Pepsi?" + '(("Coke" coke) + ("Pepsi" pepsi))))) + (if (eq? choice 'coke) + (begin + (set! (friendship game) 3) + (dialog game thing-display-name "Excellent choice!")) + (dialog game thing-display-name "Ew gross"))) (detach-all game) (explore game)) @@ -400,7 +457,11 @@ (define (tint-all color) (set! (tint (& game room-background)) color) (set! (tint (& game door-lock sprite)) color) - (set! (tint (& game terminal sprite)) color)) + (set! (tint (& game door sprite)) color) + (set! (tint (& game control-panel sprite)) color) + (set! (tint (& game terminal sprite)) color) + (set! (tint (& game fridge sprite)) color) + (set! (tint (& game window sprite)) color)) (define (fade-in) (tween 60 black white tint-all #:interpolate color-lerp)) @@ -411,15 +472,28 @@ (run-script game (fade-out) (detach-all game) - (if (> (friendship game) 3) + (if (>= (friendship game) 3) (good-ending game) (bad-ending-1 game)))) (define (open-door) (if (string=? (pin-entry game) "314159") (end-game) - (pk 'invalid-access-code))) + (dialog game player-display-name + "> Hmm, no luck."))) + (define (inspect-door) + (dialog game player-display-name + "> The door is made from thick steel. Looks like it has an electronic lock.")) (define (open-terminal) (terminal game)) + (define (open-control-panel) + (dialog game player-display-name + "> Oooh, knobs and blinking lights.")) + (define (open-fridge) + (dialog game player-display-name + "> Any leftovers in here?")) + (define (inspect-window) + (dialog game player-display-name + "> The window is covered in some sort of film and I can't see through it.")) (attach-to game (make <sprite> #:name 'room-background @@ -432,6 +506,34 @@ #:listeners `((click . ,(run-on-left-click game open-door)))) (make <device> + #:name 'door + #:rank 1 + #:texture door-texture + #:position (vec2 445.0 40.0) + #:listeners + `((click . ,(run-on-left-click game inspect-door)))) + (make <device> + #:name 'control-panel + #:rank 1 + #:texture control-panel-texture + #:position (vec2 230.0 40.0) + #:listeners + `((click . ,(run-on-left-click game open-control-panel)))) + (make <device> + #:name 'fridge + #:rank 1 + #:texture fridge-texture + #:position (vec2 0.0 40.0) + #:listeners + `((click . ,(run-on-left-click game open-fridge)))) + (make <device> + #:name 'window + #:rank 1 + #:texture window-texture + #:position (vec2 112.0 197.0) + #:listeners + `((click . ,(run-on-left-click game inspect-window)))) + (make <device> #:name 'terminal #:rank 1 #:texture terminal-texture @@ -504,6 +606,7 @@ ((good-ending bad-ending-1) (when (eq? button 'left) (detach-all game) + (reset-game game) (run-script game (intro game)))) ((terminal) |