Allow entities to be stored in maps
This commit is contained in:
@@ -11,11 +11,20 @@
|
|||||||
(defprotocol Entity
|
(defprotocol Entity
|
||||||
(draw-entity! [this screen batch] "Draws the entity"))
|
(draw-entity! [this screen batch] "Draws the entity"))
|
||||||
|
|
||||||
|
(defn draw-map!
|
||||||
|
[m screen batch]
|
||||||
|
(doseq [[k v] m]
|
||||||
|
(try
|
||||||
|
(draw-entity! v screen batch)
|
||||||
|
(catch Exception _))))
|
||||||
|
|
||||||
(extend-protocol Entity
|
(extend-protocol Entity
|
||||||
clojure.lang.PersistentArrayMap
|
clojure.lang.PersistentArrayMap
|
||||||
(draw-entity! [this screen batch])
|
(draw-entity! [this screen batch]
|
||||||
|
(draw-map! this screen batch))
|
||||||
clojure.lang.PersistentHashMap
|
clojure.lang.PersistentHashMap
|
||||||
(draw-entity! [this screen batch])
|
(draw-entity! [this screen batch]
|
||||||
|
(draw-map! this screen batch))
|
||||||
nil
|
nil
|
||||||
(draw-entity! [this screen batch]))
|
(draw-entity! [this screen batch]))
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user