enhanced box.

This commit is contained in:
Bryce Covert
2016-02-15 08:09:04 -08:00
parent 60757614b1
commit 7e8af55d3a
5 changed files with 19 additions and 14 deletions

View File

@@ -30,14 +30,16 @@
(or (scripts (:value cursor)) (scripts :default)))))})))
(defn make [& {:keys [collision interactions entities] :as params}]
(let [interactions-as-list (for [[id spec] interactions]
(merge spec {:mouse-in? (fn [_ x y]
((apply zone/box (:box spec)) x y))
:get-script (fn [cursor [x y]]
(if (= :main cursor)
(:script spec)
(when-let [scripts (:scripts spec)]
(or (scripts (:value cursor)) (scripts :default)))))
:id id}))
(merge spec
(when (:box spec)
{:mouse-in? (fn [_ x y]
((apply zone/box (:box spec)) x y))})
{:get-script (fn [cursor [x y]]
(if (= :main cursor)
(:script spec)
(when-let [scripts (:scripts spec)]
(or (scripts (:value cursor)) (scripts :default)))))
:id id}))
entities (into {} (for [[id entity] entities]
[id (make-entity id entity)]))]
(merge params {:collision (advent.pathfind/map-from-resource collision)