diff --git a/src/play_clj/core_utils.clj b/src/play_clj/core_utils.clj index bfa33ba..a6eed46 100644 --- a/src/play_clj/core_utils.clj +++ b/src/play_clj/core_utils.clj @@ -10,10 +10,12 @@ (defn bundle "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 -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\")) - (assoc (bundle) :entities [])" + (bundle (shape :filled) (shape :line)) + (assoc (bundle (shape :filled) (shape :line)) + :x 100 :y 100)" [& entities] (BundleEntity. entities)) diff --git a/src/play_clj/entities.clj b/src/play_clj/entities.clj index 9c5e6df..7f67065 100644 --- a/src/play_clj/entities.clj +++ b/src/play_clj/entities.clj @@ -75,6 +75,6 @@ (.end object))) (defrecord BundleEntity [entities] Entity - (draw-entity! [{:keys [entities]} screen batch] + (draw-entity! [{:keys [entities] :as entity} screen batch] (doseq [e entities] - (draw-entity! e screen batch)))) + (draw-entity! (merge e entity) screen batch))))