From e7629b8c96687b998c204eb82d794fddedc04be2 Mon Sep 17 00:00:00 2001 From: Bryce Covert Date: Wed, 29 Jul 2015 23:05:07 -0700 Subject: [PATCH] goon drops coin. --- desktop/src-common/advent/actions.clj | 6 ++++-- .../advent/screens/rooms/castle_gate.clj | 21 ++++++++++++------- desktop/src-common/advent/tween.clj | 2 +- 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/desktop/src-common/advent/actions.clj b/desktop/src-common/advent/actions.clj index a93b9ce1..93a57686 100644 --- a/desktop/src-common/advent/actions.clj +++ b/desktop/src-common/advent/actions.clj @@ -433,10 +433,12 @@ (recur (next-choices zipper)) (recur zipper))))))) -(defn update-entities [entities f] +(defn update-entities [entities f & {:keys [use-screen?] :or {use-screen? false}}] (run-action entities (begin [this screen entities] - (f entities)) + (if use-screen? + (f screen entities) + (f entities))) (continue [this screen entities] entities) (done? [this screen entities] true) (terminate [this screen entities] diff --git a/desktop/src-common/advent/screens/rooms/castle_gate.clj b/desktop/src-common/advent/screens/rooms/castle_gate.clj index f5edbb18..67be9bf6 100644 --- a/desktop/src-common/advent/screens/rooms/castle_gate.clj +++ b/desktop/src-common/advent/screens/rooms/castle_gate.clj @@ -106,12 +106,7 @@ :origin-x 5 :origin-y 5 :night-profile :none - :coinflip coin-flip - - - #_#_:anim coin-flip - #_#_:anim-start 0 - #_#_:stand coin-flip))) + :coinflip coin-flip))) (defn make-goon-1 [screen] (let [stand (utils/make-anim "castle-gate/goon-1.png" [12 33] 0.21 [0 0 0 0 0 0 0 0 0 1])] @@ -128,9 +123,11 @@ (let [stand (utils/make-anim "castle-gate/goon-2.png" [12 32] 0.175 [0 0 0 0 0 0 0 0 0 0 0 0 0 1]) flip (utils/make-anim "castle-gate/goon-2-flip.png" [12 32] 0.05 [1 2 2 2 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ])] (assoc (animation->texture screen stand) - :x 208 :y 102 :baseline 138 + :x 214 :y 102 :baseline 138 :scale-x 1.4 :scale-y 1.4 + :origin-x 6 + :origin-y 0 :anim stand :flip flip :update-fn (fn [s es e] @@ -140,6 +137,14 @@ (- (:total-time s) (:anim-start e)))) (actions/start-animation s e :stand) e)) + :script (actions/get-script entities + (if (= (get-in @entities [:room :entities :coin-flip :opacity]) 1.0) + (actions/update-entities entities + (fn [screen entities] + (let [current-y (get-in entities [:room :entities :coin-flip :y])] + (assoc-in entities [:tweens :coin-y] (tween/tween :coin-y screen [:room :entities :coin-flip :y] current-y 80 0.5 :ease tween/ease-in-cubic)))) + :use-screen? true) + (actions/talk entities :ego "Hey goon!"))) :night-profile :sprite :anim-start 0 :stand stand))) @@ -156,7 +161,7 @@ (assoc :opacity 1.0)))) (assoc-in [:tweens :coin-y] (tween/tween :coin-y screen [:room :entities :coin-flip :y] 112 175 0.5 :ease tween/ease-out-cubic :finish (fn [e] - (assoc-in e [:tweens :coin-y-2] (tween/tween :coin-y-2 (assoc screen :total-time (+ 0.5 (:total-time screen))) [:room :entities :coin-flip :y] 174 112 0.5 :ease tween/ease-in-cubic + (assoc-in e [:tweens :coin-y] (tween/tween :coin-y (assoc screen :total-time (+ 0.5 (:total-time screen))) [:room :entities :coin-flip :y] 174 112 0.5 :ease tween/ease-in-cubic :finish (fn [e] (assoc-in e [:room :entities :coin-flip :opacity] 0.0))))))) (update-in [:room :entities :goon-2] (fn [g] (-> (actions/start-animation screen g :flip)))))) diff --git a/desktop/src-common/advent/tween.clj b/desktop/src-common/advent/tween.clj index 31974ba7..306b4f56 100644 --- a/desktop/src-common/advent/tween.clj +++ b/desktop/src-common/advent/tween.clj @@ -61,5 +61,5 @@ new-val))] (if (= 1.0 pct-done) - (update-in (finish e) [:tweens] dissoc id) + (finish (update-in e [:tweens] dissoc id)) e)))))