Start physics

This commit is contained in:
oakes
2014-01-15 16:00:39 -05:00
parent 9208eca36c
commit 868fabc3ed
2 changed files with 28 additions and 0 deletions

21
src/play_clj/physics.clj Normal file
View 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))

View File

@@ -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!