diff --git a/src/play_clj/g2d_physics.clj b/src/play_clj/g2d_physics.clj index 6a40c5e..1d3e7e6 100644 --- a/src/play_clj/g2d_physics.clj +++ b/src/play_clj/g2d_physics.clj @@ -254,16 +254,17 @@ such as :on-begin-contact." (defn step! "Runs the physics simulations for a single frame and optionally returns the `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} - :as screen} - & [entities]] - (.step world time-step velocity-iterations position-iterations) - (when entities - (map (fn [e] - (if (u/get-obj e :body) - (assoc e - :x (body-x e) - :y (body-y e)) - e)) - entities))) + :as screen}] + (.step world time-step velocity-iterations position-iterations)) + ([screen entities] + (step! screen) + (when entities + (map (fn [e] + (if (u/get-obj e :body) + (assoc e + :x (body-x e) + :y (body-y e)) + e)) + entities)))) diff --git a/src/play_clj/g3d_physics.clj b/src/play_clj/g3d_physics.clj index 18b2625..e6bf763 100644 --- a/src/play_clj/g3d_physics.clj +++ b/src/play_clj/g3d_physics.clj @@ -311,17 +311,18 @@ such as :on-begin-contact." (defn step! "Runs the physics simulations for a single frame and optionally returns the `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)} - :as screen} - & [entities]] - (bullet-3d! screen :step-simulation delta-time max-sub-steps time-step) - (when entities - (map (fn [e] - (if (u/get-obj e :body) - (assoc e - :x (body-x e) - :y (body-y e) - :z (body-z e)) - e)) - entities))) + :as screen}] + (bullet-3d! screen :step-simulation delta-time max-sub-steps time-step)) + ([screen entities] + (step! screen) + (when entities + (map (fn [e] + (if (u/get-obj e :body) + (assoc e + :x (body-x e) + :y (body-y e) + :z (body-z e)) + e)) + entities))))