Make step! a proper multi-arity function

This commit is contained in:
oakes
2014-04-20 22:32:00 -04:00
parent bf0ea4f435
commit 6131b99776
2 changed files with 27 additions and 25 deletions

View File

@@ -254,11 +254,12 @@ such as :on-begin-contact."
(defn step! (defn step!
"Runs the physics simulations for a single frame and optionally returns the "Runs the physics simulations for a single frame and optionally returns the
`entities` with their positions updated." `entities` with their positions updated."
[{: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}
:as screen} :as screen}]
& [entities]] (.step world time-step velocity-iterations position-iterations))
(.step world time-step velocity-iterations position-iterations) ([screen entities]
(step! screen)
(when entities (when entities
(map (fn [e] (map (fn [e]
(if (u/get-obj e :body) (if (u/get-obj e :body)
@@ -266,4 +267,4 @@ such as :on-begin-contact."
:x (body-x e) :x (body-x e)
:y (body-y e)) :y (body-y e))
e)) e))
entities))) entities))))

View File

@@ -311,11 +311,12 @@ such as :on-begin-contact."
(defn step! (defn step!
"Runs the physics simulations for a single frame and optionally returns the "Runs the physics simulations for a single frame and optionally returns the
`entities` with their positions updated." `entities` with their positions updated."
[{:keys [delta-time max-sub-steps time-step] ([{:keys [delta-time max-sub-steps time-step]
:or {max-sub-steps 5 time-step (/ 1 60)} :or {max-sub-steps 5 time-step (/ 1 60)}
:as screen} :as screen}]
& [entities]] (bullet-3d! screen :step-simulation delta-time max-sub-steps time-step))
(bullet-3d! screen :step-simulation delta-time max-sub-steps time-step) ([screen entities]
(step! screen)
(when entities (when entities
(map (fn [e] (map (fn [e]
(if (u/get-obj e :body) (if (u/get-obj e :body)
@@ -324,4 +325,4 @@ such as :on-begin-contact."
:y (body-y e) :y (body-y e)
:z (body-z e)) :z (body-z e))
e)) e))
entities))) entities))))