Provide default position/size values when drawing and improve step! function

This commit is contained in:
oakes
2014-01-17 16:04:20 -05:00
parent 52ab737a32
commit 01104593ec

View File

@@ -182,8 +182,9 @@
(.draw object batch 1)) (.draw object batch 1))
(defmethod draw-entity! :texture (defmethod draw-entity! :texture
[[^SpriteBatch batch {:keys [^TextureRegion object x y width height]}]] [[^SpriteBatch batch {:keys [^TextureRegion object x y width height]
(assert (and object x y width height)) :or {x 0 y 0 width 0 height 0}}]]
(assert object)
(.draw batch object (float x) (float y) (float width) (float height))) (.draw batch object (float x) (float y) (float width) (float height)))
(defn draw! [{:keys [renderer] :as screen} entities] (defn draw! [{:keys [renderer] :as screen} entities]
@@ -218,15 +219,18 @@
(render! screen) (render! screen)
(draw! screen entities))) (draw! screen entities)))
; physics
(defn step! (defn step!
[{:keys [world time-step velocity-iterations position-iterations] ([{:keys [world time-step velocity-iterations position-iterations]
:or {time-step (/ 1 60) velocity-iterations 10 position-iterations 10}} :or {time-step (/ 1 60) velocity-iterations 10 position-iterations 10}}]
entities] (assert world)
(assert world) (cond
(cond (isa? (type world) World)
(isa? (type world) World) (.step ^World world time-step velocity-iterations position-iterations)))
(.step ^World world time-step velocity-iterations position-iterations)) ([screen entities]
entities) (step! screen)
entities))
; cameras ; cameras