From c745eb4bf13d53902e815cca88aa324642edb44c Mon Sep 17 00:00:00 2001 From: Bryce Covert Date: Tue, 23 Sep 2014 15:54:09 -0700 Subject: [PATCH] making moving speed dynamic based on scale. --- desktop/src-common/advent/actions.clj | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/desktop/src-common/advent/actions.clj b/desktop/src-common/advent/actions.clj index 919e9fea..79f09fd1 100644 --- a/desktop/src-common/advent/actions.clj +++ b/desktop/src-common/advent/actions.clj @@ -81,20 +81,23 @@ entities) (continue [this screen entities] - (let [{from-x :x from-y :y :keys [left right] :as target-entity} (get-in entities [:background :entities target-id]) + (let [{from-x :x from-y :y :keys [left right scale-x] :as target-entity} (get-in entities [:background :entities target-id]) [[target-x target-y] remainder] @targets-left] (let [delta-x (- target-x from-x) delta-y (- target-y from-y) distance (dist from-x from-y target-x target-y) + speed (* (or scale-x 1.0) 1.5) moved-x (if (= 0.0 distance) 0 - (* 1.5 (/ delta-x distance))) + (* speed (/ delta-x distance))) moved-y (if (= 0.0 distance) 0 - (* 1.5 (/ delta-y distance)))] - (if (< distance 1) + (* speed (/ delta-y distance)))] + (if (< distance speed) (do (swap! targets-left rest) - entities) + (-> entities + (assoc-in [:background :entities target-id :x] target-x) + (assoc-in [:background :entities target-id :y] target-y))) (update-in entities [:background :entities target-id] #(start-animation screen (assoc (jump-to screen entities % [(+ moved-x from-x) (+ moved-y from-y)])