diff --git a/desktop/resources/butterfly.png b/desktop/resources/butterfly.png new file mode 100644 index 00000000..7b6e0439 Binary files /dev/null and b/desktop/resources/butterfly.png differ diff --git a/desktop/resources/outside-castle/bird.png b/desktop/resources/outside-castle/bird.png index d005accd..d1877fd3 100644 Binary files a/desktop/resources/outside-castle/bird.png and b/desktop/resources/outside-castle/bird.png differ diff --git a/desktop/resources/outside-castle/flies.png b/desktop/resources/outside-castle/flies.png new file mode 100644 index 00000000..6e5b5bdb Binary files /dev/null and b/desktop/resources/outside-castle/flies.png differ diff --git a/desktop/resources/outside-castle/steer.png b/desktop/resources/outside-castle/steer.png index 94027295..bb63f21d 100644 Binary files a/desktop/resources/outside-castle/steer.png and b/desktop/resources/outside-castle/steer.png differ diff --git a/desktop/src-common/advent/screens/rooms/outside_castle.clj b/desktop/src-common/advent/screens/rooms/outside_castle.clj index 7646f5af..7645f52b 100644 --- a/desktop/src-common/advent/screens/rooms/outside_castle.clj +++ b/desktop/src-common/advent/screens/rooms/outside_castle.clj @@ -7,6 +7,7 @@ [play-clj.core :refer :all] [play-clj.ui :refer :all] [play-clj.utils :refer :all] + [play-clj.math :refer :all] [play-clj.g2d :refer :all])) (defn make [screen] @@ -18,11 +19,18 @@ balloon-sheet (texture! (texture "outside-castle/balloons.png") :split 20 36) balloon-stand (animation 0.3 (for [i [0 1 2 1]] (aget balloon-sheet 0 i))) - bird-sheet (texture! (texture "outside-castle/bird.png") :split 60 22) - bird-order [0 0 0 0 0 0 0 0 0 1 2 3 4 5 6 7 8 9 10 11 12 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ] - bird-stand (animation 0.15 (for [i (concat bird-order - (reverse bird-order))] + bird-sheet (texture! (texture "outside-castle/bird.png") :split 1 2) + bird-stand (animation 0.15 (for [i [0 1]] (aget bird-sheet 0 i))) + butterfly-sheet (texture! (texture "butterfly.png") :split 7 7) + butterfly-stand (animation 0.1 (for [i [0 1]] + (aget butterfly-sheet 0 i))) + steer-sheet (texture! (texture "outside-castle/steer.png") :split 50 35) + steer-stand (animation 0.2 (for [i [0 0 0 0 0 0 0 0 0 1 0 2 0 1 0 2 0 1 0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 3 3 3 3 3 3 3 3 3 0 0 0 0]] + (aget steer-sheet 0 i))) + flies-sheet (texture! (texture "outside-castle/flies.png") :split 15 15) + flies-stand (animation 0.075 (for [i [0 1 2 1]] + (aget flies-sheet 0 i))) ] (rooms/make :music :town-2 :interactions @@ -133,15 +141,19 @@ (assoc (texture "outside-castle/peddler.png") :x 110 :y 90 :baseline 150 :anim nil :talk peddler-talk :stand peddler-stand) :stand) - :steer (assoc (texture "outside-castle/steer.png" ) :x 203 :y 155 :baseline 80 - :script (actions/get-script entities - (actions/talk entities :ego "That is one buff bull!")) - :scripts {:grass (actions/get-script entities - (actions/walk-to entities :ego [168 150] :face :right) - (actions/play-animation entities :ego :reach) - (actions/remove-item entities :grass) - (actions/talk entities :ego "Eww! He slobbered on my hand.") - (actions/give entities :slobber))}) + :steer (actions/start-animation screen (assoc (animation->texture screen steer-stand) :x 203 :y 155 :baseline 80 + :stand steer-stand + :script (actions/get-script entities + (actions/do-dialogue entities + :ego "It's Angus, Remington's buff bull." + :ego "Farmer doug feeds him a special grass diet to keep him in tip top shape.")) + :scripts {:grass (actions/get-script entities + (actions/walk-to entities :ego [168 150] :face :right) + (actions/play-animation entities :ego :reach) + (actions/remove-item entities :grass) + (actions/talk entities :ego "Eww! He slobbered on my hand.") + (actions/give entities :slobber))}) + :stand) :balloons (actions/start-animation screen (assoc (animation->texture screen balloon-stand) :x 75 @@ -153,10 +165,40 @@ :stand) :bird (actions/start-animation screen (assoc (animation->texture screen bird-stand) + :x 0 + :y 0 + :baseline 21 + :stand bird-stand + :path (catmull-rom-spline (map #(apply vector-2* %) (as-> [[82 235] [134 215] [185 235] [165 238] + [220 225] [210 230] [250 235]] p + (concat p (reverse p)))) true) + :update-fn (fn [screen entities entity] + (let [speed 0.05 + pos-f (- (* (:total-time screen) speed) (int (* (:total-time screen) speed))) + v (vector-2 0 0) + a (catmull-rom-spline! (:path entity) :value-at v pos-f)] + (assoc entity :x (vector-2! v :x) :y (vector-2! v :y))))) + :stand) + :butterfly (actions/start-animation screen + (assoc (animation->texture screen butterfly-stand) :x 161 :y 218 - :baseline 21 - :stand bird-stand) + :baseline 240 + :stand butterfly-stand + :path (catmull-rom-spline (map #(apply vector-2* %) (take 10 (repeatedly #(vector (rand-int 320) (rand-int 180))))) true) + :update-fn (fn [screen entities entity] + (let [speed 0.009 + pos-f (- (* (:total-time screen) speed) (int (* (:total-time screen) speed))) + v (vector-2 0 0) + a (catmull-rom-spline! (:path entity) :value-at v pos-f)] + (assoc entity :x (vector-2! v :x) :y (vector-2! v :y))))) + :stand) + :flies (actions/start-animation screen + (assoc (animation->texture screen flies-stand) + :x 241 + :y 175 + :baseline 240 + :stand flies-stand) :stand)} :collision "outside-castle/collision.png" :scale-fn (utils/scaler-fn-with-baseline 110 0.10 1.00) diff --git a/desktop/src-common/advent/screens/scene.clj b/desktop/src-common/advent/screens/scene.clj index fb49be34..4a443fde 100644 --- a/desktop/src-common/advent/screens/scene.clj +++ b/desktop/src-common/advent/screens/scene.clj @@ -273,6 +273,12 @@ (if (:anim entity) [id (animate entity screen)] [id entity]))))) + entities (update-in entities [:room :entities] (fn [entities] + (into entities + (for [[id entity] entities] + (if (:update-fn entity) + [id ((:update-fn entity) screen entities entity)] + [id entity]))))) all-entities (concat (vals entities) (get-in entities [:room :layers]) (vals (get-in entities [:room :entities])))] (label! (:fps entities) :set-text (str (game :fps))) (render! screen (sort-by :baseline all-entities))