cleanup.
This commit is contained in:
@@ -5,7 +5,8 @@
|
||||
[play-clj.g2d :refer :all]
|
||||
[clojure.pprint]
|
||||
[advent.pathfind]
|
||||
[advent.actions :as actions])
|
||||
[advent.actions :as actions]
|
||||
[advent.screens.dialogue :as dialogue])
|
||||
(:import [com.badlogic.gdx.graphics Pixmap Pixmap$Filter Texture Texture$TextureFilter]
|
||||
[com.badlogic.gdx.graphics.g2d TextureRegion] ))
|
||||
|
||||
@@ -18,7 +19,7 @@
|
||||
(assoc entity :scale-x (scale-fn y) :scale-y (scale-fn y))
|
||||
entity)))
|
||||
|
||||
(defn walk-to-fn [[target-x target-y] target-id]
|
||||
(defn walk-to [[target-x target-y] target-id]
|
||||
(fn [screen entities]
|
||||
(let [{from-x :x from-y :y :keys [left right anim] :as target-entity} (entities target-id)]
|
||||
(let [delta-x (- target-x from-x)
|
||||
@@ -32,9 +33,10 @@
|
||||
(assoc (jump-to screen entities target-entity [(+ moved-x from-x) (+ moved-y from-y)])
|
||||
:anim (if (< moved-x 0) left right))))))))
|
||||
|
||||
(defn stop-fn [target-id]
|
||||
(defn stop [target-id]
|
||||
(fn [screen entities]
|
||||
(let [target (target-id entities)]
|
||||
(run! dialogue/talking-screen :stop-talk :target-id target-id)
|
||||
(assoc-in entities [target-id] (merge target
|
||||
{:anim nil
|
||||
:actions (rest (:actions target))}
|
||||
@@ -48,7 +50,16 @@
|
||||
[(int (:x entity)) (int (:y entity))]
|
||||
[(int x) (int y)])))
|
||||
actions (when (seq path)
|
||||
(conj
|
||||
(vec (map #(walk-to-fn % target-id) (conj path [x y])))
|
||||
(stop-fn target-id)))]
|
||||
(concat
|
||||
[(stop target-id)]
|
||||
(map #(walk-to % target-id) (conj path [x y]))
|
||||
[(stop target-id)]))]
|
||||
actions))
|
||||
|
||||
(defn talk [target-id text]
|
||||
(fn [screen entities]
|
||||
(run! dialogue/talking-screen :on-talk :text text
|
||||
:x (get-in entities [target-id :x]) :y (+ (get-in entities [target-id :y]) 25)
|
||||
:target-id target-id)
|
||||
(-> entities
|
||||
(update-in [target-id :actions] rest))))
|
||||
|
||||
Reference in New Issue
Block a user