From 199558e9db29f3564b72273573149ac29b3af144 Mon Sep 17 00:00:00 2001 From: Remington Covert Date: Wed, 15 Apr 2015 19:43:25 -0700 Subject: [PATCH] more work on intro. --- desktop/src-common/advent/screens/items.clj | 3 +- .../src-common/advent/screens/rooms/dream.clj | 68 ++++++++++++------- desktop/src-common/advent/screens/scene.clj | 6 +- 3 files changed, 52 insertions(+), 25 deletions(-) diff --git a/desktop/src-common/advent/screens/items.clj b/desktop/src-common/advent/screens/items.clj index 3292a5b4..47107124 100644 --- a/desktop/src-common/advent/screens/items.clj +++ b/desktop/src-common/advent/screens/items.clj @@ -132,4 +132,5 @@ :alarm-clock {:name "Time-keeping device" :value :alarm-clock :cursor :alarm-clock} :magic-slingshot {:name "The Slinger's Shot" :value :magic-slingshot :cursor :magic-slingshot} :shovel {:name "Shovel" :value :shovel :cursor :shovel} - :broom {:name "Broom" :value :broom :cursor :broom}}) + :broom {:name "Broom" :value :broom :cursor :broom} + :dream-sword {:name "Sword" :value :dream-sword :cursor :sword}}) diff --git a/desktop/src-common/advent/screens/rooms/dream.clj b/desktop/src-common/advent/screens/rooms/dream.clj index 0ff98ca6..0d961109 100644 --- a/desktop/src-common/advent/screens/rooms/dream.clj +++ b/desktop/src-common/advent/screens/rooms/dream.clj @@ -216,6 +216,20 @@ (can-skip? [this screen entities] false))) +(defn return-from-island [screen entities] + (when (and (not (get-in entities [:actions :script-running?])) + (get-in entities [:state :active?]) + (get-in entities [:room :entities :fairy-godfather :distracted?])) + ((actions/get-script entities + (actions/update-entities entities (fn [e] (update-in e [:room :entities :fairy-godfather] dissoc :distracted?))) + (actions/walk-straight-to entities :fairy-godfather [240 120] :speed 3.0 :update-baseline? false :face :left) + (actions/update-entities entities (fn [e] (update-in e [:room :entities :fairy-godfather] assoc :path (catmull-rom-spline (map #(apply vector-2* %) [[240 120] [240 124]]) true)))) + (actions/do-dialogue entities + :fairy-godfather "Hey! I didn't see anything over there!" + :ego "Oh, yes, it must have flown off.")) + entities)) + nil) + (defn make [screen] (let [fairy-godfather-anim (utils/make-anim "dream/fairy-godfather.png" [63 77] 0.15 [0 1 2 3 2 1 0 1 4 3 2 1]) @@ -237,6 +251,7 @@ (actions/play-animation entities :ego :sigh) (actions/play-animation entities :ego :reach) (actions/talk entities :ego "Wait a second! If I become a janitor, I'll never win Georgia McGorgeous' heart!"))}}} + :timers {:return [1.0 10.0 return-from-island]} :layers [(assoc (texture "dream/clouds1.png") :x -10 :y 0 :baseline -1 :parallax 0.2 :scale-x 1.1 :scale-y 1.1) (assoc (texture "dream/island.png") :x 180 :y 180 :baseline 0 :parallax 0.3 :scale-x 1.1 :scale-y 1.1) (assoc (texture "dream/cliff.png") :x 50 :y 133 :baseline 1 :parallax 0.6 :scale-x 1.2 :scale-y 1.2) @@ -254,7 +269,13 @@ :scripts {:shovel (actions/get-script entities (if (get-in @entities [:room :entities :fairy-godfather :distracted?]) (do (actions/walk-to entities :ego [148 76] :face :right) - (swing entities)) + (swing entities) + (actions/play-animation entities :ego :reach) + (actions/give entities :dream-sword) + (actions/do-dialogue entities :ego "Yes! Now, before he gets back!") + (actions/pause-camera entities) + (actions/walk-straight-to entities :ego [173 51] :anim :jump :update-baseline? false :speed 2.0) + (actions/walk-straight-to entities :ego [204 -40] :anim :stand :update-baseline? false :speed 3.0)) (do (actions/walk-to entities :ego [148 76] :face :right) (actions/do-dialogue entities :fairy-godfather "What are you doing?" :ego "Erm... Nothing."))))}) @@ -312,29 +333,30 @@ (utils/update-path-location 0.2 s es e) e)) :script (actions/get-script entities - - (actions/do-dialogue entities :fairy-godfather "Young Tick, you must choose your destiny!") - (actions/present-choices entities {:choices ["What if I don't like any of these choices?" - {:run #(do (actions/respond entities % - :fairy-godfather "Tough luck")) - :choices actions/previous-choices} + (if (get-in @entities [:room :entities :fairy-godfather :distracted?]) + (actions/do-dialogue entities :ego "He wouldn't be able to hear me from there.") + (do + (actions/do-dialogue entities :fairy-godfather "Young Tick, you must choose your destiny!") + (actions/present-choices entities {:choices ["What if I don't like any of these choices?" + {:run #(do (actions/respond entities % + :fairy-godfather "Tough luck")) + :choices actions/previous-choices} - "Look out!" - {:run #(do (actions/respond entities % - :fairy-godfather "What is it?" - :ego "Err... Um..." - :ego "I saw a, um...")) - :choices ["... a dragon!" - {:run #(do (actions/respond entities % - :ego "Yes, that's it! A dragon!" - :fairy-godfather "Over there on that island!?!") - (actions/update-entities entities (fn [e] (update-in e [:room :entities :fairy-godfather] dissoc :path))) - (actions/update-entities entities (fn [e] (update-in e [:room :entities :fairy-godfather] assoc :distracted? true))) - (actions/walk-straight-to entities :fairy-godfather [211 210] ) - (actions/talk entities :fairy-godfather "Test"))}] } - - "Nevermind." - {:run #(actions/respond entities % :fairy-godfather "Don't worry, Tick.")}]})))} + "Look out!" + {:run #(do (actions/respond entities % + :fairy-godfather "What is it?" + :ego "Err... Um..." + :ego "I saw a, um...")) + :choices ["... a dragon!" + {:run #(do (actions/respond entities % + :ego "Yes, that's it! A dragon!" + :fairy-godfather "Over there on that island!?!") + (actions/update-entities entities (fn [e] (update-in e [:room :entities :fairy-godfather] dissoc :path))) + (actions/update-entities entities (fn [e] (update-in e [:room :entities :fairy-godfather] assoc :distracted? true))) + (actions/walk-straight-to entities :fairy-godfather [211 210] ))}] } + + "Nevermind." + {:run #(actions/respond entities % :fairy-godfather "Don't worry, Tick.")}]})))))} :collision "dream/collision.png" :scale-fn (utils/scaler-fn-from-image "dream/scale.png" 0.1 1.3) :apply-state (fn [entities] diff --git a/desktop/src-common/advent/screens/scene.clj b/desktop/src-common/advent/screens/scene.clj index 59d51af5..885953f3 100644 --- a/desktop/src-common/advent/screens/scene.clj +++ b/desktop/src-common/advent/screens/scene.clj @@ -616,6 +616,10 @@ (if-let [apply-state (get-in entities [:room :apply-state])] (apply-state entities) entities))))) + + :on-resume (fn [screen [entities]] + (doseq [[k [start time fn]] (get-in entities [:room :timers])] + (add-timer! screen k start time))) :on-render (fn [{:keys [camera] :as screen} [entities]] @@ -746,7 +750,7 @@ (script entities) entities) :hud-active? (fn [{:keys [hud-active?]} [entities]] - (assoc-in entities [:state :hud-active?] hud-active?))) + (assoc-in entities [:state :hud-active?] hud-active?))) () (defn grow-hud [screen entities target up?]