added ability to change to a different screen (background)
This commit is contained in:
@@ -72,8 +72,12 @@
|
||||
(let [delta-x (- target-x from-x)
|
||||
delta-y (- target-y from-y)
|
||||
distance (dist from-x from-y target-x target-y)
|
||||
moved-x (* 1.5 (/ delta-x distance))
|
||||
moved-y (* 1.5 (/ delta-y distance))]
|
||||
moved-x (if (= 0.0 distance)
|
||||
0
|
||||
(* 1.5 (/ delta-x distance)))
|
||||
moved-y (if (= 0.0 distance)
|
||||
0
|
||||
(* 1.5 (/ delta-y distance)))]
|
||||
(if (< distance 1)
|
||||
(do (swap! targets-left rest)
|
||||
entities)
|
||||
@@ -149,3 +153,24 @@
|
||||
(put! c entities)
|
||||
entities)))
|
||||
(reset! entities (<!! c))))
|
||||
|
||||
(defn transition-background [entities new-background [x y]]
|
||||
(let [c (chan)]
|
||||
(put! (get-in @entities [:actions :channel])
|
||||
(reify
|
||||
IAction
|
||||
(begin [this screen entities]
|
||||
(-> entities
|
||||
(assoc-in [:background] (get-in entities [:backgrounds new-background]))
|
||||
(assoc-in [:ego :x] x)
|
||||
(assoc-in [:ego :y] y)))
|
||||
|
||||
(continue [this screen entities] entities)
|
||||
|
||||
(done? [this screen entities]
|
||||
true)
|
||||
|
||||
(terminate [this screen entities]
|
||||
(put! c entities)
|
||||
entities)))
|
||||
(reset! entities (<!! c))))
|
||||
|
||||
Reference in New Issue
Block a user