picking up the teddy and portait add and remove entities.

This commit is contained in:
Bryce Covert
2016-10-06 22:21:25 -07:00
parent 55fd9495eb
commit 1ac2a2ef3a
2 changed files with 70 additions and 44 deletions

View File

@@ -10,18 +10,20 @@
(merge entity
{:id id
:mouse-in? (fn [entities x y]
(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 ^TextureRegion region) 0))
height (or height (if (instance? TextureRegion region ) (.getRegionHeight ^TextureRegion region) 0))
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 scale-x 1)))
(+ entity-y (* height (or scale-y 1)))) x y)))}
(if-let [box (get-in entities [:room :entities id :box])]
((apply zone/box box) x y)
(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 ^TextureRegion region) 0))
height (or height (if (instance? TextureRegion region ) (.getRegionHeight ^TextureRegion region) 0))
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 scale-x 1)))
(+ entity-y (* height (or scale-y 1)))) x y))))}
(when (or script scripts only-script)
{:get-script (fn [cursor [x y]]
(cond only-script