From 7d8ba284d7dd03384d5da6f29dc2d470a6fb9521 Mon Sep 17 00:00:00 2001 From: Remington Covert Date: Thu, 18 Sep 2014 16:29:33 -0700 Subject: [PATCH] moving ego into background. --- desktop/resources/outside-castle/peddler.png | Bin 1664 -> 1672 bytes desktop/src-common/advent/actions.clj | 34 +++++++++--------- desktop/src-common/advent/screens/scene.clj | 36 +++++++++++++------ 3 files changed, 44 insertions(+), 26 deletions(-) diff --git a/desktop/resources/outside-castle/peddler.png b/desktop/resources/outside-castle/peddler.png index 9d0e2952a835d3b935c366567a977e5e67a9f67f..9d0eca185e96bc26b7e8adcce29ce5a4c4fc4320 100644 GIT binary patch delta 576 zcmV-G0>Ax$4Tue}R0Mw?Nklfbw#)1n7TkX+#3JQ`kIc)F7Y6 zMFc_Y`~HZhe0>E(>eJ~KCm61FDm%wS2Qof}l8lurBp(t&+e1CC)!Z?&Egf z!GrO3JS8lC^uwTp0(yLU4@75oC?_r2^cxBYV!-%De{JnLcxdn(#bB*Rc{9{1u0VQY zJ=cnpEbd;h)&zeQWpXmHdMUgCThb+F(68E>5|i<3tGqu_;*_p!8Z{8hAOKXo{qRJt zVH@&utuSS?0q}x=iadWQy-9$O&;cheucQ$cb3MidVzd1qRDeCgu08FTF>{nVvhC~0k;hA2fm7#yT6%Z-u=RzCoH?bd`Z^gBT*;!uz O0000}M`4S)@>R0Mw)NklG0|pFC6v-o!$1M}lEtHfZuOdZVeLHKn_UoL>z^ZfidVK45_UoRI zXR)XA-MF64DyA!mykk_PusrffqmKrNAZU*5uSvaYsU$E!@v{$6d%xN9@W5V= zCdG&!{V=GYfF2&-LX|VyRFfl?8Dt6wV!-%De{Sx0c*uB-au}^gc|F)7u0Tpd9oLGJ zEbLmg_9QFHpJ0D{=BYQeKf)VApm0TBPJ6wf*21$sEEG^A~Ap80~-_#E|W{sVXjMw7tpdf zRLrRRASy4W4&-9^HVE<(fPmJG{YolJ_2@r0G~I);V*0mR0g;kEUcGZ|lv2i}g^1B- zB+${`8B;jz>jXs>nRy04Dy43mM}=Z+TkPw3YyLT&&aVFB^|gl*KsQp zzW{fsIh-&d?^8+Mi1hvXj2efah*-}VO}50J8*Q-P delta-x 0) right :else (:anim %)))))))) (done? [this screen entities] - (let [{from-x :x from-y :y :keys [left right anim] :as target-entity} (entities target-id)] + (let [{from-x :x from-y :y :keys [left right anim] :as target-entity} (get-in entities [:background :entities target-id])] (< (dist final-x final-y from-x from-y) 1))) (terminate [this screen entities] @@ -109,15 +109,15 @@ (run-action entities (begin [this screen entities] (let [_ (swap! initial-time #(or % (:total-time screen))) - target-y (get-in entities [target-id :y]) + target-y (get-in entities [:background :entities target-id :y]) scale-fn (get-in entities [:background :scale-fn]) scale (scale-fn target-y) height (* scale 36)] (run! dialogue/talking-screen :on-talk :text text - :x (get-in entities [target-id :x]) :y (+ (get-in entities [target-id :y]) height) + :x (get-in entities [:background :entities target-id :x]) :y (+ (get-in entities [:background :entities target-id :y]) height) :target-id target-id :scale scale) - (assoc-in entities [target-id :anim] (get-in entities [target-id :talk])))) + (assoc-in entities [:background :entities target-id :anim] (get-in entities [:background :entities target-id :talk])))) (continue [this screen entities] entities) @@ -136,7 +136,7 @@ (sound! (sound "pickup.mp3") :play) (-> entities - (update-in [target-id :inventory] #(conj % item)) + (update-in [:background :entities target-id :inventory] #(conj % item)) (assoc-in [:cursor :current] item))) (continue [this screen entities] entities) @@ -168,10 +168,12 @@ entities)) (run-action entities (begin [this screen entities] - (-> entities - (assoc-in [:background] (get-in entities [:backgrounds new-background])) - (assoc-in [:ego :x] x) - (assoc-in [:ego :y] y))) + (let [ego (get-in entities [:background :entities :ego])] + (-> entities + (assoc-in [:background] (get-in entities [:backgrounds new-background])) + (assoc-in [:background :entities :ego] ego) + (assoc-in [:background :entities :ego :x] x) + (assoc-in [:background :entities :ego :y] y)))) (continue [this screen entities] (update-in entities [:transition :opacity] - 0.075)) diff --git a/desktop/src-common/advent/screens/scene.clj b/desktop/src-common/advent/screens/scene.clj index 5f8c6edf..c70e31a7 100644 --- a/desktop/src-common/advent/screens/scene.clj +++ b/desktop/src-common/advent/screens/scene.clj @@ -120,7 +120,11 @@ (defn backgrounds [screen] (let [sheep-sheet (texture! (texture "outsidehouse/sheep-anim.png") :split 33 21) sheep (animation 0.15 (for [i (flatten [(repeat 10 0) 1 2 3 4 5 6 7 4 5 6 7 8 9 10 (repeat 25 11) (repeat 15 12)])] - (aget sheep-sheet 0 i)))] + (aget sheep-sheet 0 i))) + + peddler-sheet (texture! (texture "outside-castle/peddler-talk.png" ) :split 18 36) + peddler-talk (animation 0.18 (for [i (flatten [2 3 2 3 2 3 6 1 0 1 0 1 0 1 0 1 2 3 2 3 2 3 6 4 5 4 5 4 5 4 5])] + (aget peddler-sheet 0 i)))] {:outside-house (make-background :interactions {:door {:box [258 100 281 160] @@ -137,7 +141,7 @@ :sheep {:box [38 160 71 181] :script (actions/get-script entities - (if ((get-in @entities [:ego :inventory]) :wool) + (if ((get-in @entities [:background :entities :ego :inventory]) :wool) (actions/talk entities :ego "The sheep has given me enough wool.") (do (actions/give entities :ego :wool) (actions/talk entities :ego "I guess his wool is shedding."))))} @@ -161,7 +165,7 @@ (assoc (texture "house.png") :x 0 :y 0 :baseline 122) (assoc (texture "overdirt.png") :x 0 :y 0 :baseline 240) (assoc (texture "background-trees.png") :x 0 :y 0 :baseline 44)] - :entities [(assoc (animation->texture screen sheep) :x 38 :y 160 :baseline 160 :anim sheep)] + :entities {:sheep (assoc (animation->texture screen sheep) :x 38 :y 160 :baseline 160 :anim sheep)} :collision "outsidehouse/collision.png" :scale-fn (scaler-fn-with-baseline 110 0.10 1.00)) @@ -177,9 +181,17 @@ :script (actions/get-script entities (actions/walk-to entities :ego [191 90]) - (actions/talk entities :ego "Hello there."))}} + (actions/talk entities :ego "Hello there, peddler.") + (actions/talk entities :peddler "Good day sir! Care to see any of my wares?") + (actions/talk entities :peddler "I have only the choicest of wares.") + (actions/talk entities :ego "What 'wares' are you selling?") + (actions/talk entities :peddler "I have all types of wares...") + (actions/talk entities :peddler "...I'm well stocked on used earplugs...") + (actions/talk entities :peddler "...glass eyes, motivational tapes... ") + (actions/talk entities :peddler "...and useful books like this:") + (actions/talk entities :peddler "'Checkers Mastery in Less Than 10 Seconds'"))}} :layers [(assoc (texture "outside-castle/background.png") :x 0 :y 0 :baseline 0)] - :entities [(assoc (texture "outside-castle/peddler.png") :x 110 :y 90 :baseline 150)] + :entities {:peddler (assoc (texture "outside-castle/peddler.png") :x 110 :y 90 :baseline 150 :anim nil :talk peddler-talk)} :collision "outside-castle/collision.png" :scale-fn (scaler-fn-with-baseline 110 0.10 1.00))})) @@ -205,8 +217,8 @@ :current :main :last :main :override nil} - :background (:outside-house backgrounds) - :ego (get-ego screen) + :background (assoc-in (:outside-house backgrounds) + [:entities :ego] (get-ego screen)) :fps (assoc (label "0" (color :white) ) :x 5 :baseline 9000) })) @@ -217,9 +229,13 @@ #_(.glEnable (.getGL30 Gdx/graphics) GL30/GL_BLEND) (let [entities (update-cursor screen entities) entities (update-from-script screen entities) - entities (update-in entities [:background :entities] (fn [entities] (map #(animate % screen) entities))) - entities (update-in entities [:ego] #(animate % screen)) - all-entities (concat (vals entities) (get-in entities [:background :layers]) (get-in entities [:background :entities]))] + entities (update-in entities [:background :entities] (fn [entities] + (into entities + (for [[id entity] entities] + (if (:anim entity) + [id (animate entity screen)] + [id entity]))))) + all-entities (concat (vals entities) (get-in entities [:background :layers]) (vals (get-in entities [:background :entities])))] (label! (:fps entities) :set-text (str (game :fps))) (render! screen (sort-by :baseline all-entities)) entities))