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