better scaling but not perfect.
This commit is contained in:
@@ -9,11 +9,17 @@
|
|||||||
(defn make-entity [id entity]
|
(defn make-entity [id entity]
|
||||||
(merge entity
|
(merge entity
|
||||||
{:mouse-in? (fn [entities x y]
|
{:mouse-in? (fn [entities x y]
|
||||||
(let [{entity-x :x entity-y :y width :width scale-x :scale-x scale-y :scale-y height :height region :object} (get-in entities [:room :entities id])
|
(let [{entity-x :x entity-y :y width :width scale-x :scale-x scale-y :scale-y origin-x :origin-x origin-y :origin-y height :height region :object} (get-in entities [:room :entities id])
|
||||||
|
|
||||||
width (or width (if (instance? TextureRegion region ) (.getRegionWidth region) 0))
|
width (or width (if (instance? TextureRegion region ) (.getRegionWidth region) 0))
|
||||||
height (or height (if (instance? TextureRegion region ) (.getRegionHeight region) 0))]
|
height (or height (if (instance? TextureRegion region ) (.getRegionHeight region) 0))
|
||||||
((zone/box entity-x entity-y (+ entity-x (* width (or 1 scale-x))) (+ entity-y (* height (or scale-y 1)))) x y)))}
|
entity-x (- entity-x (* (or origin-x 0)
|
||||||
|
(or scale-x 1)))
|
||||||
|
entity-y (- entity-y (* (or origin-y 0)
|
||||||
|
(or scale-y 1)))]
|
||||||
|
((zone/box entity-x entity-y
|
||||||
|
(+ entity-x (* width (or 1 scale-x)))
|
||||||
|
(+ entity-y (* height (or scale-y 1)))) x y)))}
|
||||||
(when (or (:scripts entity) (:script entity))
|
(when (or (:scripts entity) (:script entity))
|
||||||
{:get-script (fn [cursor [x y]]
|
{:get-script (fn [cursor [x y]]
|
||||||
(if (= :main cursor)
|
(if (= :main cursor)
|
||||||
|
|||||||
Reference in New Issue
Block a user