Add more body functions and move entities in step! function
This commit is contained in:
@@ -234,7 +234,13 @@
|
|||||||
(.step ^World world time-step velocity-iterations position-iterations)))
|
(.step ^World world time-step velocity-iterations position-iterations)))
|
||||||
([screen entities]
|
([screen entities]
|
||||||
(step! screen)
|
(step! screen)
|
||||||
entities))
|
(map (fn [entity]
|
||||||
|
(if-let [body (:body entity)]
|
||||||
|
(assoc entity
|
||||||
|
:x (g2dp/body-x body)
|
||||||
|
:y (g2dp/body-y body))
|
||||||
|
entity))
|
||||||
|
entities)))
|
||||||
|
|
||||||
; cameras
|
; cameras
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
(:require [play-clj.math :as m]
|
(:require [play-clj.math :as m]
|
||||||
[play-clj.utils :as u])
|
[play-clj.utils :as u])
|
||||||
(:import [com.badlogic.gdx.physics.box2d Body BodyDef ChainShape CircleShape
|
(:import [com.badlogic.gdx.physics.box2d Body BodyDef ChainShape CircleShape
|
||||||
ContactListener EdgeShape FixtureDef PolygonShape World]))
|
ContactListener EdgeShape FixtureDef PolygonShape Transform World]))
|
||||||
|
|
||||||
; world
|
; world
|
||||||
|
|
||||||
@@ -54,6 +54,34 @@
|
|||||||
(u/calls! ^Body object# ~@options)
|
(u/calls! ^Body object# ~@options)
|
||||||
object#))
|
object#))
|
||||||
|
|
||||||
|
(defn body-x
|
||||||
|
[entity]
|
||||||
|
(. (body! entity :get-position) x))
|
||||||
|
|
||||||
|
(defn body-y
|
||||||
|
[entity]
|
||||||
|
(. (body! entity :get-position) y))
|
||||||
|
|
||||||
|
(defn body-angle
|
||||||
|
[entity]
|
||||||
|
(.getRotation ^Transform (body! entity :get-transform)))
|
||||||
|
|
||||||
|
(defn body-transform!
|
||||||
|
[entity x y angle]
|
||||||
|
(body! entity :set-transform x y angle))
|
||||||
|
|
||||||
|
(defn body-x!
|
||||||
|
[entity x]
|
||||||
|
(body-transform! entity x (body-y entity) (body-angle entity)))
|
||||||
|
|
||||||
|
(defn body-y!
|
||||||
|
[entity y]
|
||||||
|
(body-transform! entity (body-x entity) y (body-angle entity)))
|
||||||
|
|
||||||
|
(defn body-angle!
|
||||||
|
[entity angle]
|
||||||
|
(body-transform! entity (body-x entity) (body-y entity) angle))
|
||||||
|
|
||||||
; fixtures
|
; fixtures
|
||||||
|
|
||||||
(defn fixture
|
(defn fixture
|
||||||
|
|||||||
Reference in New Issue
Block a user