diff --git a/desktop/src-common/advent/core.clj b/desktop/src-common/advent/core.clj index 567bfc2e..3243397c 100644 --- a/desktop/src-common/advent/core.clj +++ b/desktop/src-common/advent/core.clj @@ -7,6 +7,7 @@ [advent.screens.dialogue :as dialogue] [advent.screens.title :as title] [advent.screens.inventory :as inventory] + [advent.screens.test :as test] [advent.screens.safe :as safe] [clojure.pprint] [advent.pathfind]) diff --git a/desktop/src-common/advent/screens/#title.clj# b/desktop/src-common/advent/screens/#title.clj# deleted file mode 100644 index 1630170e..00000000 --- a/desktop/src-common/advent/screens/#title.clj# +++ /dev/null @@ -1,220 +0,0 @@ -(ns advent.screens.title - (:require [play-clj.core :refer :all] - [play-clj.math :refer :all] - [play-clj.ui :refer :all] - [play-clj.utils :refer :all] - [play-clj.g2d :refer :all] - [advent.utils :as utils] - [advent.tween :as tween] - [advent.screens.scene :as scene] - [advent.screens.dialogue :as dialogue] - [advent.screens.title :as title] - [advent.screens.inventory :as inventory] - [advent.screens.safe :as safe] - [advent.screens.fade :as fade] - ) - (:import [com.badlogic.gdx.graphics Pixmap Pixmap$Filter Texture Texture$TextureFilter] - [com.badlogic.gdx.graphics.g2d TextureRegion] - [com.badlogic.gdx.utils.viewport FitViewport] - [com.badlogic.gdx.scenes.scene2d.ui Slider$SliderStyle] - [com.badlogic.gdx.scenes.scene2d.utils Align] - [com.badlogic.gdx Application Audio Files Game Gdx Graphics Input - InputMultiplexer InputProcessor Net Preferences Screen])) - - -(defn get-color [e mouse-pos] - (if (utils/intersects? e mouse-pos) - (color :yellow) - (color 0.6 1.0 1.0 1.0))) - -(defn style-label [e font mouse-pos] - (label! e :set-style (style :label font (get-color e mouse-pos))) - e) - -(defn style-slider [s mouse-pos] - (if (utils/intersects? s mouse-pos) - (slider! s :set-style (:hover s)) - (slider! s :set-style (:default s))) - s) - -(defn center [e] - (assoc e :x (- (/ 1280 2) (/ (or (:width e) (.getWidth (:object e))) 2)))) - - -(defn get-dir [old-x new-x] - (if (< old-x new-x) - :right - :left)) - -(defn fly-ego [screen entities] - (let [speed 0.07 - pos-f (- (* (:total-time screen) speed) (int (* (:total-time screen) speed))) - v (vector-2 0 0) - a (catmull-rom-spline! (:path (:flying-ego entities)) :value-at v pos-f) - direction (get-dir (get-in entities [:flying-ego :x]) (vector-2! v :x)) - x (vector-2! v :x) - y (vector-2! v :y)] - (update-in entities [:flying-ego] - \(update-in\ entities\ \[:flying-ego\] - -\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ merge\ {:x\ \(vector-2\!\ v\ :x\) - -\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ :y\ \(vector-2\!\ v\ :y\)} - -\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \(get-in\ entities\ \[:flying-ego\ direction\]\) - -\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \)\)\) - assoc :x xb :y y - - - ))) - -(defn flip [t] - (let [flipped (texture t)] - (texture! flipped :flip true false) - flipped)) - -(defscreen title-screen - :on-show - (fn [screen entities] - - (utils/setup-viewport screen 1280 960) - (utils/load-settings!) - (let [font (utils/get-font "ego/font.fnt") - start-playing (assoc (label "Begin quest" (style :label font (color 0.6 1.0 1.0 1.0))) :x 0 :y 280 :height 32 :origin-x 0 :origin-y 0) - start-playing (center start-playing) - fullscreen (assoc (label "Windowed" (style :label font (color 0.6 1.0 1.0 1.0))) :x 0 :y (- 280 (* 32 5)) :height 32 :origin-x 0 :origin-y 0) - fullscreen (center fullscreen) - quit (assoc (label "End quest" (style :label font (color 0.6 1.0 1.0 1.0))) :x 0 :y (- 280 (* 32 6)) :height 32 :origin-x 0 :origin-y 0) - quit (center quit) - music (utils/make-music "intro.ogg") - ui-skin (skin "ui/ui.json") - ] - (label! start-playing :set-alignment Align/center) - (label! quit :set-alignment Align/center) - (label! fullscreen :set-alignment Align/center) - - {:overlay (assoc (texture "title.png" ) :x 0 :y 0 :scale-x 4 :scale-y 4 :origin-x 0 :origin-y 0) - :fade (assoc (texture "black.png") - :scale-x 80 - :scale-y 80 - :opacity 1.0 - :origin-x 0 - :origin-y 0) - :flying-ego (assoc (texture "ego/flying.png") - :left (flip (texture "ego/flying.png")) - :right (texture "ego/flying.png") - :scale-x 5 - :scale-y 5 - :origin-x 2 - :origin-y 0 - :path (catmull-rom-spline (map #(apply vector-2* %) [[-800 450] [1280 450] [2000 100] [0 100] [-800 300] [1280 300] [2000 450]]) true) - :x 450 - :y 650) - :clouds (assoc (particle-effect "titleclouds" :reset :start) :x 640 :y 480 ) - :toolbox (center (assoc (nine-patch {:region (:object (texture "talk-bg-2.png")) :left 9 :top 9 :right 9 :bottom 9}) - :y 58 :width 500 :height 282)) - - :music-label (-> (label "Music" (style :label font (color 1.0 1.0 1.0 1.0))) - (assoc :x 0 :y (- 280 (* 32 1)) :height 32 :origin-x 0 :origin-y 0) - center) - :music-volume-slider (-> (slider {:min 0 :max 100 :step 1} ui-skin :set-value (:music-volume @utils/settings)) - (assoc :x (- (/ 1280 2) 150) - :width 300 - :y (- 280 (* 32 2)) - :hover (skin! ui-skin :get "default-horizontal-hover" Slider$SliderStyle) - :default (skin! ui-skin :get "default-horizontal" Slider$SliderStyle))) - - :sound-label (-> - (label "FX" (style :label font (color 1.0 1.0 1.0 1.0))) - (assoc :x 0 :y (- 280 (* 32 3)) :height 32 :origin-x 0 :origin-y 0) - center) - - - :sound-volume-slider (assoc (slider {:min 0 :max 100 :step 1 } ui-skin :set-value (:sound-volume @utils/settings)) - :width 300 - :x ( - (/ 1280 2) - 150) - :y (- 280 (* 32 4)) - :hover (skin! ui-skin :get "default-horizontal-hover" Slider$SliderStyle) - :default (skin! ui-skin :get "default-horizontal" Slider$SliderStyle)) - :font font - :music music - :volume 1.0 - :start-playing start-playing - :quit quit - :fullscreen fullscreen - :tweens {:fade-in (tween/tween :fade-in screen [:fade :opacity] 1.0 0.0 1.0 - :finish #(do (utils/play-sound (:music %)) %) - :ease tween/ease-in-quadratic)}})) - - :on-render - (fn [screen [entities]] - - (clear!) - (let [entities (utils/apply-tweens screen entities (:tweens entities)) - entities (fly-ego screen entities)] - (music! (:music entities) :set-volume (utils/current-music-volume (:volume entities))) - - (render! screen [(:overlay entities) (:clouds entities) (:flying-ego entities) (:toolbox entities) (:start-playing entities) (:quit entities) (:fullscreen entities) (:music-label entities) (:music-volume-slider entities) (:sound-label entities) (:sound-volume-slider entities) (:fade entities) ]) - entities)) - - :show-screen (fn [entities] - entities) - - :on-mouse-moved (fn [screen [entities]] - (let [[x y] (utils/unproject screen)] - (style-label (:start-playing entities) (get-in entities [:font]) [x y]) - (style-label (:fullscreen entities) (get-in entities [:font]) [x y]) - (style-label (:quit entities) (get-in entities [:font]) [x y]) - (style-slider (:music-volume-slider entities) [x y]) - (style-slider (:sound-volume-slider entities) [x y]) - entities)) - :on-ui-changed - (fn [screen [entities]] - (println (slider! (:music-volume-slider entities) :get-value)) - (if (= 0.0 (slider! (:music-volume-slider entities) :get-value)) - (throw (Exception.))) - (swap! utils/settings - assoc - :music-volume (slider! (:music-volume-slider entities) :get-value) - :sound-volume (slider! (:sound-volume-slider entities) :get-value)) - - (utils/save-settings!) - entities) - - :on-touch-up (fn [screen [entities]] - (when-not (get-in entities [:tweens :fade-out]) - (let [[x y] (utils/unproject screen)] - (cond - (utils/intersects? (:start-playing entities) [x y]) - (-> entities - (assoc-in [:tweens :fade-out] - (tween/tween :fade-out screen [:fade :opacity] 0.0 1.0 1.0 - :finish (fn [entities] - (utils/stop-sound (:music entities)) - (set-screen! @(resolve 'advent.core/advent) scene/scene scene/hud dialogue/talking-screen dialogue/choice-screen inventory/inventory-screen safe/safe-screen fade/fade-screen) - entities) - :ease tween/ease-in-cubic)) - (assoc-in [:tweens :fade-out-music] - (tween/tween :fade-out-music screen [:volume] 1.0 0.0 1.0))) - (utils/intersects? (:quit entities) [x y]) - (-> entities - (assoc-in [:tweens :fade-out] - (tween/tween :fade-out screen [:fade :opacity] 0.0 1.0 1.0 - :finish (fn [entities] - (System/exit 0) - entities) - :ease tween/ease-in-cubic))) - - (utils/intersects? (:fullscreen entities) [x y]) - (if (.isFullscreen Gdx/graphics) - (on-gl (.setDisplayMode Gdx/graphics 1280 960 false) - (label! (:fullscreen entities) set-text "Windowed")) - (on-gl (.setDisplayMode Gdx/graphics - (.width (.getDesktopDisplayMode Gdx/graphics)) - (.height (.getDesktopDisplayMode Gdx/graphics)) - true) - (label! (:fullscreen entities) set-text "Fullscreen"))) - :else - nil)))) - - :on-resize (fn [{:keys [viewport width height]} [entities]] - (.update viewport width height) - nil)) diff --git a/desktop/src-common/advent/screens/rooms/castle_gate.clj b/desktop/src-common/advent/screens/rooms/castle_gate.clj index ac660cbd..d9e66049 100644 --- a/desktop/src-common/advent/screens/rooms/castle_gate.clj +++ b/desktop/src-common/advent/screens/rooms/castle_gate.clj @@ -144,6 +144,7 @@ :script (actions/get-script entities (actions/talk entities :ego "That's a big window!")) :scripts {:walkie-talkies (actions/get-script entities + (actions/play-animation entities :ego :idea) (actions/walk-to entities :ego [285 71]) (actions/walk-straight-to entities :ego [308 105] :face :left) (actions/add-entity entities :walkie-talkies (actions/start-animation (get-in @entities [:room :walkie-talkies]) diff --git a/desktop/src-common/advent/screens/rooms/cat_tree.clj b/desktop/src-common/advent/screens/rooms/cat_tree.clj index 718c206d..c844b618 100644 --- a/desktop/src-common/advent/screens/rooms/cat_tree.clj +++ b/desktop/src-common/advent/screens/rooms/cat_tree.clj @@ -239,7 +239,9 @@ (do (actions/walk-to entities :ego [60 100] :face :left) (actions/play-animation entities :ego :reach) - (actions/give entities :grass)) + (actions/give entities :grass) + (actions/do-dialogue entities :ego "Grass." + :ego "It's a high protein variety.")) (actions/talk entities :ego "I don't really need any more grass.")))} :grandma {:box [109 33 132 98] :script (actions/get-script entities (do-grandma-dialogue entities)) diff --git a/desktop/src-common/advent/screens/rooms/common.clj b/desktop/src-common/advent/screens/rooms/common.clj index aa46ec3d..47a7f4f5 100644 --- a/desktop/src-common/advent/screens/rooms/common.clj +++ b/desktop/src-common/advent/screens/rooms/common.clj @@ -60,7 +60,7 @@ :ego "'And please hurry, because we're being forced into a karaoke competition.'" :ego "'I'm about at my witt's end.'" :ego "'P.S., Guard that slingshot with your life!'" - :ego "'P.P.S., If anything goes wrong, you can look for my secret stash of helpful stuff behind a nearby r...'" + :ego "'P.P.S., You can look for my secret stash of helpful stuff behind a nearby r...'" :ego "It just cuts off there.")) (defn read-note-2 [entities] diff --git a/desktop/src-common/advent/screens/rooms/inside_antique.clj b/desktop/src-common/advent/screens/rooms/inside_antique.clj index fb0dbb91..eb197419 100644 --- a/desktop/src-common/advent/screens/rooms/inside_antique.clj +++ b/desktop/src-common/advent/screens/rooms/inside_antique.clj @@ -46,7 +46,7 @@ :shopkeep "Why?" :shopkeep "It belonged to my long lost son." :shopkeep "Why should I give it to you?") - :choices ["I just need it ok?" + :choices ["Because it's the choicest toy I've ever seen!" {:run #(actions/respond entities % :shopkeep "I'm sorry, it's not for sale.") :choices actions/something-else} @@ -97,7 +97,7 @@ :script (actions/get-script entities (actions/walk-to entities :ego [140 61] :face :left) (actions/play-animation entities :ego :reach) - (actions/talk entities :ego "It's a portrait. There's something on the back but I can't read it.") + (actions/talk entities :ego "It's a portrait. There's something on the back but it's too dim to read.") (actions/remove-entity entities :portrait) (actions/give entities :portrait)))) beard (utils/make-anim "inside-antique/beard.png" [26 52] 0.5 [0 1 0 2]) diff --git a/desktop/src-common/advent/screens/rooms/inside_cafeteria.clj b/desktop/src-common/advent/screens/rooms/inside_cafeteria.clj index 4601efff..e60b92b9 100644 --- a/desktop/src-common/advent/screens/rooms/inside_cafeteria.clj +++ b/desktop/src-common/advent/screens/rooms/inside_cafeteria.clj @@ -67,7 +67,8 @@ (actions/do-dialogue entities :warriors "Congratulations young master. Thou art worthy in might." :warriors "Take thy servant's medal of strength.") - (actions/give entities :medal)) + (actions/give entities :medal) + (actions/glad entities)) (do (play-battle entities :lose) (actions/do-dialogue entities diff --git a/desktop/src-common/advent/screens/rooms/outside_castle.clj b/desktop/src-common/advent/screens/rooms/outside_castle.clj index 5b1c7bd4..b2ae7794 100644 --- a/desktop/src-common/advent/screens/rooms/outside_castle.clj +++ b/desktop/src-common/advent/screens/rooms/outside_castle.clj @@ -36,7 +36,9 @@ :peddler "Well I'm afraid you won't have the choicest of earplugs." :ego "Can't I give you something else for them?" :peddler "I'll tell you what, I don't have any thing for the kids that come to my stand." - :peddler "If you can bring me the choicest of toys, and I mean the choicest of toys, I will give you the earplugs."))} + :peddler "If you can bring me the choicest of toys..." + :peddler "... and I mean the choicest of toys... " + :peddler "I will give you the earplugs."))} "I'm interested in a glass eye." {:run #(do (actions/update-state entities (fn [state] (assoc state :wants-toy true))) (actions/respond entities % @@ -48,7 +50,10 @@ :peddler "Well I'm afraid you won't have the choicest of glass eyes." :ego "Can't I give you something else for them?" :peddler "I'll tell you what, I don't have any thing for the kids that come to my stand." - :peddler "If you can bring me the choicest of toys, I will give you the glass eye."))} + :peddler "If you can bring me the choicest of toys..." + :peddler "... and I mean the choicest of toys... " + :peddler "Then I'll give you the glass eye." + ))} "I'm interested in the motivational tapes." {:run #(do (actions/update-state entities (fn [state] (assoc state :wants-toy true))) (actions/respond entities % @@ -60,7 +65,10 @@ :peddler "Well I'm afraid you won't have the choicest of motivational tapes." :ego "Is there anything else you'd take instead?" :peddler "I'll tell you what, I don't have any thing for the kids that come to my stand." - :peddler "If you can bring me the choicest of kid's toys, I will give you the tapes."))} + :peddler "If you can bring me the choicest of toys..." + :peddler "... and I mean the choicest of toys... " + :peddler "Then I'll give you the motivational tapes." + ))} "Nevermind." {:run #(actions/respond entities % :peddler "Goodbye, sir.")}]})) (defn give-teddy [entities] @@ -351,6 +359,12 @@ (actions/do-dialogue entities :ego "I don't thing Angus is interested." :ego "Farmer Doug only feeds him a wild high-protein grass.")) + + :sack-lunch (actions/get-script entities + (actions/walk-to entities :ego [168 150] :face :right) + (actions/do-dialogue entities + :ego "I don't thing Angus is interested." + :ego "Farmer Doug only feeds him a wild high-protein grass.")) nil)) :stand) :balloons (actions/start-animation screen diff --git a/desktop/src-common/advent/screens/scene.clj b/desktop/src-common/advent/screens/scene.clj index 36f50110..4df97347 100644 --- a/desktop/src-common/advent/screens/scene.clj +++ b/desktop/src-common/advent/screens/scene.clj @@ -510,6 +510,9 @@ void main() :ego "'A word of warning, before you go.\nA sip is all it takes to grow.'" :ego "'Not more than that do drink,\nOr you'll push your body to the brink.'" :ego "Hmm. I wonder what that last part means?")) + :portrait (actions/get-script entities (actions/do-dialogue entities + :ego "It's a portrait of a young man." + :ego "It has something written on it, but it's very dim.")) :note-1 (actions/get-script entities (common/read-note-1 entities)) :note-2 (actions/get-script entities (common/read-note-2 entities)) :camera (actions/get-script entities (actions/talk entities :ego "It's some sort of magical device that captures images.")) @@ -555,7 +558,7 @@ void main() (get-in ego [:right :crawl-stand]) {:origin-x 32} (get-in ego [:right :axe]) {:origin-x 17} (get-in ego [:right :axe-wood]) {:origin-x 17} - (get-in ego [:left :love]) {:origin-x 36} + (get-in ego [:left :love]) {:origin-x 41} (get-in ego [:left :suspended]) {:origin-x 0 :origin-y 0} (get-in ego [:right :suspended]) {:origin-x 0 :origin-y 0} (get-in ego [:left :suspended-talk]) {:origin-x 0 :origin-y 0}