diff --git a/desktop/resources/cursor.png b/desktop/resources/cursor.png index f2df32b5..65ce497f 100644 Binary files a/desktop/resources/cursor.png and b/desktop/resources/cursor.png differ diff --git a/desktop/resources/inside-jail/warden.png b/desktop/resources/inside-jail/warden.png index c6577c0c..4426e184 100644 Binary files a/desktop/resources/inside-jail/warden.png and b/desktop/resources/inside-jail/warden.png differ diff --git a/desktop/src-common/advent/actions.clj b/desktop/src-common/advent/actions.clj index b77f8380..6ec8dd35 100644 --- a/desktop/src-common/advent/actions.clj +++ b/desktop/src-common/advent/actions.clj @@ -335,10 +335,10 @@ (recur (next-choices zipper)) (recur zipper))))))) -(defn update-state [entities f] +(defn update-entities [entities f] (run-action entities (begin [this screen entities] - (update-in entities [:state] f )) + (f entities)) (continue [this screen entities] entities) (done? [this screen entities] true) (terminate [this screen entities] @@ -346,6 +346,21 @@ (can-skip? [this screen entities] false))) +(defn begin-animation [entities target-id anim] + (run-action entities + (begin [this screen entities] + (update-in entities [:room :entities target-id] + #(start-animation screen % anim))) + (continue [this screen entities] entities) + (done? [this screen entities] true) + (terminate [this screen entities] + entities) + (can-skip? [this screen entities] + false))) + +(defn update-state [entities f] + (update-entities entities #(update-in % [:state] f))) + (defn remove-item [entities item] (run-action entities (begin [this screen entities] diff --git a/desktop/src-common/advent/screens/items.clj b/desktop/src-common/advent/screens/items.clj index 99de8e1c..7dd0f212 100644 --- a/desktop/src-common/advent/screens/items.clj +++ b/desktop/src-common/advent/screens/items.clj @@ -112,4 +112,5 @@ :mandrake {:name "Mandrake root" :value :mandrake :cursor :mandrake :scripts {:flask-1-slobber (make-strength-potion) }} :ball-n-chain {:name "Ball-n-chain" :value :ball-n-chain :cursor :ball-n-chain} + :key {:name "Jail key" :value :key :cursor :key} }) diff --git a/desktop/src-common/advent/screens/rooms/inside_jail.clj b/desktop/src-common/advent/screens/rooms/inside_jail.clj index 8a451cb3..e6277360 100644 --- a/desktop/src-common/advent/screens/rooms/inside_jail.clj +++ b/desktop/src-common/advent/screens/rooms/inside_jail.clj @@ -42,50 +42,116 @@ :warden "It's how it works.") :choices actions/previous-choices} "Nevermind." - {:run #(actions/respond entities % - :warden "This conversation has got me very tired." - :warden "Be a good chap and let me rest.")}]})) + {:run #(do (actions/respond entities % + :warden "This conversation has got me very tired." + :warden "Be a good chap and let me rest.") + (actions/play-animation entities :warden :fall-asleep :stop? false) + (actions/begin-animation entities :warden :sleep) + (actions/update-state entities (fn [s] (assoc s :warden-sleeping? true))))}]})) + +(defn get-key [ entities] + (actions/walk-to entities :ego [71 82] :face :left) + (actions/play-animation entities :ego :squat) + (actions/do-dialogue entities :ego "He's got something clutched in his hand!") + (actions/play-animation entities :ego :squat) + (actions/do-dialogue entities :ego "What's this?" + :ego "Hello hello!" + :ego "It's the key!") + (let [had-key-before? (actions/has-obtained? entities :key)] + (actions/give entities :key) + (when (not had-key-before?) + (actions/do-dialogue entities :ego "Come on! It's that easy to escape?" + :ego "We're not going to at least do that dog and bone scenario?" + :ego "I get to just take the key and leave?" + :ego "Seems like a pretty sorry excuse for a puzzle.")))) + +(defn search-hay [entities] + (actions/walk-to entities :ego [144 86] :face :right) + (let [hay-searches (get-in @entities [:state :hay-searches] 0)] + (condp = hay-searches + 0 (do + (actions/talk entities :ego "Maybe there's a needle or something in here.") + (actions/play-animation entities :ego :squat) + (actions/talk entities :ego "No. Nothing at all!")) + 1 (do + (actions/talk entities :ego "Maybe I missed something. I'll check again.") + (actions/play-animation entities :ego :squat) + (actions/talk entities :ego "Nope. Still nothing.")) + + 2 (do (actions/talk entities :ego "There's got to be something in here!") + (actions/play-animation entities :ego :squat) + (actions/talk entities :ego "Nope. Still nothing.")) + + (do (actions/talk entities :ego "One more try.") + (actions/play-animation entities :ego :squat) + (actions/do-dialogue entities + :ego "You know, in some games, you have to try multiple times." + :ego "I'm beginning to feel like this isn't that game."))) + (actions/update-state entities #(assoc % :hay-searches (inc hay-searches))))) (defn make [screen] - (rooms/make :music :inside-antique - :interactions { - :lock {:box [178 102 184 124] - :script (actions/get-script entities - (actions/walk-to entities :ego [174 80] :face :right) - (actions/play-animation entities :ego :reach) - (actions/talk entities :ego "There's no helping it. It's locked."))} - :window {:box [98 110 118 140] + (let [warden-sheet (texture! (texture "inside-jail/warden.png") :split 43 58) + warden-talk (animation 0.2 (for [i [1 0 1 0 1 0 1 0 0 0 2 0]] + (aget warden-sheet 0 i))) + warden-stand (animation 0.1 (for [i (flatten [(repeat 30 0) 2 (repeat 20 0) 2])] + (aget warden-sheet 0 i))) + warden-fall-asleep (animation 0.1 (for [i (flatten [(repeat 10 0) 2 2 (repeat 10 0) 2 2 2 2 2 2 2 (repeat 10 0) 2 2 2 2 2 2 2 ])] + (aget warden-sheet 0 i))) + warden-sleep (animation 0.5 (for [i (flatten [(repeat 5 2) 3])] + (aget warden-sheet 0 i)))] + (rooms/make :music :inside-antique + :interactions { + :lock {:box [178 102 184 124] :script (actions/get-script entities - (actions/walk-to entities :ego [102 88] :face :right) - (actions/do-dialogue entities - :ego "What a peaceful night." - :ego "Oh my sweet Georgia McGorgeous. How will I ever save you now?" - :ego "I have to find a way out of here!"))} - :hay {:box [130 86 177 102] - :script (actions/get-script entities - (actions/walk-to entities :ego [144 86] :face :right) - (actions/talk entities :ego "Maybe there's a needle or something in here.") - (actions/play-animation entities :ego :squat) - (actions/talk entities :ego "No. Nothing at all!"))}} - :layers [(assoc (texture "inside-jail/background.png") :x 0 :y 0 :baseline 0) - (assoc (texture "inside-jail/bars.png") :x 0 :y 0 :baseline 165) - (assoc (texture "inside-jail/glow.png") :x 0 :y 0 :baseline 240)] - :entities {:warden (assoc (texture "inside-jail/warden.png" ) - :x 40 :y 60 :baseline 166 - :talk-color (color 0.9 0.3 0.9 1.0) - :script (actions/get-script entities - (do-warden-dialogue entities))) - :ball-n-chain (assoc (texture "inside-jail/ball-n-chain.png") - :x 80 :y 80 :baseline 160 - :script (actions/get-script entities - (actions/walk-to entities :ego [103 83] :face :left) - (actions/play-animation entities :ego :squat) - (actions/remove-entity entities :ball-n-chain) - (actions/give entities :ball-n-chain)))} - :collision "inside-jail/collision.png" - :scale-fn (utils/scaler-fn-with-baseline 0 0.50 1.5) - :start-pos [130 85] - :apply-state (fn [entities] - (if (actions/has-item? entities :ball-n-chain) - (update-in entities [:room :entities] #(dissoc % :ball-n-chain)) - entities)))) + (actions/walk-to entities :ego [174 80] :face :right) + (actions/play-animation entities :ego :reach) + (actions/talk entities :ego "There's no helping it. It's locked."))} + :window {:box [98 110 118 140] + :script (actions/get-script entities + (actions/walk-to entities :ego [102 88] :face :right) + (actions/do-dialogue entities + :ego "What a peaceful night." + :ego "Oh my sweet Georgia McGorgeous. How will I ever save you now?" + :ego "I have to find a way out of here!"))} + :hay {:box [130 86 177 102] + :script (actions/get-script entities + (search-hay entities) + )}} + :layers [(assoc (texture "inside-jail/background.png") :x 0 :y 0 :baseline 0) + (assoc (texture "inside-jail/bars.png") :x 0 :y 0 :baseline 165) + (assoc (texture "inside-jail/glow.png") :x 0 :y 0 :baseline 240)] + :entities {:warden (assoc (texture "inside-jail/warden.png" ) + :x 40 :y 60 :baseline 166 + :stand warden-stand + :talk warden-talk + :sleep warden-sleep + :fall-asleep warden-fall-asleep + :anim warden-stand + :anim-start 0 + :talk-color (color 0.9 0.3 0.9 1.0) + :script (actions/get-script entities + (cond + (actions/has-item? entities :key) (actions/talk entities :ego "Shh! It's best not to wake him now.") + (get-in @entities [:state :warden-fast-asleep?]) (get-key entities) + (get-in @entities [:state :warden-sleeping?]) (do (actions/walk-to entities :ego [103 82]) + (actions/do-dialogue entities + :ego "You-hoo! Mr. Warden?" + :ego "I guess he's really fast asleep!") + (actions/update-state entities #(assoc % :warden-fast-asleep? true))) + + :else (do (actions/walk-to entities :ego [103 82]) + (do-warden-dialogue entities))))) + :ball-n-chain (assoc (texture "inside-jail/ball-n-chain.png") + :x 80 :y 80 :baseline 160 + :script (actions/get-script entities + (actions/walk-to entities :ego [103 83] :face :left) + (actions/play-animation entities :ego :squat) + (actions/remove-entity entities :ball-n-chain) + (actions/give entities :ball-n-chain)))} + :collision "inside-jail/collision.png" + :scale-fn (utils/scaler-fn-with-baseline 0 0.50 1.5) + :start-pos [130 85] + :apply-state (fn [entities] + (if (actions/has-item? entities :ball-n-chain) + (update-in entities [:room :entities] #(dissoc % :ball-n-chain)) + entities))))) diff --git a/desktop/src-common/advent/utils.clj b/desktop/src-common/advent/utils.clj index 43ce2917..f4a1e274 100644 --- a/desktop/src-common/advent/utils.clj +++ b/desktop/src-common/advent/utils.clj @@ -14,7 +14,7 @@ (let [{:keys [x y]} (input->screen screen {:x (:input-x screen) :y (:input-y screen)})] (println (:input-x screen) (:input-y screen) "->" x y))) -(def +all-cursors+ [:main :wool :mushrooms :carrot :right :down :left :up :flask :flask-with-contents :trophy :ladder :stick :cat-toy :balloon :frog-legs :teddy :portrait :recipe :glass-eye :motivational-tapes :used-earplugs :grass :slobber :flask-with-strength :medal :kiss :sword :hourglass :mandrake :ball-n-chain]) +(def +all-cursors+ [:main :wool :mushrooms :carrot :right :down :left :up :flask :flask-with-contents :trophy :ladder :stick :cat-toy :balloon :frog-legs :teddy :portrait :recipe :glass-eye :motivational-tapes :used-earplugs :grass :slobber :flask-with-strength :medal :kiss :sword :hourglass :mandrake :ball-n-chain :key]) (defn cursor [filename which] (let [scale 2