Rename draw-entity! to draw! to reduce redundancy
This commit is contained in:
@@ -466,7 +466,7 @@ with the tiled map file at `path` and `unit` scale.
|
|||||||
(let [^Batch batch (.getSpriteBatch renderer)]
|
(let [^Batch batch (.getSpriteBatch renderer)]
|
||||||
(.begin batch)
|
(.begin batch)
|
||||||
(doseq [entity entities]
|
(doseq [entity entities]
|
||||||
(e/draw-entity! entity screen batch))
|
(e/draw! entity screen batch))
|
||||||
(.end batch))
|
(.end batch))
|
||||||
entities)
|
entities)
|
||||||
|
|
||||||
@@ -475,7 +475,7 @@ with the tiled map file at `path` and `unit` scale.
|
|||||||
(let [^Batch batch (.getBatch renderer)]
|
(let [^Batch batch (.getBatch renderer)]
|
||||||
(.begin batch)
|
(.begin batch)
|
||||||
(doseq [entity entities]
|
(doseq [entity entities]
|
||||||
(e/draw-entity! entity screen batch))
|
(e/draw! entity screen batch))
|
||||||
(.end batch))
|
(.end batch))
|
||||||
entities)
|
entities)
|
||||||
|
|
||||||
@@ -483,7 +483,7 @@ with the tiled map file at `path` and `unit` scale.
|
|||||||
[{:keys [^ModelBatch renderer ^Camera camera] :as screen} entities]
|
[{:keys [^ModelBatch renderer ^Camera camera] :as screen} entities]
|
||||||
(.begin renderer camera)
|
(.begin renderer camera)
|
||||||
(doseq [entity entities]
|
(doseq [entity entities]
|
||||||
(e/draw-entity! entity screen nil))
|
(e/draw! entity screen nil))
|
||||||
(.end renderer)
|
(.end renderer)
|
||||||
entities)
|
entities)
|
||||||
|
|
||||||
@@ -600,6 +600,6 @@ to overlap correctly with the entities.
|
|||||||
sort-fn)]
|
sort-fn)]
|
||||||
(if-let [layer (:layer entity)]
|
(if-let [layer (:layer entity)]
|
||||||
(.renderTileLayer renderer layer)
|
(.renderTileLayer renderer layer)
|
||||||
(e/draw-entity! entity screen batch)))
|
(e/draw! entity screen batch)))
|
||||||
(.end batch))
|
(.end batch))
|
||||||
entities))
|
entities))
|
||||||
|
|||||||
@@ -9,21 +9,21 @@
|
|||||||
[com.badlogic.gdx.scenes.scene2d Actor]))
|
[com.badlogic.gdx.scenes.scene2d Actor]))
|
||||||
|
|
||||||
(defprotocol Entity
|
(defprotocol Entity
|
||||||
(draw-entity! [this screen batch] "Draws the entity"))
|
(draw! [this screen batch] "Draws the entity"))
|
||||||
|
|
||||||
(extend-protocol Entity
|
(extend-protocol Entity
|
||||||
clojure.lang.PersistentArrayMap
|
clojure.lang.PersistentArrayMap
|
||||||
(draw-entity! [this screen batch])
|
(draw! [this screen batch])
|
||||||
clojure.lang.PersistentHashMap
|
clojure.lang.PersistentHashMap
|
||||||
(draw-entity! [this screen batch])
|
(draw! [this screen batch])
|
||||||
nil
|
nil
|
||||||
(draw-entity! [this screen batch]))
|
(draw! [this screen batch]))
|
||||||
|
|
||||||
(defrecord TextureEntity [object] Entity
|
(defrecord TextureEntity [object] Entity
|
||||||
(draw-entity! [{:keys [^TextureRegion object x y width height
|
(draw! [{:keys [^TextureRegion object x y width height
|
||||||
scale-x scale-y angle origin-x origin-y]}
|
scale-x scale-y angle origin-x origin-y]}
|
||||||
_
|
_
|
||||||
batch]
|
batch]
|
||||||
(let [x (float (or x 0))
|
(let [x (float (or x 0))
|
||||||
y (float (or y 0))
|
y (float (or y 0))
|
||||||
width (float (or width (.getRegionWidth object)))
|
width (float (or width (.getRegionWidth object)))
|
||||||
@@ -39,7 +39,7 @@
|
|||||||
(.draw ^Batch batch object x y width height)))))
|
(.draw ^Batch batch object x y width height)))))
|
||||||
|
|
||||||
(defrecord NinePatchEntity [object] Entity
|
(defrecord NinePatchEntity [object] Entity
|
||||||
(draw-entity! [{:keys [^NinePatch object x y width height]} _ batch]
|
(draw! [{:keys [^NinePatch object x y width height]} _ batch]
|
||||||
(let [x (float (or x 0))
|
(let [x (float (or x 0))
|
||||||
y (float (or y 0))
|
y (float (or y 0))
|
||||||
width (float (or width (.getTotalWidth object)))
|
width (float (or width (.getTotalWidth object)))
|
||||||
@@ -47,7 +47,7 @@
|
|||||||
(.draw object ^Batch batch x y width height))))
|
(.draw object ^Batch batch x y width height))))
|
||||||
|
|
||||||
(defrecord ParticleEffectEntity [object] Entity
|
(defrecord ParticleEffectEntity [object] Entity
|
||||||
(draw-entity! [{:keys [^ParticleEffect object x y delta-time]} _ batch]
|
(draw! [{:keys [^ParticleEffect object x y delta-time]} _ batch]
|
||||||
(let [x (float (or x 0))
|
(let [x (float (or x 0))
|
||||||
y (float (or y 0))
|
y (float (or y 0))
|
||||||
^Graphics g (Gdx/graphics)
|
^Graphics g (Gdx/graphics)
|
||||||
@@ -56,8 +56,8 @@
|
|||||||
(.draw object ^Batch batch delta-time))))
|
(.draw object ^Batch batch delta-time))))
|
||||||
|
|
||||||
(defrecord ActorEntity [object] Entity
|
(defrecord ActorEntity [object] Entity
|
||||||
(draw-entity! [{:keys [^Actor object x y width height
|
(draw! [{:keys [^Actor object x y width height
|
||||||
scale-x scale-y angle origin-x origin-y]} _ batch]
|
scale-x scale-y angle origin-x origin-y]} _ batch]
|
||||||
(some->> x (.setX object))
|
(some->> x (.setX object))
|
||||||
(some->> y (.setY object))
|
(some->> y (.setY object))
|
||||||
(some->> width (.setWidth object))
|
(some->> width (.setWidth object))
|
||||||
@@ -76,9 +76,9 @@
|
|||||||
(.draw object ^Batch batch 1)))
|
(.draw object ^Batch batch 1)))
|
||||||
|
|
||||||
(defrecord ModelEntity [object] Entity
|
(defrecord ModelEntity [object] Entity
|
||||||
(draw-entity! [{:keys [^ModelInstance object x y z]}
|
(draw! [{:keys [^ModelInstance object x y z]}
|
||||||
{:keys [^ModelBatch renderer ^Environment attributes]}
|
{:keys [^ModelBatch renderer ^Environment attributes]}
|
||||||
_]
|
_]
|
||||||
(when (or x y z)
|
(when (or x y z)
|
||||||
(let [^Matrix4 m (. object transform)
|
(let [^Matrix4 m (. object transform)
|
||||||
x (float (or x 0))
|
x (float (or x 0))
|
||||||
@@ -88,10 +88,10 @@
|
|||||||
(.render renderer object attributes)))
|
(.render renderer object attributes)))
|
||||||
|
|
||||||
(defrecord ShapeEntity [object] Entity
|
(defrecord ShapeEntity [object] Entity
|
||||||
(draw-entity! [{:keys [^ShapeRenderer object type draw!
|
(draw! [{:keys [^ShapeRenderer object type draw!
|
||||||
x y scale-x scale-y angle]}
|
x y scale-x scale-y angle]}
|
||||||
{:keys [^Camera camera]}
|
{:keys [^Camera camera]}
|
||||||
batch]
|
batch]
|
||||||
(when batch
|
(when batch
|
||||||
(.end ^Batch batch))
|
(.end ^Batch batch))
|
||||||
(when camera
|
(when camera
|
||||||
@@ -113,6 +113,6 @@
|
|||||||
(.begin ^Batch batch))))
|
(.begin ^Batch batch))))
|
||||||
|
|
||||||
(defrecord BundleEntity [entities] Entity
|
(defrecord BundleEntity [entities] Entity
|
||||||
(draw-entity! [{:keys [entities] :as entity} screen batch]
|
(draw! [{:keys [entities] :as entity} screen batch]
|
||||||
(doseq [e entities]
|
(doseq [e entities]
|
||||||
(draw-entity! (merge e (apply dissoc entity (keys e))) screen batch))))
|
(draw! (merge e (apply dissoc entity (keys e))) screen batch))))
|
||||||
|
|||||||
Reference in New Issue
Block a user