Goon dropping

This commit is contained in:
Bryce Covert
2015-07-30 09:14:36 -07:00
parent fffe494308
commit 4ba5457d2e
2 changed files with 20 additions and 11 deletions

View File

@@ -338,7 +338,7 @@
(defn get-text-duration [text] (defn get-text-duration [text]
(max 1.5 (* (count (s/split text #" ")) 0.5))) (max 1.5 (* (count (s/split text #" ")) 0.5)))
(defn talk [entities target-id text & {:keys [stop? animate? anim]}] (defn talk [entities target-id text & {:keys [stop? animate? anim wait] :or {wait true}}]
(let [initial-time (atom nil) (let [initial-time (atom nil)
stop? (if (nil? stop?) true stop?) stop? (if (nil? stop?) true stop?)
animate? (if (nil? animate?) true animate?)] animate? (if (nil? animate?) true animate?)]
@@ -371,15 +371,20 @@
(continue [this screen entities] entities) (continue [this screen entities] entities)
(done? [this screen entities] (done? [this screen entities]
(> (- (:total-time screen) (if wait
@initial-time) (> (- (:total-time screen)
(get-text-duration text))) @initial-time)
(get-text-duration text))
true))
(terminate [this screen entities] (terminate [this screen entities]
(screen! dialogue/talking-screen :stop-talk :target-id target-id) (if wait
(if stop? (do
(stop screen entities target-id) (screen! dialogue/talking-screen :stop-talk :target-id target-id)
entities)) (if stop?
(stop screen entities target-id)
entities))
entities))
(can-skip? [this screen entities] (can-skip? [this screen entities]
true)))) true))))

View File

@@ -4,6 +4,7 @@
[advent.screens.items :as items] [advent.screens.items :as items]
[advent.screens.rooms.common :as common] [advent.screens.rooms.common :as common]
[advent.utils :as utils] [advent.utils :as utils]
[advent.screens.dialogue :as dialogue]
[advent.tween :as tween] [advent.tween :as tween]
[clojure.zip :as zip] [clojure.zip :as zip]
@@ -148,11 +149,13 @@
:script (actions/get-script entities :script (actions/get-script entities
(if (get-in @entities [:tweens :coin-y]) (if (get-in @entities [:tweens :coin-y])
(do (do
(actions/talk entities :ego "Hey goon!" :wait false)
(actions/update-entities entities (fn [entities] (actions/update-entities entities (fn [entities]
(update-in entities [:tweens] dissoc :coin-y))) (update-in entities [:tweens] dissoc :coin-y)))
(actions/walk-straight-to entities :coin-flip [212 90] :update-baseline? false :speed 3.0) (actions/walk-straight-to entities :coin-flip [212 90] :update-baseline? false :speed 3.0)
(screen! dialogue/talking-screen :stop-talk :target-id :ego)
(actions/do-stop entities :ego)
(actions/walk-straight-to entities :coin-flip [210 105] :update-baseline? false :speed 1.0) (actions/walk-straight-to entities :coin-flip [210 105] :update-baseline? false :speed 1.0)
(Thread/sleep 50) (Thread/sleep 50)
@@ -165,7 +168,8 @@
(actions/walk-straight-to entities :coin-flip [192 70] :update-baseline? false :speed 0.5) (actions/walk-straight-to entities :coin-flip [192 70] :update-baseline? false :speed 0.5)
(Thread/sleep 50) (Thread/sleep 50)
(actions/walk-straight-to entities :coin-flip [185 44] :update-baseline? false :speed 0.5) (actions/walk-straight-to entities :coin-flip [185 44] :update-baseline? false :speed 0.5)
(actions/update-state entities (fn [s] (assoc s :has-dropped-coin? true)))) (actions/update-state entities (fn [s] (assoc s :has-dropped-coin? true)))
(actions/talk entities :frankie "You made me lose my coin, Dipstick!"))
(actions/talk entities :ego "Hey goon!"))) (actions/talk entities :ego "Hey goon!")))
:night-profile :sprite :night-profile :sprite
:anim-start 0 :anim-start 0
@@ -196,7 +200,7 @@
walkie-visible (animation 1.0 [(last (utils/split-texture "castle-gate/throw-walkie.png" [205 136] (range 9)))]) walkie-visible (animation 1.0 [(last (utils/split-texture "castle-gate/throw-walkie.png" [205 136] (range 9)))])
walkie-invisible (animation 1.0 [(first (utils/split-texture "castle-gate/throw-walkie.png" [205 136] (range 9)))])] walkie-invisible (animation 1.0 [(first (utils/split-texture "castle-gate/throw-walkie.png" [205 136] (range 9)))])]
(rooms/make :music {:day :town-2 :night :night} (rooms/make :music {:day :town-2 :night :night}
:timers {:taunt [4.0 8.0 flip-coin]} :timers {:taunt [4.0 11.0 flip-coin]}
:interactions {:right-dir {:box [300 40 320 83] :interactions {:right-dir {:box [300 40 320 83]
:script (actions/get-script entities :script (actions/get-script entities
(actions/walk-to entities :ego [301 46] :face :right) (actions/walk-to entities :ego [301 46] :face :right)