fixing a number of issues.
This commit is contained in:
@@ -343,37 +343,53 @@
|
||||
(continue [this screen entities]
|
||||
(when (= (rand-int 5) 2)
|
||||
#_(particle-effect! (:step-particles entities) :start))
|
||||
(let [{from-x :x from-y :y :keys [left right scale-x] :as target-entity} (get-in entities [:room :entities target-id])
|
||||
[[target-x target-y] remainder] @targets-left]
|
||||
(let [delta-x (- target-x from-x)
|
||||
delta-y (- target-y from-y)
|
||||
distance (utils/dist from-x from-y target-x target-y)
|
||||
speed (* (or scale-x 1.0) 1.5)
|
||||
speed (* speed
|
||||
(/ (:delta-time screen)
|
||||
(/ 1.0 60.0)))
|
||||
moved-x (if (= 0.0 distance)
|
||||
0
|
||||
(* speed (/ delta-x distance)))
|
||||
moved-y (if (= 0.0 distance)
|
||||
0
|
||||
(* speed (/ delta-y distance)))]
|
||||
(if (< distance speed)
|
||||
(do (swap! targets-left rest)
|
||||
(-> entities
|
||||
(assoc-in [:room :entities target-id :x] target-x)
|
||||
(assoc-in [:room :entities target-id :y] target-y)
|
||||
(assoc-in [:step-particles :x] target-x)
|
||||
(assoc-in [:step-particles :y] target-y)))
|
||||
(update-in entities [:room :entities target-id]
|
||||
#(start-animation screen
|
||||
(assoc (jump-to screen entities % [(+ moved-x from-x) (+ moved-y from-y)] true)
|
||||
:facing (cond force-dir force-dir
|
||||
(< delta-x 0) :left
|
||||
(> delta-x 0) :right
|
||||
:else (:facing %)))
|
||||
:walk
|
||||
))))))
|
||||
(loop [entities entities
|
||||
base-speed (* 1.5
|
||||
(/ (:delta-time screen)
|
||||
(/ 1.0 60.0))
|
||||
1.0)]
|
||||
(let [{from-x :x from-y :y :keys [left right scale-x] :as target-entity} (get-in entities [:room :entities target-id])
|
||||
[[target-x target-y] remainder] @targets-left]
|
||||
(let [delta-x (- target-x from-x)
|
||||
delta-y (- target-y from-y)
|
||||
distance (utils/dist from-x from-y target-x target-y)
|
||||
speed (* (or scale-x 1.0) base-speed)
|
||||
moved-x (if (= 0.0 distance)
|
||||
0
|
||||
(* speed (/ delta-x distance)))
|
||||
moved-y (if (= 0.0 distance)
|
||||
0
|
||||
(* speed (/ delta-y distance)))]
|
||||
(cond (<= speed 0)
|
||||
entities
|
||||
|
||||
(> distance speed)
|
||||
(update-in entities [:room :entities target-id]
|
||||
#(start-animation screen
|
||||
(assoc (jump-to screen entities % [(+ moved-x from-x) (+ moved-y from-y)] true)
|
||||
:facing (cond force-dir force-dir
|
||||
(< delta-x 0) :left
|
||||
(> delta-x 0) :right
|
||||
:else (:facing %)))
|
||||
:walk
|
||||
))
|
||||
|
||||
(seq remainder)
|
||||
(do
|
||||
(swap! targets-left rest)
|
||||
(recur (-> entities
|
||||
(assoc-in [:room :entities target-id :x] target-x)
|
||||
(assoc-in [:room :entities target-id :y] target-y)
|
||||
(assoc-in [:step-particles :x] target-x)
|
||||
(assoc-in [:step-particles :y] target-y))
|
||||
(- base-speed distance)))
|
||||
|
||||
:else
|
||||
(-> entities
|
||||
(assoc-in [:room :entities target-id :x] target-x)
|
||||
(assoc-in [:room :entities target-id :y] target-y)
|
||||
(assoc-in [:step-particles :x] target-x)
|
||||
(assoc-in [:step-particles :y] target-y)))))))
|
||||
|
||||
(done? [this screen entities]
|
||||
(let [{from-x :x from-y :y :keys [left right anim] :as target-entity} (get-in entities [:room :entities target-id])]
|
||||
|
||||
@@ -61,7 +61,11 @@
|
||||
|
||||
tr (bitmap-font! font :get-region)
|
||||
scale (* scale (/ utils/ui-scale 2))
|
||||
scale (or (min (max scale (/ utils/ui-scale 5) 0.4) (/ utils/ui-scale 4)) (/ utils/ui-scale 4))
|
||||
scale (or (min
|
||||
(max scale
|
||||
(/ utils/ui-scale 5) 0.4)
|
||||
(/ utils/ui-scale 4))
|
||||
(/ utils/ui-scale 4))
|
||||
_ (.setFilter (.getTexture tr) Texture$TextureFilter/Linear Texture$TextureFilter/Linear)
|
||||
style (style :label font color)
|
||||
[source-x source-y] [x y]
|
||||
@@ -182,7 +186,7 @@
|
||||
(assoc-in [:state :labels] labels)
|
||||
(assoc-in [:state :table]
|
||||
(doto (-> labels
|
||||
(vertical :align Align/bottomLeft :pad 20 :space 24)
|
||||
(vertical :align Align/bottomLeft :pad (* utils/ui-scale 20) :space (* utils/ui-scale 24))
|
||||
|
||||
(#(utils/add-actor-to-stage screen %))
|
||||
(assoc :x 0 :y 0 :width 1240)
|
||||
@@ -269,9 +273,10 @@
|
||||
tr (bitmap-font! font :get-region)
|
||||
_ (.setFilter (.getTexture tr) Texture$TextureFilter/Linear Texture$TextureFilter/Linear)
|
||||
style (doto (style :label font (color :white))
|
||||
(#(-> % .font .getData (.setScale (* utils/ui-scale 0.25)))))]
|
||||
(#(-> % .font .getData (.setScale (/ utils/ui-scale 4)))))]
|
||||
{:label (as-> (label "" style) l
|
||||
(do (label! l :set-alignment (if utils/mobile? Align/bottomLeft Align/center))
|
||||
(label! l :set-font-scale (* utils/ui-scale 0.25))
|
||||
l)
|
||||
(assoc l :x 0 :y 0 :baseline 10000)
|
||||
(utils/add-actor-to-stage screen l))
|
||||
@@ -295,7 +300,7 @@
|
||||
(cond-> entities
|
||||
true (assoc-in [:label :text] hover-text)
|
||||
|
||||
utils/mobile? (update-in [:label] assoc :x (* 20 4) :y 12)
|
||||
utils/mobile? (update-in [:label] assoc :x (* 20 4 utils/ui-scale) :y 12)
|
||||
|
||||
(and utils/mobile? (or item-cursor action-cursor)
|
||||
(= :main action-cursor))
|
||||
@@ -307,7 +312,7 @@
|
||||
(assoc
|
||||
(texture (aget all-icons 0 (.indexOf utils/+all-cursors+ (or item-cursor action-cursor))))
|
||||
:x 4 :y 4
|
||||
:width (* 18 4) :height (* 16 4)))
|
||||
:width (* 18 4 utils/ui-scale) :height (* 16 4 utils/ui-scale)))
|
||||
|
||||
(not utils/mobile?) (update-in [:label] assoc :x scene-x :y scene-y)
|
||||
|
||||
|
||||
@@ -1125,13 +1125,7 @@ void main ()
|
||||
e)))
|
||||
|
||||
(defn mouse-moved [screen entities {:keys [input-x input-y] :as options}]
|
||||
(if utils/mobile?
|
||||
(-> entities
|
||||
(assoc-in [:cursor :last-pos] [0 0])
|
||||
(assoc-in [:cursor :last] [:main nil])
|
||||
(assoc-in [:cursor :override] nil)
|
||||
(assoc-in [:cursor :down-target] nil)
|
||||
(assoc-in [:label :text] ""))
|
||||
(when (or (not utils/mobile?) (get-in entities [:cursor :came-from-inventory?]))
|
||||
(utils/update-override screen (assoc-in entities [:cursor :last-pos] [input-x input-y]) options)))
|
||||
|
||||
(defn grab-layers [entities]
|
||||
@@ -1322,17 +1316,22 @@ void main ()
|
||||
:on-pan
|
||||
(fn [screen entities {:keys [input-x input-y delta-x delta-y]}]
|
||||
(when (and utils/mobile?
|
||||
(get-in entities [:state :active?])
|
||||
(not (get-in entities [:cursor :came-from-inventory?])))
|
||||
(get-in entities [:state :active?])
|
||||
(not (get-in entities [:cursor :came-from-inventory?])))
|
||||
(let [ideal-x (+ (get-in entities [:cam :x]) (- (/ delta-x 4)))
|
||||
ideal-y (+ (get-in entities [:cam :y]) (/ delta-y 4))]
|
||||
(-> entities
|
||||
(remove-cam-tweens)
|
||||
(assoc-in [:cursor :last-pos] [0 0])
|
||||
(assoc-in [:cam :ideal-x] ideal-x)
|
||||
(assoc-in [:cam :ideal-y] ideal-y)
|
||||
(assoc-in [:cam :x] (utils/bound-to-camera ideal-x 320 (get-in entities [:cam :zoom])) )
|
||||
(assoc-in [:cam :y] (utils/bound-to-camera ideal-y 240 (get-in entities [:cam :zoom])) )))))
|
||||
ideal-y (+ (get-in entities [:cam :y]) (/ delta-y 4))]
|
||||
(-> entities
|
||||
(remove-cam-tweens)
|
||||
(assoc-in [:cursor :last-pos] [0 0])
|
||||
(assoc-in [:cursor :last] [:main nil])
|
||||
(assoc-in [:cursor :override] nil)
|
||||
(assoc-in [:cursor :down-target] nil)
|
||||
(assoc-in [:label :text] "")
|
||||
(assoc-in [:cursor :last-pos] [0 0])
|
||||
(assoc-in [:cam :ideal-x] ideal-x)
|
||||
(assoc-in [:cam :ideal-y] ideal-y)
|
||||
(assoc-in [:cam :x] (utils/bound-to-camera ideal-x 320 (get-in entities [:cam :zoom])) )
|
||||
(assoc-in [:cam :y] (utils/bound-to-camera ideal-y 240 (get-in entities [:cam :zoom])) )))))
|
||||
|
||||
:pinch-stop
|
||||
(fn [screen entities options]
|
||||
@@ -1557,7 +1556,7 @@ void main ()
|
||||
|
||||
:on-save (fn [screen entities options]
|
||||
(when-not (get-in entities [:fg-actions :script-running?])
|
||||
(let [date (.format (java.text.SimpleDateFormat. "MM/dd/YY") (java.util.Date.))
|
||||
(let [date (.format (java.text.SimpleDateFormat. "MM/dd/yy") (java.util.Date.))
|
||||
save-name (str (-> entities :room :name) " - " date)]
|
||||
(utils/save entities
|
||||
(str (.getTime (java.util.Date.)))
|
||||
@@ -1938,7 +1937,7 @@ void main ()
|
||||
:anim-start 0
|
||||
:opacity 0.8)
|
||||
:all-items (texture! (texture (pixmap "cursor.png")) :split 18 16)
|
||||
#_#_:fps (->> (assoc (label "" (color :white) ) :x 5 :baseline 0 :opacity 0.1)
|
||||
#_:fps #_(->> (assoc (label "" (color :white) ) :x 5 :baseline 0 :opacity 0.1)
|
||||
(utils/add-actor-to-stage screen))}))
|
||||
|
||||
:on-render
|
||||
|
||||
Reference in New Issue
Block a user