Add vector macros
This commit is contained in:
@@ -1,8 +1,26 @@
|
|||||||
(ns play-clj.math
|
(ns play-clj.math
|
||||||
(:import [com.badlogic.gdx.math Vector2 Vector3]))
|
(:import [com.badlogic.gdx.math Vector2 Vector3]))
|
||||||
|
|
||||||
(defn vector
|
(defn vector-2*
|
||||||
([x y]
|
[x y]
|
||||||
(Vector2. x y))
|
(Vector2. x y))
|
||||||
([x y z]
|
|
||||||
(Vector3. x y z)))
|
(defmacro vector-2
|
||||||
|
[x y & options]
|
||||||
|
`(u/calls! ^Vector2 (vector-2* ~x ~y) ~@options))
|
||||||
|
|
||||||
|
(defmacro vector-2!
|
||||||
|
[object k & options]
|
||||||
|
`(u/call! ^Vector2 ~object ~k ~@options))
|
||||||
|
|
||||||
|
(defn vector-3*
|
||||||
|
[x y z]
|
||||||
|
(Vector3. x y z))
|
||||||
|
|
||||||
|
(defmacro vector-3
|
||||||
|
[x y z & options]
|
||||||
|
`(u/calls! ^Vector3 (vector-3* ~x ~y ~z) ~@options))
|
||||||
|
|
||||||
|
(defmacro vector-3!
|
||||||
|
[object k & options]
|
||||||
|
`(u/call! ^Vector3 ~object ~k ~@options))
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
([gravity-x gravity-y]
|
([gravity-x gravity-y]
|
||||||
(world* gravity-x gravity-y true))
|
(world* gravity-x gravity-y true))
|
||||||
([gravity-x gravity-y sleep?]
|
([gravity-x gravity-y sleep?]
|
||||||
(World. (m/vector gravity-x gravity-y) sleep?)))
|
(World. (m/vector-2 gravity-x gravity-y) sleep?)))
|
||||||
|
|
||||||
(defmacro world
|
(defmacro world
|
||||||
[gravity-x gravity-y & options]
|
[gravity-x gravity-y & options]
|
||||||
|
|||||||
Reference in New Issue
Block a user