walking overrides ftw.
This commit is contained in:
@@ -63,17 +63,34 @@
|
|||||||
(when (:anim target)
|
(when (:anim target)
|
||||||
(texture (animation! (:anim target) :get-key-frame 0.25))))))))
|
(texture (animation! (:anim target) :get-key-frame 0.25))))))))
|
||||||
|
|
||||||
(defn left-click [screen entities]
|
(defn begin-walking [screen entities target-id [x y]]
|
||||||
(let [{:keys [x y]} (input->screen screen {:x (:input-x screen) :y (:input-y screen)})
|
(let [entity (target-id entities)
|
||||||
path (vec (take-nth 2 (advent.pathfind/visit-all
|
path (vec (take-nth 2 (advent.pathfind/visit-all
|
||||||
(:collision (:background entities))
|
(:collision (:background entities))
|
||||||
[(int (:x (:ego entities))) (int (:y (:ego entities)))]
|
[(int (:x entity)) (int (:y entity))]
|
||||||
[(int x) (int y)])))
|
[(int x) (int y)])))
|
||||||
actions (when (seq path)
|
actions (when (seq path)
|
||||||
(conj
|
(conj
|
||||||
(vec (map #(walk-to-fn % :ego) (conj path [x y])))
|
(vec (map #(walk-to-fn % target-id) (conj path [x y])))
|
||||||
(stop-fn :ego)))]
|
(stop-fn target-id)))]
|
||||||
(assoc-in entities [:ego :actions] actions)))
|
(assoc entity :actions actions)))
|
||||||
|
|
||||||
|
(defn walk-click [screen entities [x y]]
|
||||||
|
(assoc entities :ego (begin-walking screen entities :ego [x y])))
|
||||||
|
|
||||||
|
(defn walk-override-click [screen entities [x y]]
|
||||||
|
(let [target-location (->> (get-in entities [:background :mouse-overrides])
|
||||||
|
(filter #((:mouse-in? %) x y))
|
||||||
|
first
|
||||||
|
:go-to)]
|
||||||
|
(assoc entities :ego (begin-walking screen entities :ego target-location))))
|
||||||
|
|
||||||
|
(defn left-click [screen entities]
|
||||||
|
(let [{:keys [x y]} (input->screen screen {:x (:input-x screen) :y (:input-y screen)})]
|
||||||
|
(if (get-in entities [:cursor :override])
|
||||||
|
(walk-override-click screen entities [x y])
|
||||||
|
(walk-click screen entities [x y]))))
|
||||||
|
|
||||||
(defn get-ego [screen]
|
(defn get-ego [screen]
|
||||||
(let [player-sheet (texture! (texture "player.png") :split 18 36)
|
(let [player-sheet (texture! (texture "player.png") :split 18 36)
|
||||||
ego {:right (animation 0.075 (for [i (range 8)]
|
ego {:right (animation 0.075 (for [i (range 8)]
|
||||||
@@ -129,11 +146,14 @@
|
|||||||
:collision (advent.pathfind/map-from-resource "pathfind-test-big.png")
|
:collision (advent.pathfind/map-from-resource "pathfind-test-big.png")
|
||||||
:baseline 0
|
:baseline 0
|
||||||
:mouse-overrides [{:mouse-in? (box-maker-fn 290 131 320 224)
|
:mouse-overrides [{:mouse-in? (box-maker-fn 290 131 320 224)
|
||||||
:cursor-override 4}
|
:cursor-override 4
|
||||||
|
:go-to [319 160]}
|
||||||
{:mouse-in? (box-maker-fn 60 180 224 240)
|
{:mouse-in? (box-maker-fn 60 180 224 240)
|
||||||
:cursor-override 7}
|
:cursor-override 7
|
||||||
|
:go-to [137 204]}
|
||||||
{:mouse-in? (box-maker-fn 0 40 30 140)
|
{:mouse-in? (box-maker-fn 0 40 30 140)
|
||||||
:cursor-override 6}]
|
:cursor-override 6
|
||||||
|
:go-to [0 80]}]
|
||||||
:scale-fn (scaler-fn-with-baseline 110 0.10 1.00))
|
:scale-fn (scaler-fn-with-baseline 110 0.10 1.00))
|
||||||
:house (assoc house
|
:house (assoc house
|
||||||
:x 0 :y 0
|
:x 0 :y 0
|
||||||
@@ -182,5 +202,4 @@
|
|||||||
(defgame advent
|
(defgame advent
|
||||||
:on-create
|
:on-create
|
||||||
(fn [this]
|
(fn [this]
|
||||||
(set-screen! this main-screen)
|
(set-screen! this main-screen)))
|
||||||
#_(input! :set-cursor-catched true)))
|
|
||||||
|
|||||||
Reference in New Issue
Block a user