the sheep can move closer to the player now.
This commit is contained in:
Binary file not shown.
|
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 2.2 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 5.5 KiB After Width: | Height: | Size: 5.7 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 6.2 KiB After Width: | Height: | Size: 6.2 KiB |
@@ -67,6 +67,48 @@
|
|||||||
~@forms))
|
~@forms))
|
||||||
(reset! ~entities (<!! c#)))))
|
(reset! ~entities (<!! c#)))))
|
||||||
|
|
||||||
|
(defn walk-straight-to [entities target-id [final-x final-y]]
|
||||||
|
(let [{start-x :x start-y :y} (get-in @entities [:background :entities target-id])
|
||||||
|
final-x (int final-x)
|
||||||
|
final-y (int final-y)]
|
||||||
|
(run-action entities
|
||||||
|
(begin [this screen entities]
|
||||||
|
entities)
|
||||||
|
|
||||||
|
(continue [this screen entities]
|
||||||
|
(let [{from-x :x from-y :y :keys [left right scale-x] :as target-entity} (get-in entities [:background :entities target-id])]
|
||||||
|
(let [delta-x (- final-x from-x)
|
||||||
|
delta-y (- final-y from-y)
|
||||||
|
distance (dist from-x from-y final-x final-y)
|
||||||
|
speed (* (or scale-x 1.0) 1.5)
|
||||||
|
moved-x (if (= 0.0 distance)
|
||||||
|
0
|
||||||
|
(* speed (/ delta-x distance)))
|
||||||
|
moved-y (if (= 0.0 distance)
|
||||||
|
0
|
||||||
|
(* speed (/ delta-y distance)))]
|
||||||
|
(if (< distance speed)
|
||||||
|
(-> entities
|
||||||
|
(assoc-in [:background :entities target-id :x] final-x)
|
||||||
|
(assoc-in [:background :entities target-id :y] final-y))
|
||||||
|
(update-in entities [:background :entities target-id]
|
||||||
|
#(start-animation screen
|
||||||
|
(assoc (jump-to screen entities % [(+ moved-x from-x) (+ moved-y from-y)])
|
||||||
|
:facing (cond (< delta-x 0) :left
|
||||||
|
(> delta-x 0) :right
|
||||||
|
:else (:facing %)))
|
||||||
|
:walk
|
||||||
|
))))))
|
||||||
|
|
||||||
|
(done? [this screen entities]
|
||||||
|
(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]
|
||||||
|
(stop screen entities target-id))
|
||||||
|
(can-skip? [this screen entities]
|
||||||
|
false))))
|
||||||
|
|
||||||
(defn walk-to [entities target-id [final-x final-y] & [can-skip?]]
|
(defn walk-to [entities target-id [final-x final-y] & [can-skip?]]
|
||||||
(let [{start-x :x start-y :y} (get-in @entities [:background :entities target-id])
|
(let [{start-x :x start-y :y} (get-in @entities [:background :entities target-id])
|
||||||
final-x (int final-x)
|
final-x (int final-x)
|
||||||
|
|||||||
@@ -322,7 +322,11 @@
|
|||||||
(do (actions/give entities :wool)
|
(do (actions/give entities :wool)
|
||||||
(actions/talk entities :ego "I guess her wool is shedding."))))
|
(actions/talk entities :ego "I guess her wool is shedding."))))
|
||||||
:scripts {:wool (actions/get-script entities
|
:scripts {:wool (actions/get-script entities
|
||||||
(actions/talk entities :ego "She doesn't need it back."))}}
|
(actions/talk entities :ego "She doesn't need it back."))
|
||||||
|
:carrot (actions/get-script entities
|
||||||
|
(actions/walk-to entities :ego [132 140])
|
||||||
|
(actions/talk entities :ego "Come on girl, get the carrot!")
|
||||||
|
(actions/walk-straight-to entities :sheep [100 150]))}}
|
||||||
:right-dir {:box [300 131 320 224]
|
:right-dir {:box [300 131 320 224]
|
||||||
:script (actions/get-script
|
:script (actions/get-script
|
||||||
entities
|
entities
|
||||||
@@ -410,6 +414,15 @@
|
|||||||
(actions/walk-to entities :ego [310 80])
|
(actions/walk-to entities :ego [310 80])
|
||||||
(actions/transition-background entities :outside-house [0 80]))
|
(actions/transition-background entities :outside-house [0 80]))
|
||||||
:cursor :right}
|
:cursor :right}
|
||||||
|
:garden {:box [103 170 178 200]
|
||||||
|
:script (actions/get-script
|
||||||
|
entities
|
||||||
|
(if ((get-in @entities [:state :inventory]) :carrot)
|
||||||
|
(actions/talk entities :ego "If I steal any more, I might get caught.")
|
||||||
|
(do
|
||||||
|
(actions/walk-to entities :ego [128 180])
|
||||||
|
(actions/talk entities :ego "Hey! Carrots. No one will notice one missing.")
|
||||||
|
(actions/give entities :carrot))))}
|
||||||
:peddler {:box [110 90 128 146]
|
:peddler {:box [110 90 128 146]
|
||||||
:script (actions/get-script
|
:script (actions/get-script
|
||||||
entities
|
entities
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
(let [{:keys [x y]} (input->screen screen {:x (:input-x screen) :y (:input-y screen)})]
|
(let [{:keys [x y]} (input->screen screen {:x (:input-x screen) :y (:input-y screen)})]
|
||||||
(println (:input-x screen) (:input-y screen) "->" x y)))
|
(println (:input-x screen) (:input-y screen) "->" x y)))
|
||||||
|
|
||||||
(def +all-cursors+ [:main :wool :mushrooms :talk :right :down :left :up])
|
(def +all-cursors+ [:main :wool :mushrooms :carrot :right :down :left :up])
|
||||||
|
|
||||||
(defn cursor [filename which]
|
(defn cursor [filename which]
|
||||||
(let [scale 2
|
(let [scale 2
|
||||||
|
|||||||
Reference in New Issue
Block a user