Merge bundle into internal entities

This commit is contained in:
oakes
2014-04-09 18:35:22 -04:00
parent a8a980a569
commit ad73891910
2 changed files with 7 additions and 5 deletions

View File

@@ -10,10 +10,12 @@
(defn bundle (defn bundle
"Returns an entity containing other entities. This is a useful way to keep "Returns an entity containing other entities. This is a useful way to keep
related entities together. They will be drawn in the order they appear in the related entities together. They will be drawn in the order they appear in the
internal :entities vector. internal :entities vector. Any keys in the bundle, such as :x and :y, will
override the equivalent keys in each entity when being drawn.
(bundle (shape :filled) (texture \"image.png\")) (bundle (shape :filled) (shape :line))
(assoc (bundle) :entities [])" (assoc (bundle (shape :filled) (shape :line))
:x 100 :y 100)"
[& entities] [& entities]
(BundleEntity. entities)) (BundleEntity. entities))

View File

@@ -75,6 +75,6 @@
(.end object))) (.end object)))
(defrecord BundleEntity [entities] Entity (defrecord BundleEntity [entities] Entity
(draw-entity! [{:keys [entities]} screen batch] (draw-entity! [{:keys [entities] :as entity} screen batch]
(doseq [e entities] (doseq [e entities]
(draw-entity! e screen batch)))) (draw-entity! (merge e entity) screen batch))))