From e3ea76d4c63738b0bee9328d0af0bd5b6f41954d Mon Sep 17 00:00:00 2001 From: oakes Date: Wed, 15 Jan 2014 16:47:23 -0500 Subject: [PATCH] Add vector macros --- src/play_clj/math.clj | 28 +++++++++++++++++++++++----- src/play_clj/physics.clj | 2 +- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/src/play_clj/math.clj b/src/play_clj/math.clj index abd9934..5a4042a 100644 --- a/src/play_clj/math.clj +++ b/src/play_clj/math.clj @@ -1,8 +1,26 @@ (ns play-clj.math (:import [com.badlogic.gdx.math Vector2 Vector3])) -(defn vector - ([x y] - (Vector2. x y)) - ([x y z] - (Vector3. x y z))) +(defn vector-2* + [x y] + (Vector2. x y)) + +(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)) diff --git a/src/play_clj/physics.clj b/src/play_clj/physics.clj index 08b7a6b..d797eed 100644 --- a/src/play_clj/physics.clj +++ b/src/play_clj/physics.clj @@ -9,7 +9,7 @@ ([gravity-x gravity-y] (world* gravity-x gravity-y true)) ([gravity-x gravity-y sleep?] - (World. (m/vector gravity-x gravity-y) sleep?))) + (World. (m/vector-2 gravity-x gravity-y) sleep?))) (defmacro world [gravity-x gravity-y & options]