rotating.
This commit is contained in:
Binary file not shown.
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 10 KiB |
@@ -56,17 +56,20 @@
|
|||||||
[target-x target-y] (first target-path)
|
[target-x target-y] (first target-path)
|
||||||
target {:x target-x :y target-y}]
|
target {:x target-x :y target-y}]
|
||||||
(if (and target (seq target-path))
|
(if (and target (seq target-path))
|
||||||
(let [
|
(let [delta-x (- (:x target) (:x ego))
|
||||||
delta-x (- (:x target) (:x ego))
|
|
||||||
delta-y (- (:y target) (:y ego))
|
delta-y (- (:y target) (:y ego))
|
||||||
mag (Math/sqrt (+ (* delta-x delta-x) (* delta-y delta-y)))
|
mag (Math/sqrt (+ (* delta-x delta-x) (* delta-y delta-y)))
|
||||||
vector-x (* 1.5 (/ delta-x mag))
|
vector-x (* 1.5 (/ delta-x mag))
|
||||||
vector-y (* 1.5 (/ delta-y mag))]
|
vector-y (* 1.5 (/ delta-y mag))]
|
||||||
(if (< mag 1)
|
(if (< mag 1)
|
||||||
(update-in ego [:target-path] rest)
|
(update-in ego [:target-path] rest)
|
||||||
(-> ego
|
(merge (-> ego
|
||||||
(update-in [:x] #(+ % vector-x))
|
(update-in [:x] #(+ % vector-x))
|
||||||
(update-in [:y] #(+ % vector-y)))))
|
(update-in [:y] #(+ % vector-y))
|
||||||
|
(assoc-in [:anim] (if (< vector-x 0)
|
||||||
|
(:left ego)
|
||||||
|
(:right ego))))
|
||||||
|
(animation->texture screen (:anim ego)))))
|
||||||
|
|
||||||
(dissoc ego :target-path))))
|
(dissoc ego :target-path))))
|
||||||
(defscreen main-screen
|
(defscreen main-screen
|
||||||
|
|||||||
Reference in New Issue
Block a user