rotating.

This commit is contained in:
=
2014-09-03 00:13:01 -07:00
parent 5c9fb09e2b
commit dfc0554d6c
2 changed files with 8 additions and 5 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 10 KiB

View File

@@ -56,17 +56,20 @@
[target-x target-y] (first target-path)
target {:x target-x :y target-y}]
(if (and target (seq target-path))
(let [
delta-x (- (:x target) (:x ego))
(let [delta-x (- (:x target) (:x ego))
delta-y (- (:y target) (:y ego))
mag (Math/sqrt (+ (* delta-x delta-x) (* delta-y delta-y)))
vector-x (* 1.5 (/ delta-x mag))
vector-y (* 1.5 (/ delta-y mag))]
(if (< mag 1)
(update-in ego [:target-path] rest)
(-> ego
(update-in [:x] #(+ % vector-x))
(update-in [:y] #(+ % vector-y)))))
(merge (-> ego
(update-in [:x] #(+ % vector-x))
(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))))
(defscreen main-screen