Start physics
This commit is contained in:
21
src/play_clj/physics.clj
Normal file
21
src/play_clj/physics.clj
Normal file
@@ -0,0 +1,21 @@
|
||||
(ns play-clj.physics
|
||||
(:require [play-clj.utils :as u])
|
||||
(:import [com.badlogic.gdx.physics.box2d World]))
|
||||
|
||||
(defn world*
|
||||
([]
|
||||
(world* 0 0 true))
|
||||
([gravity-x gravity-y]
|
||||
(world* gravity-x gravity-y true))
|
||||
([gravity-x gravity-y sleep?]
|
||||
(World. (u/gdx-vector gravity-x gravity-y) sleep?)))
|
||||
|
||||
(defmacro world
|
||||
[gravity-x gravity-y & options]
|
||||
`(let [object# (world* ~gravity-x ~gravity-y)]
|
||||
(u/calls! ^World object# ~@options)
|
||||
object#))
|
||||
|
||||
(defmacro world!
|
||||
[{:keys [^World world]} k & options]
|
||||
`(u/call! ^World ~world ~k ~@options))
|
||||
@@ -1,6 +1,7 @@
|
||||
(ns play-clj.utils
|
||||
(:require [clojure.string :as s])
|
||||
(:import [com.badlogic.gdx.graphics.g2d TextureRegion]
|
||||
[com.badlogic.gdx.math Vector2 Vector3]
|
||||
[com.badlogic.gdx.scenes.scene2d Actor]
|
||||
[com.badlogic.gdx.utils Array ArrayMap]))
|
||||
|
||||
@@ -67,6 +68,12 @@
|
||||
(.put amap k v))
|
||||
amap))
|
||||
|
||||
(defn gdx-vector
|
||||
([x y]
|
||||
(Vector2. x y))
|
||||
([x y z]
|
||||
(Vector3. x y z)))
|
||||
|
||||
; java interop
|
||||
|
||||
(defmacro call!
|
||||
|
||||
Reference in New Issue
Block a user