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-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
|
||||
|
||||
Reference in New Issue
Block a user