Change docstrings

This commit is contained in:
oakes
2014-03-31 19:57:19 -04:00
parent ed67cef30c
commit c036e36786
13 changed files with 249 additions and 376 deletions

View File

@@ -34,18 +34,15 @@
(load "core_utils") (load "core_utils")
(defn ^:private reset-changed! (defn ^:private reset-changed!
"Internal use only"
[e-atom e-old e-new] [e-atom e-old e-new]
(when (not= e-old e-new) (when (not= e-old e-new)
(compare-and-set! e-atom e-old e-new))) (compare-and-set! e-atom e-old e-new)))
(defn ^:private wrapper (defn ^:private wrapper
"Internal use only"
[screen f] [screen f]
(f)) (f))
(defn defscreen* (defn defscreen*
"Internal use only"
[{:keys [screen entities [{:keys [screen entities
on-show on-render on-hide on-pause on-resize on-resume on-timer] on-show on-render on-hide on-pause on-resize on-resume on-timer]
:as options}] :as options}]
@@ -86,9 +83,7 @@
:input-listeners (global-listeners options execute-fn!)})) :input-listeners (global-listeners options execute-fn!)}))
(defmacro defscreen (defmacro defscreen
"Creates vars for all the anonymous functions provided to it, so they can be "Defines a screen, and creates vars for all the functions inside of it."
replaced by simply reloading the namespace, and creates a var for the symbol `n`
bound to a map containing various important values related to the screen"
[n & {:keys [] :as options}] [n & {:keys [] :as options}]
`(let [fn-syms# (->> (for [[k# v#] ~options] `(let [fn-syms# (->> (for [[k# v#] ~options]
[k# (intern *ns* (symbol (str '~n "-" (name k#))) v#)]) [k# (intern *ns* (symbol (str '~n "-" (name k#))) v#)])
@@ -106,7 +101,6 @@ bound to a map containing various important values related to the screen"
(def ~n (defscreen* syms#)))) (def ~n (defscreen* syms#))))
(defn defgame* (defn defgame*
"Internal use only"
[{:keys [on-create]}] [{:keys [on-create]}]
(proxy [Game] [] (proxy [Game] []
(create [] (create []
@@ -115,15 +109,14 @@ bound to a map containing various important values related to the screen"
(on-create this))))) (on-create this)))))
(defmacro defgame (defmacro defgame
"Creates a var for the symbol `n` bound to a [Game](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/Game.html) "Defines a game. This should only be called once."
object" {:url ""}
[n & {:keys [] :as options}] [n & {:keys [] :as options}]
`(defonce ~n (defgame* ~options))) `(defonce ~n (defgame* ~options)))
(defn set-screen! (defn set-screen!
"Creates a [Screen](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/Screen.html) "Creates and displays a screen for the `game` object, using one or more
object, sets it as the screen for the `game`, and runs the functions from `screen` maps in the order they were provided.
`screens` in the order they are provided in
(set-screen! hello-world main-screen text-screen)" (set-screen! hello-world main-screen text-screen)"
[^Game game & screens] [^Game game & screens]
@@ -146,9 +139,9 @@ object, sets it as the screen for the `game`, and runs the functions from
(defn update! (defn update!
"Runs the equivalent of `(swap! screen-atom assoc ...)`, where `screen-atom` "Runs the equivalent of `(swap! screen-atom assoc ...)`, where `screen-atom`
is the atom storing the screen map behind the scenes, and returns the new screen is the atom storing the screen map behind the scenes. Returns the updated
map `screen` map.
(update! screen :renderer (stage))" (update! screen :renderer (stage))"
[{:keys [update-fn!]} & args] [{:keys [update-fn!] :as screen} & args]
(update-fn! assoc args)) (update-fn! assoc args))

View File

@@ -3,7 +3,7 @@
; graphics ; graphics
(defn clear! (defn clear!
"Clears the screen with a uniform color, defaulting to black "Clears the screen with a uniform color, defaulting to black.
(clear!) (clear!)
(clear! 0.5 0.5 1 1)" (clear! 0.5 0.5 1 1)"
@@ -15,7 +15,7 @@
(.glClear (bit-or GL20/GL_COLOR_BUFFER_BIT GL20/GL_DEPTH_BUFFER_BIT))))) (.glClear (bit-or GL20/GL_COLOR_BUFFER_BIT GL20/GL_DEPTH_BUFFER_BIT)))))
(defmacro color (defmacro color
"Returns a [Color](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/Color.html) "Returns a [Color](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/Color.html).
(color :white) (color :white)
(color 1 1 1 1)" (color 1 1 1 1)"
@@ -28,49 +28,49 @@
; interop ; interop
(defmacro app! (defmacro app!
"Calls a single method on [Gdx.app](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/Application.html) "Calls a single method on [Gdx.app](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/Application.html).
(app! :error \"MYTAG\" \"An error occurred, so I'm logging it!\")" (app! :error \"MYTAG\" \"An error occurred, so I'm logging it!\")"
[k & options] [k & options]
`(u/call! ^Application (Gdx/app) ~k ~@options)) `(u/call! ^Application (Gdx/app) ~k ~@options))
(defmacro audio! (defmacro audio!
"Calls a single method on [Gdx.audio](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/Audio.html) "Calls a single method on [Gdx.audio](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/Audio.html).
(audio! :new-audio-recorder 44100 false)" (audio! :new-audio-recorder 44100 false)"
[k & options] [k & options]
`(u/call! ^Audio (Gdx/audio) ~k ~@options)) `(u/call! ^Audio (Gdx/audio) ~k ~@options))
(defmacro files! (defmacro files!
"Calls a single method on [Gdx.files](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/Files.html) "Calls a single method on [Gdx.files](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/Files.html).
(files! :internal \"image.png\")" (files! :internal \"image.png\")"
[k & options] [k & options]
`(u/call! ^Files (Gdx/files) ~k ~@options)) `(u/call! ^Files (Gdx/files) ~k ~@options))
(defmacro gl! (defmacro gl!
"Calls a single method on [Gdx.gl20](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/GL20.html) "Calls a single method on [Gdx.gl20](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/GL20.html).
(gl! :gl-create-program)" (gl! :gl-create-program)"
[k & options] [k & options]
`(u/call! ^GL20 (Gdx/gl20) ~k ~@options)) `(u/call! ^GL20 (Gdx/gl20) ~k ~@options))
(defmacro graphics! (defmacro graphics!
"Calls a single method on [Gdx.graphics](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/Graphics.html) "Calls a single method on [Gdx.graphics](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/Graphics.html).
(graphics! :is-fullscreen)" (graphics! :is-fullscreen)"
[k & options] [k & options]
`(u/call! ^Graphics (Gdx/graphics) ~k ~@options)) `(u/call! ^Graphics (Gdx/graphics) ~k ~@options))
(defmacro input! (defmacro input!
"Calls a single method on [Gdx.input](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/Input.html) "Calls a single method on [Gdx.input](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/Input.html).
(input! :is-touched)" (input! :is-touched)"
[k & options] [k & options]
`(u/call! ^Input (Gdx/input) ~k ~@options)) `(u/call! ^Input (Gdx/input) ~k ~@options))
(defmacro net! (defmacro net!
"Calls a single method on [Gdx.net](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/Net.html) "Calls a single method on [Gdx.net](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/Net.html).
(net! :open-uri \"https://nightcode.info/\")" (net! :open-uri \"https://nightcode.info/\")"
[k & options] [k & options]
@@ -79,10 +79,15 @@
; input/output ; input/output
(defn game (defn game
"Calls the global method cooresponding to `k` in a more Clojuresque way "Provides quick access to often-used functions.
(game :width) (game :width) ; width of the window
(game :is-touched?)" (game :height) ; height of the window
(game :fps) ; frames per second
(game :is-fullscreen?) ; whether the window is fullscreen
(game :is-touched?) ; whether the window is being touched/clicked
(game :x) ; the x position of the touch/click
(game :y) ; the y position of the touch/click"
[k] [k]
(case k (case k
:width (graphics! :get-width) :width (graphics! :get-width)
@@ -95,7 +100,7 @@
(u/throw-key-not-found k))) (u/throw-key-not-found k)))
(defmacro key-code (defmacro key-code
"Returns a static field from [Input.Keys](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/Input.Keys.html) "Returns a static field from [Input.Keys](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/Input.Keys.html).
(key-code :a) (key-code :a)
(key-code :page-down)" (key-code :page-down)"
@@ -103,7 +108,7 @@
`~(u/gdx-field "Input$Keys" (u/key->upper k))) `~(u/gdx-field "Input$Keys" (u/key->upper k)))
(defmacro is-pressed? (defmacro is-pressed?
"Returns a boolean indicating if the key cooresponding to `k` is being pressed "Returns a boolean indicating if the key cooresponding to `k` is being pressed.
(is-pressed? :a) (is-pressed? :a)
(is-pressed? :page-down)" (is-pressed? :page-down)"
@@ -111,26 +116,23 @@
`(input! :is-key-pressed (key-code ~k))) `(input! :is-key-pressed (key-code ~k)))
(defn ^:private add-input! (defn ^:private add-input!
"Internal use only"
[^InputProcessor p] [^InputProcessor p]
(let [^InputMultiplexer multi (input! :get-input-processor)] (let [^InputMultiplexer multi (input! :get-input-processor)]
(.addProcessor multi p))) (.addProcessor multi p)))
(defn ^:private remove-input! (defn ^:private remove-input!
"Internal use only"
[^InputProcessor p] [^InputProcessor p]
(let [^InputMultiplexer multi (input! :get-input-processor)] (let [^InputMultiplexer multi (input! :get-input-processor)]
(.removeProcessor multi p))) (.removeProcessor multi p)))
(defn sound* (defn sound*
"The function version of `sound`"
[path] [path]
(audio! :new-sound (if (string? path) (audio! :new-sound (if (string? path)
(files! :internal path) (files! :internal path)
path))) path)))
(defmacro sound (defmacro sound
"Returns a [Sound](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/audio/Sound.html) "Returns a [Sound](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/audio/Sound.html).
(sound \"playerhurt.wav\") (sound \"playerhurt.wav\")
(sound \"playerhurt.wav\" :play)" (sound \"playerhurt.wav\" :play)"
@@ -138,7 +140,7 @@
`(u/calls! ^Sound (sound* ~path) ~@options)) `(u/calls! ^Sound (sound* ~path) ~@options))
(defmacro sound! (defmacro sound!
"Calls a single method on a `sound` "Calls a single method on a `sound`.
(sound! object :play) (sound! object :play)
(sound! object :dispose)" (sound! object :dispose)"

View File

@@ -1,12 +1,11 @@
(in-ns 'play-clj.core) (in-ns 'play-clj.core)
(defn orthographic* (defn orthographic*
"The function version of `orthographic`"
[] []
(OrthographicCamera.)) (OrthographicCamera.))
(defmacro orthographic (defmacro orthographic
"Returns an [OrthographicCamera](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/OrthographicCamera.html) "Returns an [OrthographicCamera](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/OrthographicCamera.html).
(orthographic)" (orthographic)"
[& options] [& options]
@@ -14,20 +13,19 @@
(u/calls! object# ~@options))) (u/calls! object# ~@options)))
(defmacro orthographic! (defmacro orthographic!
"Calls a single method on an `orthographic`" "Calls a single method on an `orthographic`."
[screen k & options] [screen k & options]
`(let [^OrthographicCamera object# (u/get-obj ~screen :camera)] `(let [^OrthographicCamera object# (u/get-obj ~screen :camera)]
(u/call! object# ~k ~@options))) (u/call! object# ~k ~@options)))
(defn perspective* (defn perspective*
"The function version of `perspective`"
([] ([]
(PerspectiveCamera.)) (PerspectiveCamera.))
([field-of-view viewport-width viewport-height] ([field-of-view viewport-width viewport-height]
(PerspectiveCamera. field-of-view viewport-width viewport-height))) (PerspectiveCamera. field-of-view viewport-width viewport-height)))
(defmacro perspective (defmacro perspective
"Returns an [PerspectiveCamera](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/PerspectiveCamera.html) "Returns a [PerspectiveCamera](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/PerspectiveCamera.html).
(perspective)" (perspective)"
[fov vw vh & options] [fov vw vh & options]
@@ -35,13 +33,13 @@
(u/calls! object# ~@options))) (u/calls! object# ~@options)))
(defmacro perspective! (defmacro perspective!
"Calls a single method on a `perspective`" "Calls a single method on a `perspective`."
[screen k & options] [screen k & options]
`(let [^PerspectiveCamera object# (u/get-obj ~screen :camera)] `(let [^PerspectiveCamera object# (u/get-obj ~screen :camera)]
(u/call! object# ~k ~@options))) (u/call! object# ~k ~@options)))
(defn size! (defn size!
"Sets the size of the camera in `screen` "Sets the size of the camera in `screen`.
(size! screen 480 360)" (size! screen 480 360)"
[screen width height] [screen width height]
@@ -52,14 +50,14 @@
(defn width! (defn width!
"Sets the width of the camera in `screen`, adjusting the height so the ratio "Sets the width of the camera in `screen`, adjusting the height so the ratio
remains in tact remains in tact.
(width! screen 480)" (width! screen 480)"
[screen new-width] [screen new-width]
(size! screen new-width (* new-width (/ (game :height) (game :width))))) (size! screen new-width (* new-width (/ (game :height) (game :width)))))
(defn width (defn width
"Returns the width of the camera in `screen` "Returns the width of the camera in `screen`.
(width screen)" (width screen)"
[screen] [screen]
@@ -68,14 +66,14 @@ remains in tact
(defn height! (defn height!
"Sets the height of the camera in `screen`, adjusting the width so the ratio "Sets the height of the camera in `screen`, adjusting the width so the ratio
remains in tact remains in tact.
(height! screen 360)" (height! screen 360)"
[screen new-height] [screen new-height]
(size! screen (* new-height (/ (game :width) (game :height))) new-height)) (size! screen (* new-height (/ (game :width) (game :height))) new-height))
(defn height (defn height
"Returns the height of the camera in `screen` "Returns the height of the camera in `screen`.
(height screen)" (height screen)"
[screen] [screen]
@@ -83,46 +81,46 @@ remains in tact
(. camera viewportHeight))) (. camera viewportHeight)))
(defn x! (defn x!
"Sets only the x position of the camera in `screen`" "Sets only the x position of the camera in `screen`."
[screen x-val] [screen x-val]
(let [^Camera camera (u/get-obj screen :camera)] (let [^Camera camera (u/get-obj screen :camera)]
(set! (. (. camera position) x) x-val) (set! (. (. camera position) x) x-val)
(.update camera))) (.update camera)))
(defn x (defn x
"Returns the x position of the camera in `screen`" "Returns the x position of the camera in `screen`."
[screen] [screen]
(let [^Camera camera (u/get-obj screen :camera)] (let [^Camera camera (u/get-obj screen :camera)]
(. (. camera position) x))) (. (. camera position) x)))
(defn y! (defn y!
"Sets only the y position of the camera in `screen`" "Sets only the y position of the camera in `screen`."
[screen y-val] [screen y-val]
(let [^Camera camera (u/get-obj screen :camera)] (let [^Camera camera (u/get-obj screen :camera)]
(set! (. (. camera position) y) y-val) (set! (. (. camera position) y) y-val)
(.update camera))) (.update camera)))
(defn y (defn y
"Returns the y position of the camera in `screen`" "Returns the y position of the camera in `screen`."
[screen] [screen]
(let [^Camera camera (u/get-obj screen :camera)] (let [^Camera camera (u/get-obj screen :camera)]
(. (. camera position) y))) (. (. camera position) y)))
(defn z! (defn z!
"Sets only the z position of the camera in `screen`" "Sets only the z position of the camera in `screen`."
[screen z-val] [screen z-val]
(let [^Camera camera (u/get-obj screen :camera)] (let [^Camera camera (u/get-obj screen :camera)]
(set! (. (. camera position) z) z-val) (set! (. (. camera position) z) z-val)
(.update camera))) (.update camera)))
(defn z (defn z
"Returns the z position of the camera in `screen`" "Returns the z position of the camera in `screen`."
[screen] [screen]
(let [^Camera camera (u/get-obj screen :camera)] (let [^Camera camera (u/get-obj screen :camera)]
(. (. camera position) z))) (. (. camera position) z)))
(defn position! (defn position!
"Sets the position of the camera in `screen`" "Sets the position of the camera in `screen`."
([screen pos] ([screen pos]
(let [^Camera camera (u/get-obj screen :camera)] (let [^Camera camera (u/get-obj screen :camera)]
(set! (. camera position) pos))) (set! (. camera position) pos)))
@@ -136,46 +134,46 @@ remains in tact
(.update camera)))) (.update camera))))
(defn position (defn position
"Returns the position of the camera in `screen`" "Returns the position of the camera in `screen`."
[screen] [screen]
(let [^Camera camera (u/get-obj screen :camera)] (let [^Camera camera (u/get-obj screen :camera)]
(. camera position))) (. camera position)))
(defn direction! (defn direction!
"Sets the direction of the camera in `screen`" "Sets the direction of the camera in `screen`."
[screen x y z] [screen x y z]
(let [^Camera camera (u/get-obj screen :camera)] (let [^Camera camera (u/get-obj screen :camera)]
(.lookAt camera x y z) (.lookAt camera x y z)
(.update camera))) (.update camera)))
(defn direction (defn direction
"Returns the direction of the camera in `screen`" "Returns the direction of the camera in `screen`."
[screen] [screen]
(let [^Camera camera (u/get-obj screen :camera)] (let [^Camera camera (u/get-obj screen :camera)]
(. camera direction))) (. camera direction)))
(defn near! (defn near!
"Sets the near clipping plane distance of the camera in `screen`" "Sets the near clipping plane distance of the camera in `screen`."
[screen n] [screen n]
(let [^Camera camera (u/get-obj screen :camera)] (let [^Camera camera (u/get-obj screen :camera)]
(set! (. camera near) n) (set! (. camera near) n)
(.update camera))) (.update camera)))
(defn near (defn near
"Returns the near clipping plane distance of the camera in `screen`" "Returns the near clipping plane distance of the camera in `screen`."
[screen] [screen]
(let [^Camera camera (u/get-obj screen :camera)] (let [^Camera camera (u/get-obj screen :camera)]
(. camera near))) (. camera near)))
(defn far! (defn far!
"Sets the far clipping plane distance of the camera in `screen`" "Sets the far clipping plane distance of the camera in `screen`."
[screen n] [screen n]
(let [^Camera camera (u/get-obj screen :camera)] (let [^Camera camera (u/get-obj screen :camera)]
(set! (. camera far) n) (set! (. camera far) n)
(.update camera))) (.update camera)))
(defn far (defn far
"Returns the far clipping plane distance of the camera in `screen`" "Returns the far clipping plane distance of the camera in `screen`."
[screen] [screen]
(let [^Camera camera (u/get-obj screen :camera)] (let [^Camera camera (u/get-obj screen :camera)]
(. camera far))) (. camera far)))

View File

@@ -3,21 +3,19 @@
; tiled maps ; tiled maps
(defn tiled-map* (defn tiled-map*
"The function version of `tiled-map`"
[s] [s]
(if (string? s) (if (string? s)
(.load (TmxMapLoader.) s) (.load (TmxMapLoader.) s)
s)) s))
(defmacro tiled-map (defmacro tiled-map
"Returns a [TiledMap](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/maps/tiled/TiledMap.html) "Returns a [TiledMap](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/maps/tiled/TiledMap.html).
(normally, you don't need to use this directly, because the *-tiled-map Normally, you don't need to use this directly."
macros that create the renderers will call this themselves)"
[s & options] [s & options]
`(u/calls! ^TiledMap (tiled-map* ~s) ~@options)) `(u/calls! ^TiledMap (tiled-map* ~s) ~@options))
(defmacro tiled-map! (defmacro tiled-map!
"Calls a single method on a `tiled-map` "Calls a single method on a `tiled-map`.
(tiled-map! screen :get-layers)" (tiled-map! screen :get-layers)"
[screen k & options] [screen k & options]
@@ -26,7 +24,7 @@ macros that create the renderers will call this themselves)"
(defn tiled-map-layers (defn tiled-map-layers
"Returns a list with [MapLayer](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/maps/MapLayer.html) "Returns a list with [MapLayer](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/maps/MapLayer.html)
objects cooresponding to each layer in the tiled map in `screen` objects cooresponding to each layer in the tiled map in `screen`.
(tiled-map-layers screen)" (tiled-map-layers screen)"
[screen] [screen]
@@ -36,7 +34,6 @@ objects cooresponding to each layer in the tiled map in `screen`
(.get layers i)))) (.get layers i))))
(defn tiled-map-layer* (defn tiled-map-layer*
"The function version of `tiled-map-layer`"
[screen layer] [screen layer]
(if (isa? (type layer) MapLayer) (if (isa? (type layer) MapLayer)
layer layer
@@ -46,7 +43,7 @@ objects cooresponding to each layer in the tiled map in `screen`
(defmacro tiled-map-layer (defmacro tiled-map-layer
"Returns a [TiledMapTileLayer](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/maps/tiled/TiledMapTileLayer.html) "Returns a [TiledMapTileLayer](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/maps/tiled/TiledMapTileLayer.html)
from the tiled map in `screen` that matches `layer` from the tiled map in `screen` that matches `layer`.
(tiled-map-layer screen \"water\")" (tiled-map-layer screen \"water\")"
[screen layer & options] [screen layer & options]
@@ -54,7 +51,7 @@ from the tiled map in `screen` that matches `layer`
(u/calls! object# ~@options))) (u/calls! object# ~@options)))
(defmacro tiled-map-layer! (defmacro tiled-map-layer!
"Calls a single method on a `tiled-map-layer` "Calls a single method on a `tiled-map-layer`.
(tiled-map-layer! (tiled-map-layer screen \"water\") (tiled-map-layer! (tiled-map-layer screen \"water\")
:set-cell 0 0 nil)" :set-cell 0 0 nil)"
@@ -63,19 +60,18 @@ from the tiled map in `screen` that matches `layer`
(defn tiled-map-layer-names (defn tiled-map-layer-names
"Returns a list with strings cooresponding to the name of each layer in the "Returns a list with strings cooresponding to the name of each layer in the
tiled map in `screen`" tiled map in `screen`."
[screen] [screen]
(for [layer (tiled-map-layers screen)] (for [layer (tiled-map-layers screen)]
(tiled-map-layer! layer :get-name))) (tiled-map-layer! layer :get-name)))
(defn tiled-map-cell* (defn tiled-map-cell*
"The function version of `tiled-map-cell`"
[screen layer x y] [screen layer x y]
(.getCell ^TiledMapTileLayer (tiled-map-layer screen layer) x y)) (.getCell ^TiledMapTileLayer (tiled-map-layer screen layer) x y))
(defmacro tiled-map-cell (defmacro tiled-map-cell
"Returns a [TiledMapTileLayer.Cell](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/maps/tiled/TiledMapTileLayer.Cell.html) "Returns a [TiledMapTileLayer.Cell](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/maps/tiled/TiledMapTileLayer.Cell.html)
from the tiled map in `screen` from the given `layer` and position `x` and `y` from the tiled map in `screen` from the given `layer` and position `x` and `y`.
(tiled-map-cell screen \"water\" 0 0)" (tiled-map-cell screen \"water\" 0 0)"
[screen layer x y & options] [screen layer x y & options]
@@ -83,7 +79,7 @@ from the tiled map in `screen` from the given `layer` and position `x` and `y`
(u/calls! object# ~@options))) (u/calls! object# ~@options)))
(defmacro tiled-map-cell! (defmacro tiled-map-cell!
"Calls a single method on a `tiled-map-cell` "Calls a single method on a `tiled-map-cell`.
(tiled-map-cell! (tiled-map-cell screen \"water\" 0 0) (tiled-map-cell! (tiled-map-cell screen \"water\" 0 0)
:set-rotation 90)" :set-rotation 90)"
@@ -91,7 +87,6 @@ from the tiled map in `screen` from the given `layer` and position `x` and `y`
`(u/call! ^TiledMapTileLayer$Cell ~object ~k ~@options)) `(u/call! ^TiledMapTileLayer$Cell ~object ~k ~@options))
(defn ^:private tiled-map-prop (defn ^:private tiled-map-prop
"Internal use only"
[screen] [screen]
(let [^BatchTiledMapRenderer renderer (u/get-obj screen :renderer) (let [^BatchTiledMapRenderer renderer (u/get-obj screen :renderer)
^MapProperties prop (-> renderer .getMap .getProperties)] ^MapProperties prop (-> renderer .getMap .getProperties)]
@@ -103,7 +98,7 @@ from the tiled map in `screen` from the given `layer` and position `x` and `y`
(defn screen->isometric (defn screen->isometric
"Returns a copy of the provided map with x/y values converted from screen "Returns a copy of the provided map with x/y values converted from screen
to isometric map coordinates to isometric map coordinates.
(screen->isometric screen {:x 64 :y 32})" (screen->isometric screen {:x 64 :y 32})"
[screen {:keys [x y] :as entity}] [screen {:keys [x y] :as entity}]
@@ -120,7 +115,7 @@ to isometric map coordinates
(defn isometric->screen (defn isometric->screen
"Returns a copy of the provided map with x/y values converted from isometric "Returns a copy of the provided map with x/y values converted from isometric
map to screen coordinates map to screen coordinates.
(isometric->screen screen {:x 2 :y 1})" (isometric->screen screen {:x 2 :y 1})"
[screen {:keys [x y] :as entity}] [screen {:keys [x y] :as entity}]
@@ -136,13 +131,12 @@ map to screen coordinates
; renderers ; renderers
(defn orthogonal-tiled-map* (defn orthogonal-tiled-map*
"The function version of `orthogonal-tiled-map`"
[path unit] [path unit]
(OrthogonalTiledMapRenderer. ^TiledMap (tiled-map* path) ^double unit)) (OrthogonalTiledMapRenderer. ^TiledMap (tiled-map* path) ^double unit))
(defmacro orthogonal-tiled-map (defmacro orthogonal-tiled-map
"Returns an [OrthogonalTiledMapRenderer](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/maps/tiled/renderers/OrthogonalTiledMapRenderer.html) "Returns an [OrthogonalTiledMapRenderer](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/maps/tiled/renderers/OrthogonalTiledMapRenderer.html)
with the tiled map file at `path` and `unit` scale with the tiled map file at `path` and `unit` scale.
(orthogonal-tiled-map \"level1.tmx\" (/ 1 8))" (orthogonal-tiled-map \"level1.tmx\" (/ 1 8))"
[path unit & options] [path unit & options]
@@ -150,19 +144,18 @@ with the tiled map file at `path` and `unit` scale
~@options)) ~@options))
(defmacro orthogonal-tiled-map! (defmacro orthogonal-tiled-map!
"Calls a single method on an `orthogonal-tiled-map`" "Calls a single method on an `orthogonal-tiled-map`."
[screen k & options] [screen k & options]
`(let [^OrthogonalTiledMapRenderer object# (u/get-obj ~screen :renderer)] `(let [^OrthogonalTiledMapRenderer object# (u/get-obj ~screen :renderer)]
(u/call! object# ~k ~@options))) (u/call! object# ~k ~@options)))
(defn isometric-tiled-map* (defn isometric-tiled-map*
"The function version of `isometric-tiled-map`"
[path unit] [path unit]
(IsometricTiledMapRenderer. ^TiledMap (tiled-map* path) ^double unit)) (IsometricTiledMapRenderer. ^TiledMap (tiled-map* path) ^double unit))
(defmacro isometric-tiled-map (defmacro isometric-tiled-map
"Returns an [IsometricTiledMapRenderer](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/maps/tiled/renderers/IsometricTiledMapRenderer.html) "Returns an [IsometricTiledMapRenderer](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/maps/tiled/renderers/IsometricTiledMapRenderer.html)
with the tiled map file at `path` and `unit` scale with the tiled map file at `path` and `unit` scale.
(isometric-tiled-map \"level1.tmx\" (/ 1 8))" (isometric-tiled-map \"level1.tmx\" (/ 1 8))"
[path unit & options] [path unit & options]
@@ -170,20 +163,19 @@ with the tiled map file at `path` and `unit` scale
~@options)) ~@options))
(defmacro isometric-tiled-map! (defmacro isometric-tiled-map!
"Calls a single method on an `isometric-tiled-map`" "Calls a single method on an `isometric-tiled-map`."
[screen k & options] [screen k & options]
`(let [^IsometricTiledMapRenderer object# (u/get-obj ~screen :renderer)] `(let [^IsometricTiledMapRenderer object# (u/get-obj ~screen :renderer)]
(u/call! object# ~k ~@options))) (u/call! object# ~k ~@options)))
(defn isometric-staggered-tiled-map* (defn isometric-staggered-tiled-map*
"The function version of `isometric-staggered-tiled-map`"
[path unit] [path unit]
(IsometricStaggeredTiledMapRenderer. ^TiledMap (tiled-map* path) (IsometricStaggeredTiledMapRenderer. ^TiledMap (tiled-map* path)
^double unit)) ^double unit))
(defmacro isometric-staggered-tiled-map (defmacro isometric-staggered-tiled-map
"Returns an [IsometricStaggeredTiledMapRenderer](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/maps/tiled/renderers/IsometricStaggeredTiledMapRenderer.html) "Returns an [IsometricStaggeredTiledMapRenderer](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/maps/tiled/renderers/IsometricStaggeredTiledMapRenderer.html)
with the tiled map file at `path` and `unit` scale with the tiled map file at `path` and `unit` scale.
(isometric-staggered-tiled-map \"level1.tmx\" (/ 1 8))" (isometric-staggered-tiled-map \"level1.tmx\" (/ 1 8))"
[path unit & options] [path unit & options]
@@ -192,20 +184,19 @@ with the tiled map file at `path` and `unit` scale
~@options)) ~@options))
(defmacro isometric-staggered-tiled-map! (defmacro isometric-staggered-tiled-map!
"Calls a single method on an `isometric-staggered-tiled-map`" "Calls a single method on an `isometric-staggered-tiled-map`."
[screen k & options] [screen k & options]
`(let [^IsometricStaggeredTiledMapRenderer object# `(let [^IsometricStaggeredTiledMapRenderer object#
(u/get-obj ~screen :renderer)] (u/get-obj ~screen :renderer)]
(u/call! object# ~k ~@options))) (u/call! object# ~k ~@options)))
(defn hexagonal-tiled-map* (defn hexagonal-tiled-map*
"The function version of `hexagonal-tiled-map`"
[path unit] [path unit]
(HexagonalTiledMapRenderer. ^TiledMap (tiled-map* path) ^double unit)) (HexagonalTiledMapRenderer. ^TiledMap (tiled-map* path) ^double unit))
(defmacro hexagonal-tiled-map (defmacro hexagonal-tiled-map
"Returns a [HexagonalTiledMapRenderer](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/maps/tiled/renderers/HexagonalTiledMapRenderer.html) "Returns a [HexagonalTiledMapRenderer](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/maps/tiled/renderers/HexagonalTiledMapRenderer.html)
with the tiled map file at `path` and `unit` scale with the tiled map file at `path` and `unit` scale.
(hexagonal-tiled-map \"level1.tmx\" (/ 1 8))" (hexagonal-tiled-map \"level1.tmx\" (/ 1 8))"
[path unit & options] [path unit & options]
@@ -213,25 +204,24 @@ with the tiled map file at `path` and `unit` scale
~@options)) ~@options))
(defmacro hexagonal-tiled-map! (defmacro hexagonal-tiled-map!
"Calls a single method on a `hexagonal-tiled-map`" "Calls a single method on a `hexagonal-tiled-map`."
[screen k & options] [screen k & options]
`(let [^HexagonalTiledMapRenderer object# (u/get-obj ~screen :renderer)] `(let [^HexagonalTiledMapRenderer object# (u/get-obj ~screen :renderer)]
(u/call! object# ~k ~@options))) (u/call! object# ~k ~@options)))
(defn stage* (defn stage*
"The function version of `stage`"
[] []
(Stage.)) (Stage.))
(defmacro stage (defmacro stage
"Returns a [Stage](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/Stage.html) "Returns a [Stage](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/Stage.html).
(stage)" (stage)"
[& options] [& options]
`(u/calls! ^Stage (stage*) ~@options)) `(u/calls! ^Stage (stage*) ~@options))
(defmacro stage! (defmacro stage!
"Calls a single method on a `stage`" "Calls a single method on a `stage`."
[screen k & options] [screen k & options]
`(let [^Stage object# (u/get-obj ~screen :renderer)] `(let [^Stage object# (u/get-obj ~screen :renderer)]
(u/call! object# ~k ~@options))) (u/call! object# ~k ~@options)))
@@ -239,7 +229,6 @@ with the tiled map file at `path` and `unit` scale
; draw ; draw
(defmulti draw! (defmulti draw!
"Internal use only"
(fn [screen _] (-> screen :renderer class))) (fn [screen _] (-> screen :renderer class)))
(defmethod draw! BatchTiledMapRenderer (defmethod draw! BatchTiledMapRenderer
@@ -272,7 +261,7 @@ with the tiled map file at `path` and `unit` scale
(defn render-map! (defn render-map!
"Calls the tiled-map renderer from `screen`, optionally allowing you to "Calls the tiled-map renderer from `screen`, optionally allowing you to
specify which layers to render with or without specify which layers to render with or without.
(render-map! screen :with \"water\" \"grass\") (render-map! screen :with \"water\" \"grass\")
(render-map! screen :without \"desert\" \"rocks\")" (render-map! screen :without \"desert\" \"rocks\")"
@@ -298,7 +287,7 @@ specify which layers to render with or without
nil) nil)
(defn render-stage! (defn render-stage!
"Calls the stage renderer from `screen`" "Calls the stage renderer from `screen`."
[{:keys [^Stage renderer ^Camera camera]}] [{:keys [^Stage renderer ^Camera camera]}]
(when camera (when camera
(.setCamera renderer camera) (.setCamera renderer camera)
@@ -308,7 +297,7 @@ specify which layers to render with or without
(defn render! (defn render!
"Calls the renderer from `screen` and optionally draws and returns the "Calls the renderer from `screen` and optionally draws and returns the
`entities` `entities`.
(render! screen entities)" (render! screen entities)"
([{:keys [renderer] :as screen}] ([{:keys [renderer] :as screen}]
@@ -322,7 +311,6 @@ specify which layers to render with or without
(draw! screen entities))) (draw! screen entities)))
(defn ^:private create-layer (defn ^:private create-layer
"Internal use only"
[^TiledMapTileLayer layer] [^TiledMapTileLayer layer]
(TiledMapTileLayer. (.getWidth layer) (TiledMapTileLayer. (.getWidth layer)
(.getHeight layer) (.getHeight layer)
@@ -330,13 +318,11 @@ specify which layers to render with or without
(int (.getTileHeight layer)))) (int (.getTileHeight layer))))
(defn ^:private isometric? (defn ^:private isometric?
"Internal use only"
[{:keys [renderer] :as screen}] [{:keys [renderer] :as screen}]
(or (isa? (type renderer) IsometricTiledMapRenderer) (or (isa? (type renderer) IsometricTiledMapRenderer)
(isa? (type renderer) IsometricStaggeredTiledMapRenderer))) (isa? (type renderer) IsometricStaggeredTiledMapRenderer)))
(defn ^:private split-layer (defn ^:private split-layer
"Internal use only"
[screen layer-name] [screen layer-name]
(let [^TiledMapTileLayer l (tiled-map-layer screen layer-name)] (let [^TiledMapTileLayer l (tiled-map-layer screen layer-name)]
(reduce (fn [layers {:keys [x y] :as map-tile}] (reduce (fn [layers {:keys [x y] :as map-tile}]
@@ -358,7 +344,7 @@ specify which layers to render with or without
{:x x :y y})))) {:x x :y y}))))
(defn render-sorted! (defn render-sorted!
"Draws the supplied tiled-map layers and entities, sorted by latitude "Draws the supplied tiled-map layers and entities, sorted by latitude.
(render-sorted! screen [\"walls\"] entities)" (render-sorted! screen [\"walls\"] entities)"
[{:keys [^BatchTiledMapRenderer renderer [{:keys [^BatchTiledMapRenderer renderer

View File

@@ -3,7 +3,6 @@
; global ; global
(defn ^:private input-processor (defn ^:private input-processor
"Internal use only"
[{:keys [on-key-down on-key-typed on-key-up on-mouse-moved [{:keys [on-key-down on-key-typed on-key-up on-mouse-moved
on-scrolled on-touch-down on-touch-dragged on-touch-up]} on-scrolled on-touch-down on-touch-dragged on-touch-up]}
execute-fn!] execute-fn!]
@@ -34,7 +33,6 @@
false))) false)))
(defn ^:private gesture-listener (defn ^:private gesture-listener
"Internal use only"
[{:keys [on-fling on-long-press on-pan on-pan-stop on-pinch on-tap on-zoom]} [{:keys [on-fling on-long-press on-pan on-pan-stop on-pinch on-tap on-zoom]}
execute-fn!] execute-fn!]
(reify GestureDetector$GestureListener (reify GestureDetector$GestureListener
@@ -65,12 +63,10 @@
false))) false)))
(defn ^:private gesture-detector (defn ^:private gesture-detector
"Internal use only"
[options execute-fn!] [options execute-fn!]
(proxy [GestureDetector] [(gesture-listener options execute-fn!)])) (proxy [GestureDetector] [(gesture-listener options execute-fn!)]))
(defn ^:private global-listeners (defn ^:private global-listeners
"Internal use only"
[options execute-fn!] [options execute-fn!]
[(input-processor options execute-fn!) [(input-processor options execute-fn!)
(gesture-detector options execute-fn!)]) (gesture-detector options execute-fn!)])
@@ -78,7 +74,6 @@
; ui ; ui
(defn ^:private actor-gesture-listener (defn ^:private actor-gesture-listener
"Internal use only"
[{:keys [on-ui-fling on-ui-long-press on-ui-pan on-ui-pinch [{:keys [on-ui-fling on-ui-long-press on-ui-pan on-ui-pinch
on-ui-tap on-ui-touch-down on-ui-touch-up on-ui-zoom]} on-ui-tap on-ui-touch-down on-ui-touch-up on-ui-zoom]}
execute-fn!] execute-fn!]
@@ -105,14 +100,12 @@
(execute-fn! on-ui-zoom :event e :initial-distance id :distance d)))) (execute-fn! on-ui-zoom :event e :initial-distance id :distance d))))
(defn ^:private change-listener (defn ^:private change-listener
"Internal use only"
[{:keys [on-ui-changed]} execute-fn!] [{:keys [on-ui-changed]} execute-fn!]
(proxy [ChangeListener] [] (proxy [ChangeListener] []
(changed [e a] (changed [e a]
(execute-fn! on-ui-changed :event e :actor a)))) (execute-fn! on-ui-changed :event e :actor a))))
(defn ^:private click-listener (defn ^:private click-listener
"Internal use only"
[{:keys [on-ui-clicked on-ui-enter on-ui-exit [{:keys [on-ui-clicked on-ui-enter on-ui-exit
on-ui-touch-down on-ui-touch-dragged on-ui-touch-up]} on-ui-touch-down on-ui-touch-dragged on-ui-touch-up]}
execute-fn!] execute-fn!]
@@ -132,7 +125,6 @@
(execute-fn! on-ui-touch-up :event e :x x :y y :pointer p :button b)))) (execute-fn! on-ui-touch-up :event e :x x :y y :pointer p :button b))))
(defn ^:private drag-listener (defn ^:private drag-listener
"Internal use only"
[{:keys [on-ui-drag on-ui-drag-start on-ui-drag-stop [{:keys [on-ui-drag on-ui-drag-start on-ui-drag-stop
on-ui-touch-down on-ui-touch-dragged on-ui-touch-up]} on-ui-touch-down on-ui-touch-dragged on-ui-touch-up]}
execute-fn!] execute-fn!]
@@ -152,7 +144,6 @@
(execute-fn! on-ui-drag-stop :event e :x x :y y :pointer p)))) (execute-fn! on-ui-drag-stop :event e :x x :y y :pointer p))))
(defn ^:private focus-listener (defn ^:private focus-listener
"Internal use only"
[{:keys [on-ui-keyboard-focus-changed on-ui-scroll-focus-changed]} [{:keys [on-ui-keyboard-focus-changed on-ui-scroll-focus-changed]}
execute-fn!] execute-fn!]
(proxy [FocusListener] [] (proxy [FocusListener] []
@@ -162,7 +153,6 @@
(execute-fn! on-ui-scroll-focus-changed :event e :actor a :focused? f)))) (execute-fn! on-ui-scroll-focus-changed :event e :actor a :focused? f))))
(defn ^:private ui-listeners (defn ^:private ui-listeners
"Internal use only"
[options execute-fn!] [options execute-fn!]
[(actor-gesture-listener options execute-fn!) [(actor-gesture-listener options execute-fn!)
(change-listener options execute-fn!) (change-listener options execute-fn!)
@@ -173,7 +163,6 @@
; g2d-physics ; g2d-physics
(defn ^:private contact-listener (defn ^:private contact-listener
"Internal use only"
[{:keys [on-begin-contact on-end-contact on-post-solve on-pre-solve]} execute-fn!] [{:keys [on-begin-contact on-end-contact on-post-solve on-pre-solve]} execute-fn!]
(reify ContactListener (reify ContactListener
(beginContact [this c] (beginContact [this c]
@@ -188,7 +177,6 @@
; update functions ; update functions
(defn ^:private update-stage! (defn ^:private update-stage!
"Internal use only"
[{:keys [^Stage renderer ui-listeners]} entities] [{:keys [^Stage renderer ui-listeners]} entities]
(doseq [^Actor a (.getActors renderer)] (doseq [^Actor a (.getActors renderer)]
(.remove a)) (.remove a))
@@ -201,7 +189,6 @@
(add-input! renderer)) (add-input! renderer))
(defn ^:private update-box-2d! (defn ^:private update-box-2d!
"Internal use only"
[{:keys [^World world]} entities] [{:keys [^World world]} entities]
(when-not (.isLocked world) (when-not (.isLocked world)
(let [arr (u/gdx-array [])] (let [arr (u/gdx-array [])]
@@ -218,7 +205,6 @@
(.destroyJoint world joint)))))) (.destroyJoint world joint))))))
(defn ^:private update-screen! (defn ^:private update-screen!
"Internal use only"
([{:keys [world g2dp-listener]}] ([{:keys [world g2dp-listener]}]
(when (isa? (type world) World) (when (isa? (type world) World)
(.setContactListener ^World world g2dp-listener))) (.setContactListener ^World world g2dp-listener)))

View File

@@ -3,42 +3,32 @@
; static fields ; static fields
(defmacro scaling (defmacro scaling
"Returns a static field from [Scaling](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/utils/Scaling.html) "Returns a static field from [Scaling](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/utils/Scaling.html).
(scaling :fill) (scaling :fill)"
(scaling :fill-x)
(scaling :fill-y)
(scaling :fit)
(scaling :none)
(scaling :stretch)
(scaling :stretch-x)
(scaling :stretch-y)"
[k] [k]
`~(u/gdx-field :utils :Scaling k)) `~(u/gdx-field :utils :Scaling k))
(defmacro usage (defmacro usage
"Returns a static field in [VertexAttributes.Usage](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/VertexAttributes.Usage.html)" "Returns a static field in [VertexAttributes.Usage](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/VertexAttributes.Usage.html)."
[k] [k]
`~(u/gdx-field :graphics "VertexAttributes$Usage" (u/key->pascal k))) `~(u/gdx-field :graphics "VertexAttributes$Usage" (u/key->pascal k)))
; timers ; timers
(defn ^:private task* (defn ^:private task*
"Internal use only."
[{:keys [execute-fn! on-timer]} id] [{:keys [execute-fn! on-timer]} id]
(proxy [Timer$Task] [] (proxy [Timer$Task] []
(run [] (run []
(execute-fn! on-timer :id id)))) (execute-fn! on-timer :id id))))
(defn ^:private timer* (defn ^:private timer*
"Internal use only."
[] []
(some-> (Class/forName "com.badlogic.gdx.utils.Timer") (some-> (Class/forName "com.badlogic.gdx.utils.Timer")
(try (catch Exception _)) (try (catch Exception _))
.newInstance)) .newInstance))
(defn ^:private create-and-add-timer! (defn ^:private create-and-add-timer!
"Internal use only."
[{:keys [update-fn!] :as screen} id] [{:keys [update-fn!] :as screen} id]
(when-let [timer (timer*)] (when-let [timer (timer*)]
(update-fn! assoc-in [[:timers id] timer]) (update-fn! assoc-in [[:timers id] timer])
@@ -46,7 +36,7 @@
(defn add-timer! (defn add-timer!
"Returns a [Timer](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/utils/Timer.html) "Returns a [Timer](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/utils/Timer.html)
that runs the :on-timer function according to the given arguments that runs the :on-timer function according to the given arguments.
; wait 2 seconds and run once ; wait 2 seconds and run once
(add-timer! screen :spawn-enemy 2) (add-timer! screen :spawn-enemy 2)
@@ -66,7 +56,7 @@ that runs the :on-timer function according to the given arguments
(defn remove-timer! (defn remove-timer!
"Stops and removes the timer associated with `id`, returning it or nil if not "Stops and removes the timer associated with `id`, returning it or nil if not
found" found."
[{:keys [update-fn!] :as screen} id] [{:keys [update-fn!] :as screen} id]
(when-let [timer (get-in screen [:timers id])] (when-let [timer (get-in screen [:timers id])]
(.stop timer) (.stop timer)
@@ -76,7 +66,6 @@ found"
; assets ; assets
(defn ^:private loader-init (defn ^:private loader-init
"Internal use only"
[k] [k]
(cond (cond
(contains? #{:atlas-tmx-map :tmx-map} k) (contains? #{:atlas-tmx-map :tmx-map} k)
@@ -87,7 +76,7 @@ found"
(u/gdx :assets :loaders (str (u/key->pascal k) "Loader.")))) (u/gdx :assets :loaders (str (u/key->pascal k) "Loader."))))
(defmacro loader (defmacro loader
"Returns a subclass of [AsynchronousAssetLoader](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/assets/loaders/AsynchronousAssetLoader.html) "Returns a subclass of [AsynchronousAssetLoader](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/assets/loaders/AsynchronousAssetLoader.html).
(loader :atlas-tmx-map \"map.atlas\") (loader :atlas-tmx-map \"map.atlas\")
(loader :tmx-map \"map.tmx\") (loader :tmx-map \"map.tmx\")
@@ -104,21 +93,20 @@ found"
(u/calls! object# ~@options))) (u/calls! object# ~@options)))
(defmacro loader! (defmacro loader!
"Calls a single method in a subclass of [AsynchronousAssetLoader](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/assets/loaders/AsynchronousAssetLoader.html) "Calls a single method in a subclass of [AsynchronousAssetLoader](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/assets/loaders/AsynchronousAssetLoader.html).
(loader! object :load \"map.tmx\")" (loader! object :load \"map.tmx\")"
[object & options] [object & options]
`(u/call! ~object ~@options)) `(u/call! ~object ~@options))
(defn asset-manager* (defn asset-manager*
"The function version of `asset-manager`"
([] ([]
(AssetManager.)) (AssetManager.))
([resolver] ([resolver]
(AssetManager. resolver))) (AssetManager. resolver)))
(defmacro asset-manager (defmacro asset-manager
"Returns an [AssetManager](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/assets/AssetManager.html) "Returns an [AssetManager](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/assets/AssetManager.html).
(asset-manager)" (asset-manager)"
[& options] [& options]
@@ -126,7 +114,7 @@ found"
(u/calls! object# ~@options))) (u/calls! object# ~@options)))
(defmacro asset-manager! (defmacro asset-manager!
"Calls a single method in an `asset-manager` "Calls a single method in an `asset-manager`.
(asset-manager! object :clear)" (asset-manager! object :clear)"
[object k & options] [object k & options]

View File

@@ -6,7 +6,6 @@
[com.badlogic.gdx.scenes.scene2d Actor])) [com.badlogic.gdx.scenes.scene2d Actor]))
(defprotocol Entity (defprotocol Entity
"Internal use only"
(draw-entity! [this batch] "Draws the entity")) (draw-entity! [this batch] "Draws the entity"))
(extend-protocol Entity (extend-protocol Entity

View File

@@ -7,7 +7,7 @@
ParticleEffectEntity])) ParticleEffectEntity]))
(defmacro bitmap-font (defmacro bitmap-font
"Returns a [BitmapFont](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/g2d/BitmapFont.html) "Returns a [BitmapFont](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/g2d/BitmapFont.html).
(bitmap-font) (bitmap-font)
(bitmap-font (files! :internal \"default.fnt\"))" (bitmap-font (files! :internal \"default.fnt\"))"
@@ -17,7 +17,6 @@
; texture ; texture
(defn texture* (defn texture*
"The function version of `texture`"
[arg] [arg]
(TextureEntity. (TextureEntity.
(cond (cond
@@ -29,7 +28,7 @@
arg))) arg)))
(defmacro texture (defmacro texture
"Returns an entity based on [TextureRegion](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/g2d/TextureRegion.html) "Returns an entity based on [TextureRegion](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/g2d/TextureRegion.html).
(texture \"image.png\") (texture \"image.png\")
(texture \"image.png\" :flip true false) (texture \"image.png\" :flip true false)
@@ -42,7 +41,7 @@
entity#)) entity#))
(defmacro texture! (defmacro texture!
"Calls a single method on a `texture` "Calls a single method on a `texture`.
(texture! entity :flip true false) (texture! entity :flip true false)
(texture! entity :get-region-width)" (texture! entity :get-region-width)"
@@ -52,7 +51,6 @@
; nine-patch ; nine-patch
(defn nine-patch* (defn nine-patch*
"The function version of `nine-patch`"
[arg] [arg]
(NinePatchEntity. (NinePatchEntity.
(cond (cond
@@ -68,7 +66,7 @@
arg))) arg)))
(defmacro nine-patch (defmacro nine-patch
"Returns an entity based on [NinePatch](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/g2d/NinePatch.html) "Returns an entity based on [NinePatch](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/g2d/NinePatch.html).
(nine-patch \"image.png\") (nine-patch \"image.png\")
(nine-patch \"image.png\" :set-color (color :blue)) (nine-patch \"image.png\" :set-color (color :blue))
@@ -79,7 +77,7 @@
entity#)) entity#))
(defmacro nine-patch! (defmacro nine-patch!
"Calls a single method on a `nine-patch` "Calls a single method on a `nine-patch`.
(nine-patch! entity :set-color (color :blue)) (nine-patch! entity :set-color (color :blue))
(nine-patch! entity :get-middle-width)" (nine-patch! entity :get-middle-width)"
@@ -89,12 +87,11 @@
; particle-effect ; particle-effect
(defn particle-effect* (defn particle-effect*
"The function version of `particle-effect`"
[] []
(ParticleEffectEntity. (ParticleEffect.))) (ParticleEffectEntity. (ParticleEffect.)))
(defmacro particle-effect (defmacro particle-effect
"Returns an entity based on [ParticleEffect](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/g2d/ParticleEffect.html) "Returns an entity based on [ParticleEffect](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/g2d/ParticleEffect.html).
(particle-effect :load (particle-effect :load
(files! :internal \"fire.p\") (files! :internal \"fire.p\")
@@ -105,7 +102,7 @@
entity#)) entity#))
(defmacro particle-effect! (defmacro particle-effect!
"Calls a single method on a `particle-effect` "Calls a single method on a `particle-effect`.
(particle-effect! entity :set-position 10 10)" (particle-effect! entity :set-position 10 10)"
[entity k & options] [entity k & options]
@@ -114,12 +111,11 @@
; texture-atlas ; texture-atlas
(defn texture-atlas* (defn texture-atlas*
"The function version of `texture-atlas`"
[^String path] [^String path]
(TextureAtlas. path)) (TextureAtlas. path))
(defmacro texture-atlas (defmacro texture-atlas
"Returns a [TextureAtlas](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/g2d/TextureAtlas.html) "Returns a [TextureAtlas](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/g2d/TextureAtlas.html).
(texture-atlas \"packed.txt\")" (texture-atlas \"packed.txt\")"
[path & options] [path & options]
@@ -128,7 +124,7 @@
object#)) object#))
(defmacro texture-atlas! (defmacro texture-atlas!
"Calls a single method on a `texture-atlas` "Calls a single method on a `texture-atlas`.
(texture-atlas! object :create-patch \"test\")" (texture-atlas! object :create-patch \"test\")"
[object k & options] [object k & options]
@@ -137,26 +133,20 @@
; animation ; animation
(defmacro play-mode (defmacro play-mode
"Returns a static field from [Animation](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/g2d/Animation.html) "Returns a static field from [Animation](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/g2d/Animation.html).
(play-mode :loop) (play-mode :loop)"
(play-mode :loop-pingpong)
(play-mode :loop-random)
(play-mode :loop-reversed)
(play-mode :normal)
(play-mode :reversed)"
[k] [k]
`~(u/gdx-field :graphics :g2d :Animation (u/key->upper k))) `~(u/gdx-field :graphics :g2d :Animation (u/key->upper k)))
(defn animation* (defn animation*
"The function version of `animation`"
[duration textures] [duration textures]
(Animation. duration (Animation. duration
(u/gdx-array (map #(u/get-obj % :object) textures)) (u/gdx-array (map #(u/get-obj % :object) textures))
(play-mode :normal))) (play-mode :normal)))
(defmacro animation (defmacro animation
"Returns an [Animation](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/g2d/Animation.html) "Returns an [Animation](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/g2d/Animation.html).
(animation 0.2 (animation 0.2
[walk-1 walk-2 walk-3] [walk-1 walk-2 walk-3]
@@ -165,7 +155,7 @@
`(u/calls! ^Animation (animation* ~duration ~textures) ~@options)) `(u/calls! ^Animation (animation* ~duration ~textures) ~@options))
(defmacro animation! (defmacro animation!
"Calls a single method on an `animation` "Calls a single method on an `animation`.
(animation! object :set-play-mode (play-mode :loop))" (animation! object :set-play-mode (play-mode :loop))"
[object k & options] [object k & options]
@@ -173,7 +163,7 @@
(defn animation->texture (defn animation->texture
"Returns a `texture` entity with a frame from `animation` based on the total "Returns a `texture` entity with a frame from `animation` based on the total
time the `screen` has been showing time the `screen` has been showing.
(animation->texture screen anim)" (animation->texture screen anim)"
([{:keys [total-time]} ^Animation animation] ([{:keys [total-time]} ^Animation animation]

View File

@@ -8,7 +8,6 @@
; world ; world
(defn box-2d* (defn box-2d*
"The function version of `box-2d`"
([] ([]
(box-2d* 0 0 true)) (box-2d* 0 0 true))
([gravity-x gravity-y] ([gravity-x gravity-y]
@@ -17,7 +16,7 @@
(World. (m/vector-2 gravity-x gravity-y) sleep?))) (World. (m/vector-2 gravity-x gravity-y) sleep?)))
(defmacro box-2d (defmacro box-2d
"Returns a [World](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/physics/box2d/World.html) "Returns a [World](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/physics/box2d/World.html).
(box-2d 0 0)" (box-2d 0 0)"
[gravity-x gravity-y & options] [gravity-x gravity-y & options]
@@ -25,7 +24,7 @@
(u/calls! object# ~@options))) (u/calls! object# ~@options)))
(defmacro box-2d! (defmacro box-2d!
"Calls a single method on a `box-2d`" "Calls a single method on a `box-2d`."
[screen k & options] [screen k & options]
`(let [^World object# (u/get-obj ~screen :world)] `(let [^World object# (u/get-obj ~screen :world)]
(u/call! object# ~k ~@options))) (u/call! object# ~k ~@options)))
@@ -33,13 +32,12 @@
; bodies ; bodies
(defn ^:private body-type (defn ^:private body-type
"Internal use only"
[k] [k]
(u/gdx-class :physics :box2d :BodyDef (u/gdx-class :physics :box2d :BodyDef
(str "BodyType/" (u/key->pascal k) "Body"))) (str "BodyType/" (u/key->pascal k) "Body")))
(defmacro body-def (defmacro body-def
"Returns a [BodyDef](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/physics/box2d/BodyDef.html) "Returns a [BodyDef](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/physics/box2d/BodyDef.html).
(body-def :dynamic)" (body-def :dynamic)"
[k & options] [k & options]
@@ -48,67 +46,65 @@
(u/fields! object# ~@options))) (u/fields! object# ~@options)))
(defmacro body! (defmacro body!
"Calls a single method on a body" "Calls a single method on a body."
[entity k & options] [entity k & options]
`(let [^Body object# (u/get-obj ~entity :body)] `(let [^Body object# (u/get-obj ~entity :body)]
(u/call! object# ~k ~@options))) (u/call! object# ~k ~@options)))
(defn create-body!* (defn create-body!*
"The function version of `create-body!`"
[screen b-def] [screen b-def]
(box-2d! screen :create-body b-def)) (box-2d! screen :create-body b-def))
(defmacro create-body! (defmacro create-body!
"Returns a [Body](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/physics/box2d/Body.html)" "Returns a [Body](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/physics/box2d/Body.html)."
[screen b-def & options] [screen b-def & options]
`(let [^Body object# (create-body!* ~screen ~b-def)] `(let [^Body object# (create-body!* ~screen ~b-def)]
(u/calls! object# ~@options))) (u/calls! object# ~@options)))
(defn body-x (defn body-x
"Returns the x position of the body in `entity`" "Returns the x position of the body in `entity`."
[entity] [entity]
(. (body! entity :get-position) x)) (. (body! entity :get-position) x))
(defn body-y (defn body-y
"Returns the y position of the body in `entity`" "Returns the y position of the body in `entity`."
[entity] [entity]
(. (body! entity :get-position) y)) (. (body! entity :get-position) y))
(defn body-angle (defn body-angle
"Returns the angle of the body in `entity`" "Returns the angle of the body in `entity`."
[entity] [entity]
(.getRotation ^Transform (body! entity :get-transform))) (.getRotation ^Transform (body! entity :get-transform)))
(defn body-transform! (defn body-transform!
"Changes the `x`, `y`, and `angle` of the body in `entity`" "Changes the `x`, `y`, and `angle` of the body in `entity`."
[entity x y angle] [entity x y angle]
(body! entity :set-transform x y angle) (body! entity :set-transform x y angle)
entity) entity)
(defn body-x! (defn body-x!
"Changes the `x` of the body in `entity`" "Changes the `x` of the body in `entity`."
[entity x] [entity x]
(body-transform! entity x (body-y entity) (body-angle entity))) (body-transform! entity x (body-y entity) (body-angle entity)))
(defn body-y! (defn body-y!
"Changes the `y` of the body in `entity`" "Changes the `y` of the body in `entity`."
[entity y] [entity y]
(body-transform! entity (body-x entity) y (body-angle entity))) (body-transform! entity (body-x entity) y (body-angle entity)))
(defn body-angle! (defn body-angle!
"Changes the `angle` of the body in `entity`" "Changes the `angle` of the body in `entity`."
[entity angle] [entity angle]
(body-transform! entity (body-x entity) (body-y entity) angle)) (body-transform! entity (body-x entity) (body-y entity) angle))
; joints ; joints
(defn ^:private joint-init (defn ^:private joint-init
"Internal use only"
[k] [k]
(u/gdx :physics :box2d :joints (str (u/key->pascal k) "JointDef."))) (u/gdx :physics :box2d :joints (str (u/key->pascal k) "JointDef.")))
(defmacro joint-def (defmacro joint-def
"Returns a subclass of [JointDef](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/physics/box2d/JointDef.html) "Returns a subclass of [JointDef](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/physics/box2d/JointDef.html).
(joint-def :rope)" (joint-def :rope)"
[k & options] [k & options]
@@ -116,17 +112,16 @@
(u/fields! object# ~@options))) (u/fields! object# ~@options)))
(defmacro joint! (defmacro joint!
"Calls a single method on a joint" "Calls a single method on a joint."
[object k & options] [object k & options]
`(u/call! ^Joint ~object ~k ~@options)) `(u/call! ^Joint ~object ~k ~@options))
(defn create-joint!* (defn create-joint!*
"The function version of `create-joint!`"
[screen j-def] [screen j-def]
(box-2d! screen :create-joint j-def)) (box-2d! screen :create-joint j-def))
(defmacro create-joint! (defmacro create-joint!
"Returns a [Joint](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/physics/box2d/Joint.html)" "Returns a [Joint](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/physics/box2d/Joint.html)."
[screen j-def & options] [screen j-def & options]
`(let [object# (create-joint!* ~screen ~j-def)] `(let [object# (create-joint!* ~screen ~j-def)]
(u/calls! object# ~@options))) (u/calls! object# ~@options)))
@@ -134,36 +129,34 @@
; fixtures ; fixtures
(defmacro fixture-def (defmacro fixture-def
"Returns a [FixtureDef](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/physics/box2d/FixtureDef.html)" "Returns a [FixtureDef](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/physics/box2d/FixtureDef.html)."
[& options] [& options]
`(let [^FixtureDef object# (FixtureDef.)] `(let [^FixtureDef object# (FixtureDef.)]
(u/fields! object# ~@options) (u/fields! object# ~@options)
object#)) object#))
(defmacro fixture! (defmacro fixture!
"Calls a single method on a fixture" "Calls a single method on a fixture."
[object k & options] [object k & options]
`(u/call! ^Fixture ~object ~k ~@options)) `(u/call! ^Fixture ~object ~k ~@options))
; shapes ; shapes
(defn chain-shape* (defn chain-shape*
"The function version of `chain-shape`"
[] []
(ChainShape.)) (ChainShape.))
(defmacro chain-shape (defmacro chain-shape
"Returns a [ChainShape](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/physics/box2d/ChainShape.html)" "Returns a [ChainShape](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/physics/box2d/ChainShape.html)."
[& options] [& options]
`(u/calls! ^ChainShape (chain-shape*) ~@options)) `(u/calls! ^ChainShape (chain-shape*) ~@options))
(defmacro chain-shape! (defmacro chain-shape!
"Calls a single method on a `chain-shape`" "Calls a single method on a `chain-shape`."
[object k & options] [object k & options]
`(u/call! ^ChainShape ~object ~k ~@options)) `(u/call! ^ChainShape ~object ~k ~@options))
(defn circle-shape* (defn circle-shape*
"The function version of `circle-shape`"
([] ([]
(CircleShape.)) (CircleShape.))
([radius] ([radius]
@@ -172,66 +165,64 @@
(.setPosition (m/vector-2 radius radius))))) (.setPosition (m/vector-2 radius radius)))))
(defmacro circle-shape (defmacro circle-shape
"Returns a [CircleShape](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/physics/box2d/CircleShape.html)" "Returns a [CircleShape](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/physics/box2d/CircleShape.html)."
[radius & options] [radius & options]
`(u/calls! ^CircleShape (circle-shape* ~radius) ~@options)) `(u/calls! ^CircleShape (circle-shape* ~radius) ~@options))
(defmacro circle-shape! (defmacro circle-shape!
"Calls a single method on a `circle-shape`" "Calls a single method on a `circle-shape`."
[object k & options] [object k & options]
`(u/call! ^CircleShape ~object ~k ~@options)) `(u/call! ^CircleShape ~object ~k ~@options))
(defn edge-shape* (defn edge-shape*
"The function version of `edge-shape`"
[] []
(EdgeShape.)) (EdgeShape.))
(defmacro edge-shape (defmacro edge-shape
"Returns an [EdgeShape](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/physics/box2d/EdgeShape.html)" "Returns an [EdgeShape](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/physics/box2d/EdgeShape.html)."
[& options] [& options]
`(u/calls! ^EdgeShape (edge-shape*) ~@options)) `(u/calls! ^EdgeShape (edge-shape*) ~@options))
(defmacro edge-shape! (defmacro edge-shape!
"Calls a single method on an `edge-shape`" "Calls a single method on an `edge-shape`."
[object k & options] [object k & options]
`(u/call! ^EdgeShape ~object ~k ~@options)) `(u/call! ^EdgeShape ~object ~k ~@options))
(defn polygon-shape* (defn polygon-shape*
"The function version of `polygon-shape`"
[] []
(PolygonShape.)) (PolygonShape.))
(defmacro polygon-shape (defmacro polygon-shape
"Returns a [PolygonShape](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/physics/box2d/PolygonShape.html)" "Returns a [PolygonShape](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/physics/box2d/PolygonShape.html)."
[& options] [& options]
`(u/calls! ^PolygonShape (polygon-shape*) ~@options)) `(u/calls! ^PolygonShape (polygon-shape*) ~@options))
(defmacro polygon-shape! (defmacro polygon-shape!
"Calls a single method on a `polygon-shape`" "Calls a single method on a `polygon-shape`."
[object k & options] [object k & options]
`(u/call! ^PolygonShape ~object ~k ~@options)) `(u/call! ^PolygonShape ~object ~k ~@options))
; misc ; misc
(defmacro contact! (defmacro contact!
"Calls a single method on a [Contact](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/physics/box2d/Contact.html)" "Calls a single method on a [Contact](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/physics/box2d/Contact.html)."
[screen k & options] [screen k & options]
`(u/call! ^Contact (u/get-obj ~screen :contact) ~k ~@options)) `(u/call! ^Contact (u/get-obj ~screen :contact) ~k ~@options))
(defn find-body (defn find-body
"Returns the first entity in `entities` whose body matches `body`" "Returns the first entity in `entities` whose body matches `body`."
[body entities] [body entities]
(some #(if (= body (:body %)) %) entities)) (some #(if (= body (:body %)) %) entities))
(defn first-body (defn first-body
"Returns the first body in a contact" "Returns the first body in a contact."
[screen] [screen]
(let [^Contact contact (u/get-obj screen :contact)] (let [^Contact contact (u/get-obj screen :contact)]
(assert contact) (assert contact)
(-> contact .getFixtureA .getBody))) (-> contact .getFixtureA .getBody)))
(defn second-body (defn second-body
"Returns the second body in a contact" "Returns the second body in a contact."
[screen] [screen]
(let [^Contact contact (u/get-obj screen :contact)] (let [^Contact contact (u/get-obj screen :contact)]
(assert contact) (assert contact)

View File

@@ -13,12 +13,11 @@
; animation-controller ; animation-controller
(defn animation-controller* (defn animation-controller*
"The function version of `animation-controller`"
[entity] [entity]
(AnimationController. (u/get-obj entity :object))) (AnimationController. (u/get-obj entity :object)))
(defmacro animation-controller (defmacro animation-controller
"Returns an [AnimationController](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/g3d/utils/AnimationController.html) "Returns an [AnimationController](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/g3d/utils/AnimationController.html).
(animation-controller model-entity)" (animation-controller model-entity)"
[entity & options] [entity & options]
@@ -26,7 +25,7 @@
(u/calls! object# ~@options))) (u/calls! object# ~@options)))
(defmacro animation-controller! (defmacro animation-controller!
"Calls a single method on an `animation-controller`" "Calls a single method on an `animation-controller`."
[object k & options] [object k & options]
`(let [^AnimationController object# ~object] `(let [^AnimationController object# ~object]
(u/call! object# ~k ~@options))) (u/call! object# ~k ~@options)))
@@ -34,12 +33,11 @@
; environment ; environment
(defn environment* (defn environment*
"The function version of `environment`"
[] []
(Environment.)) (Environment.))
(defmacro environment (defmacro environment
"Returns an [Environment](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/g3d/Environment.html) "Returns an [Environment](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/g3d/Environment.html).
(environment)" (environment)"
[& options] [& options]
@@ -47,7 +45,7 @@
(u/calls! object# ~@options))) (u/calls! object# ~@options)))
(defmacro environment! (defmacro environment!
"Calls a single method on an `environment`" "Calls a single method on an `environment`."
[screen k & options] [screen k & options]
`(let [^Environment object# (u/get-obj ~screen :attributes)] `(let [^Environment object# (u/get-obj ~screen :attributes)]
(u/call! object# ~k ~@options))) (u/call! object# ~k ~@options)))
@@ -55,12 +53,11 @@
; model-batch ; model-batch
(defn model-batch* (defn model-batch*
"The function version of `model-batch`"
[] []
(ModelBatch.)) (ModelBatch.))
(defmacro model-batch (defmacro model-batch
"Returns a [ModelBatch](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/g3d/ModelBatch.html) "Returns a [ModelBatch](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/g3d/ModelBatch.html).
(model-batch)" (model-batch)"
[& options] [& options]
@@ -68,7 +65,7 @@
(u/calls! object# ~@options))) (u/calls! object# ~@options)))
(defmacro model-batch! (defmacro model-batch!
"Calls a single method on a `model-batch`" "Calls a single method on a `model-batch`."
[screen k & options] [screen k & options]
`(let [^ModelBatch object# (u/get-obj ~screen :renderer)] `(let [^ModelBatch object# (u/get-obj ~screen :renderer)]
(u/call! object# ~k ~@options))) (u/call! object# ~k ~@options)))
@@ -76,7 +73,7 @@
; model ; model
(defmacro model (defmacro model
"Returns an entity based on [ModelInstance](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/g3d/ModelInstance.html)" "Returns an entity based on [ModelInstance](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/g3d/ModelInstance.html)."
[& args] [& args]
`(ModelEntity. `(ModelEntity.
(let [arg1# ~(first args)] (let [arg1# ~(first args)]
@@ -89,7 +86,7 @@
(ModelInstance. ~@args))))) (ModelInstance. ~@args)))))
(defmacro model! (defmacro model!
"Calls a single method on a `model`" "Calls a single method on a `model`."
[entity k & options] [entity k & options]
`(let [^ModelInstance object# (u/get-obj ~entity :object)] `(let [^ModelInstance object# (u/get-obj ~entity :object)]
(u/call! object# ~k ~@options))) (u/call! object# ~k ~@options)))
@@ -97,12 +94,11 @@
; model-builder ; model-builder
(defn model-builder* (defn model-builder*
"The function version of `model-builder`"
[] []
(ModelBuilder.)) (ModelBuilder.))
(defmacro model-builder (defmacro model-builder
"Returns a [ModelBuilder](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/g3d/utils/ModelBuilder.html) "Returns a [ModelBuilder](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/g3d/utils/ModelBuilder.html).
(model-builder)" (model-builder)"
[& options] [& options]
@@ -110,19 +106,18 @@
(u/calls! object# ~@options))) (u/calls! object# ~@options)))
(defmacro model-builder! (defmacro model-builder!
"Calls a single method on a `model-builder`" "Calls a single method on a `model-builder`."
[object k & options] [object k & options]
`(u/call! ^ModelBuilder ~object ~k ~@options)) `(u/call! ^ModelBuilder ~object ~k ~@options))
; material ; material
(defn material* (defn material*
"The function version of `material`"
[] []
(Material.)) (Material.))
(defmacro material (defmacro material
"Returns a [Material](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/g3d/Material.html) "Returns a [Material](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/g3d/Material.html).
(material)" (material)"
[& options] [& options]
@@ -130,26 +125,25 @@
(u/calls! object# ~@options))) (u/calls! object# ~@options)))
(defmacro material! (defmacro material!
"Calls a single method on a `material`" "Calls a single method on a `material`."
[object k & options] [object k & options]
`(u/call! ^Material ~object ~k ~@options)) `(u/call! ^Material ~object ~k ~@options))
; attribute ; attribute
(defn ^:private attribute-init (defn ^:private attribute-init
"Internal use only"
[k] [k]
(u/gdx :graphics :g3d :attributes (str (u/key->pascal k) "Attribute."))) (u/gdx :graphics :g3d :attributes (str (u/key->pascal k) "Attribute.")))
(defmacro attribute (defmacro attribute
"Returns a subclass of [Attribute](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/g3d/Attribute.html) "Returns a subclass of [Attribute](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/g3d/Attribute.html).
(attribute :color (attribute-type :color :diffuse) (color :blue))" (attribute :color (attribute-type :color :diffuse) (color :blue))"
[type & args] [type & args]
`(~(attribute-init type) ~@args)) `(~(attribute-init type) ~@args))
(defmacro attribute-type (defmacro attribute-type
"Returns a static field in a subclass of [Attribute](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/g3d/Attribute.html) "Returns a static field in a subclass of [Attribute](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/g3d/Attribute.html).
(attribute-type :color :diffuse)" (attribute-type :color :diffuse)"
[type k] [type k]
@@ -158,7 +152,7 @@
(u/key->pascal k))) (u/key->pascal k)))
(defmacro attribute! (defmacro attribute!
"Calls a static method in a subclass of [Attribute](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/g3d/Attribute.html) "Calls a static method in a subclass of [Attribute](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/g3d/Attribute.html).
(attribute! :color :create-diffuse (color :blue))" (attribute! :color :create-diffuse (color :blue))"
[type k & options] [type k & options]

View File

@@ -9,33 +9,33 @@
; static methods/fields ; static methods/fields
(defmacro geometry! (defmacro geometry!
"Calls a single static method on [GeometryUtils](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/math/GeometryUtils.html)" "Calls a single static method on [GeometryUtils](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/math/GeometryUtils.html)."
[k & options] [k & options]
`(~(u/gdx-field :math :GeometryUtils (u/key->camel k)) ~@options)) `(~(u/gdx-field :math :GeometryUtils (u/key->camel k)) ~@options))
(defmacro interpolation (defmacro interpolation
"Returns a static class in [Interpolation](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/math/Interpolation.html) "Returns a static class in [Interpolation](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/math/Interpolation.html).
(interpolation :bounce)" (interpolation :bounce)"
[k] [k]
`~(u/gdx-class :math :Interpolation (u/key->pascal k))) `~(u/gdx-class :math :Interpolation (u/key->pascal k)))
(defmacro intersector! (defmacro intersector!
"Calls a single static method on [Intersector](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/math/Intersector.html) "Calls a single static method on [Intersector](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/math/Intersector.html).
(intersector! :is-point-in-triangle 0 1 0 0 1 2 3 0)" (intersector! :is-point-in-triangle 0 1 0 0 1 2 3 0)"
[k & options] [k & options]
`(~(u/gdx-field :math :Intersector (u/key->camel k)) ~@options)) `(~(u/gdx-field :math :Intersector (u/key->camel k)) ~@options))
(defmacro math! (defmacro math!
"Calls a single static method on [MathUtils](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/math/MathUtils.html) "Calls a single static method on [MathUtils](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/math/MathUtils.html).
(math! :ceil 0.1)" (math! :ceil 0.1)"
[k & options] [k & options]
`(~(u/gdx-field :math :MathUtils (u/key->camel k)) ~@options)) `(~(u/gdx-field :math :MathUtils (u/key->camel k)) ~@options))
(defmacro plane-side (defmacro plane-side
"Returns a static field in [Plane.PlaneSide](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/math/Plane.PlaneSide.html) "Returns a static field in [Plane.PlaneSide](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/math/Plane.PlaneSide.html).
(plane-side :back)" (plane-side :back)"
[k] [k]
@@ -44,418 +44,395 @@
; bezier ; bezier
(defn bezier* (defn bezier*
"The function version of `bezier`"
([] ([]
(Bezier.)) (Bezier.))
([points] ([points]
(Bezier. (into-array points) 0 (count points)))) (Bezier. (into-array points) 0 (count points))))
(defmacro bezier (defmacro bezier
"Returns a [Bezier](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/math/Bezier.html)" "Returns a [Bezier](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/math/Bezier.html)."
[points & options] [points & options]
`(u/calls! ^Bezier (bezier* ~points) ~@options)) `(u/calls! ^Bezier (bezier* ~points) ~@options))
(defmacro bezier! (defmacro bezier!
"Calls a single method on a `bezier`" "Calls a single method on a `bezier`."
[object k & options] [object k & options]
`(u/call! ^Bezier ~object ~k ~@options)) `(u/call! ^Bezier ~object ~k ~@options))
; bresenham2 ; bresenham2
(defn bresenham-2* (defn bresenham-2*
"The function version of `bresenham-2`"
[] []
(Bresenham2.)) (Bresenham2.))
(defmacro bresenham-2 (defmacro bresenham-2
"Returns a [Bresenham2](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/math/Bresenham2.html)" "Returns a [Bresenham2](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/math/Bresenham2.html)."
[& options] [& options]
`(u/calls! ^Bresenham2 (bresenham-2*) ~@options)) `(u/calls! ^Bresenham2 (bresenham-2*) ~@options))
(defmacro bresenham-2! (defmacro bresenham-2!
"Calls a single method on a `bresenham-2`" "Calls a single method on a `bresenham-2`."
[object k & options] [object k & options]
`(u/call! ^Bresenham2 ~object ~k ~@options)) `(u/call! ^Bresenham2 ~object ~k ~@options))
; b-spline ; b-spline
(defn b-spline* (defn b-spline*
"The function version of `b-spline`"
([] ([]
(BSpline.)) (BSpline.))
([points degree cont?] ([points degree cont?]
(BSpline. (into-array points) degree cont?))) (BSpline. (into-array points) degree cont?)))
(defmacro b-spline (defmacro b-spline
"Returns a [BSpline](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/math/BSpline.html)" "Returns a [BSpline](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/math/BSpline.html)."
[points degree cont? & options] [points degree cont? & options]
`(u/calls! ^BSpline (b-spline* ~points ~degree ~cont?) ~@options)) `(u/calls! ^BSpline (b-spline* ~points ~degree ~cont?) ~@options))
(defmacro b-spline! (defmacro b-spline!
"Calls a single method on a `b-spline`" "Calls a single method on a `b-spline`."
[object k & options] [object k & options]
`(u/call! ^BSpline ~object ~k ~@options)) `(u/call! ^BSpline ~object ~k ~@options))
; catmull-rom-spline ; catmull-rom-spline
(defn catmull-rom-spline* (defn catmull-rom-spline*
"The function version of `catmull-rom-spline`"
([] ([]
(CatmullRomSpline.)) (CatmullRomSpline.))
([points cont?] ([points cont?]
(CatmullRomSpline. (into-array points) cont?))) (CatmullRomSpline. (into-array points) cont?)))
(defmacro catmull-rom-spline (defmacro catmull-rom-spline
"Returns a [CatmullRomSpline](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/math/CatmullRomSpline.html)" "Returns a [CatmullRomSpline](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/math/CatmullRomSpline.html)."
[points cont? & options] [points cont? & options]
`(u/calls! ^CatmullRomSpline (catmull-rom-spline* ~points ~cont?) ~@options)) `(u/calls! ^CatmullRomSpline (catmull-rom-spline* ~points ~cont?) ~@options))
(defmacro catmull-rom-spline! (defmacro catmull-rom-spline!
"Calls a single method on a `catmull-rom-spline`" "Calls a single method on a `catmull-rom-spline`."
[object k & options] [object k & options]
`(u/call! ^CatmullRomSpline ~object ~k ~@options)) `(u/call! ^CatmullRomSpline ~object ~k ~@options))
; circle ; circle
(defn circle* (defn circle*
"The function version of `circle`"
([] ([]
(Circle.)) (Circle.))
([x y radius] ([x y radius]
(Circle. x y radius))) (Circle. x y radius)))
(defmacro circle (defmacro circle
"Returns a [Circle](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/math/Circle.html)" "Returns a [Circle](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/math/Circle.html)."
[x y radius & options] [x y radius & options]
`(u/calls! ^Circle (circle* ~x ~y ~radius) ~@options)) `(u/calls! ^Circle (circle* ~x ~y ~radius) ~@options))
(defmacro circle! (defmacro circle!
"Calls a single method on a `circle`" "Calls a single method on a `circle`."
[object k & options] [object k & options]
`(u/call! ^Circle ~object ~k ~@options)) `(u/call! ^Circle ~object ~k ~@options))
; convex-hull ; convex-hull
(defn convex-hull* (defn convex-hull*
"The function version of `convex-hull`"
[] []
(ConvexHull.)) (ConvexHull.))
(defmacro convex-hull (defmacro convex-hull
"Returns a [ConvexHull](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/math/ConvexHull.html)" "Returns a [ConvexHull](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/math/ConvexHull.html)."
[& options] [& options]
`(u/calls! ^ConvexHull (convex-hull*) ~@options)) `(u/calls! ^ConvexHull (convex-hull*) ~@options))
(defmacro convex-hull! (defmacro convex-hull!
"Calls a single method on a `convex-hull`" "Calls a single method on a `convex-hull`."
[object k & options] [object k & options]
`(u/call! ^ConvexHull ~object ~k ~@options)) `(u/call! ^ConvexHull ~object ~k ~@options))
; delaunay-triangulator ; delaunay-triangulator
(defn delaunay-triangulator* (defn delaunay-triangulator*
"The function version of `delaunay-triangulator`"
[] []
(DelaunayTriangulator.)) (DelaunayTriangulator.))
(defmacro delaunay-triangulator (defmacro delaunay-triangulator
"Returns a [DelaunayTriangulator](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/math/DelaunayTriangulator.html)" "Returns a [DelaunayTriangulator](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/math/DelaunayTriangulator.html)."
[& options] [& options]
`(u/calls! ^DelaunayTriangulator (delaunay-triangulator*) ~@options)) `(u/calls! ^DelaunayTriangulator (delaunay-triangulator*) ~@options))
(defmacro delaunay-triangulator! (defmacro delaunay-triangulator!
"Calls a single method on a `delaunay-triangulator`" "Calls a single method on a `delaunay-triangulator`."
[object k & options] [object k & options]
`(u/call! ^DelaunayTriangulator ~object ~k ~@options)) `(u/call! ^DelaunayTriangulator ~object ~k ~@options))
; ear-clipping-triangulator ; ear-clipping-triangulator
(defn ear-clipping-triangulator* (defn ear-clipping-triangulator*
"The function version of `ear-clipping-triangulator`"
[] []
(EarClippingTriangulator.)) (EarClippingTriangulator.))
(defmacro ear-clipping-triangulator (defmacro ear-clipping-triangulator
"Returns an [EarClippingTriangulator](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/math/EarClippingTriangulator.html)" "Returns an [EarClippingTriangulator](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/math/EarClippingTriangulator.html)."
[& options] [& options]
`(u/calls! ^EarClippingTriangulator (ear-clipping-triangulator*) ~@options)) `(u/calls! ^EarClippingTriangulator (ear-clipping-triangulator*) ~@options))
(defmacro ear-clipping-triangulator! (defmacro ear-clipping-triangulator!
"Calls a single method on a `ear-clipping-triangulator`" "Calls a single method on a `ear-clipping-triangulator`."
[object k & options] [object k & options]
`(u/call! ^EarClippingTriangulator ~object ~k ~@options)) `(u/call! ^EarClippingTriangulator ~object ~k ~@options))
; ellipse ; ellipse
(defn ellipse* (defn ellipse*
"The function version of `ellipse`"
([] ([]
(Ellipse.)) (Ellipse.))
([x y width height] ([x y width height]
(Ellipse. x y width height))) (Ellipse. x y width height)))
(defmacro ellipse (defmacro ellipse
"Returns an [Ellipse](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/math/Ellipse.html)" "Returns an [Ellipse](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/math/Ellipse.html)."
[x y width height & options] [x y width height & options]
`(u/calls! ^Ellipse (ellipse* ~x ~y ~width ~height) ~@options)) `(u/calls! ^Ellipse (ellipse* ~x ~y ~width ~height) ~@options))
(defmacro ellipse! (defmacro ellipse!
"Calls a single method on an `ellipse`" "Calls a single method on an `ellipse`."
[object k & options] [object k & options]
`(u/call! ^Ellipse ~object ~k ~@options)) `(u/call! ^Ellipse ~object ~k ~@options))
; float-counter ; float-counter
(defn float-counter* (defn float-counter*
"The function version of `float-counter`"
[window-size] [window-size]
(FloatCounter. window-size)) (FloatCounter. window-size))
(defmacro float-counter (defmacro float-counter
"Returns a [FloatCounter](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/math/FloatCounter.html)" "Returns a [FloatCounter](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/math/FloatCounter.html)."
[window-size & options] [window-size & options]
`(u/calls! ^FloatCounter (float-counter* ~window-size) ~@options)) `(u/calls! ^FloatCounter (float-counter* ~window-size) ~@options))
(defmacro float-counter! (defmacro float-counter!
"Calls a single method on a `float-counter`" "Calls a single method on a `float-counter`."
[object k & options] [object k & options]
`(u/call! ^FloatCounter ~object ~k ~@options)) `(u/call! ^FloatCounter ~object ~k ~@options))
; frustum ; frustum
(defn frustum* (defn frustum*
"The function version of `frustum`"
[] []
(Frustum.)) (Frustum.))
(defmacro frustum (defmacro frustum
"Returns a [Frustum](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/math/Frustum.html)" "Returns a [Frustum](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/math/Frustum.html)."
[& options] [& options]
`(u/calls! ^Frustum (frustum*) ~@options)) `(u/calls! ^Frustum (frustum*) ~@options))
(defmacro frustum! (defmacro frustum!
"Calls a single method on a `frustum`" "Calls a single method on a `frustum`."
[object k & options] [object k & options]
`(u/call! ^Frustum ~object ~k ~@options)) `(u/call! ^Frustum ~object ~k ~@options))
; grid-point-2 ; grid-point-2
(defn grid-point-2* (defn grid-point-2*
"The function version of `grid-point-2`"
[x y] [x y]
(GridPoint2. x y)) (GridPoint2. x y))
(defmacro grid-point-2 (defmacro grid-point-2
"Returns a [GridPoint2](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/math/GridPoint2.html)" "Returns a [GridPoint2](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/math/GridPoint2.html)."
[x y & options] [x y & options]
`(u/calls! ^GridPoint2 (grid-point-2* ~x ~y) ~@options)) `(u/calls! ^GridPoint2 (grid-point-2* ~x ~y) ~@options))
(defmacro grid-point-2! (defmacro grid-point-2!
"Calls a single method on a `grid-point-2`" "Calls a single method on a `grid-point-2`."
[object k & options] [object k & options]
`(u/call! ^GridPoint2 ~object ~k ~@options)) `(u/call! ^GridPoint2 ~object ~k ~@options))
; grid-point-3 ; grid-point-3
(defn grid-point-3* (defn grid-point-3*
"The function version of `grid-point-3`"
[x y z] [x y z]
(GridPoint3. x y z)) (GridPoint3. x y z))
(defmacro grid-point-3 (defmacro grid-point-3
"Returns a [GridPoint3](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/math/GridPoint3.html)" "Returns a [GridPoint3](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/math/GridPoint3.html)."
[x y z & options] [x y z & options]
`(u/calls! ^GridPoint3 (grid-point-3* ~x ~y ~z) ~@options)) `(u/calls! ^GridPoint3 (grid-point-3* ~x ~y ~z) ~@options))
(defmacro grid-point-3! (defmacro grid-point-3!
"Calls a single method on a `grid-point-3`" "Calls a single method on a `grid-point-3`."
[object k & options] [object k & options]
`(u/call! ^GridPoint3 ~object ~k ~@options)) `(u/call! ^GridPoint3 ~object ~k ~@options))
; matrix-3 ; matrix-3
(defn matrix-3* (defn matrix-3*
"The function version of `matrix-3`"
([] ([]
(Matrix3.)) (Matrix3.))
([values] ([values]
(Matrix3. values))) (Matrix3. values)))
(defmacro matrix-3 (defmacro matrix-3
"Returns a [Matrix3](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/math/Matrix3.html)" "Returns a [Matrix3](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/math/Matrix3.html)."
[values & options] [values & options]
`(u/calls! ^Matrix3 (matrix-3* ~values) ~@options)) `(u/calls! ^Matrix3 (matrix-3* ~values) ~@options))
(defmacro matrix-3! (defmacro matrix-3!
"Calls a single method on a `matrix-3`" "Calls a single method on a `matrix-3`."
[object k & options] [object k & options]
`(u/call! ^Matrix3 ~object ~k ~@options)) `(u/call! ^Matrix3 ~object ~k ~@options))
; matrix-4 ; matrix-4
(defn matrix-4* (defn matrix-4*
"The function version of `matrix-4`"
([] ([]
(Matrix4.)) (Matrix4.))
([^floats values] ([^floats values]
(Matrix4. values))) (Matrix4. values)))
(defmacro matrix-4 (defmacro matrix-4
"Returns a [Matrix4](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/math/Matrix4.html)" "Returns a [Matrix4](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/math/Matrix4.html)."
[values & options] [values & options]
`(u/calls! ^Matrix4 (matrix-4* ~values) ~@options)) `(u/calls! ^Matrix4 (matrix-4* ~values) ~@options))
(defmacro matrix-4! (defmacro matrix-4!
"Calls a single method on a `matrix-4`" "Calls a single method on a `matrix-4`."
[object k & options] [object k & options]
`(u/call! ^Matrix4 ~object ~k ~@options)) `(u/call! ^Matrix4 ~object ~k ~@options))
; plane ; plane
(defn plane* (defn plane*
"The function version of `plane`"
([arg1 arg2] ([arg1 arg2]
(Plane. arg1 arg2)) (Plane. arg1 arg2))
([^Vector3 p1 ^Vector3 p2 ^Vector3 p3] ([^Vector3 p1 ^Vector3 p2 ^Vector3 p3]
(Plane. p1 p2 p3))) (Plane. p1 p2 p3)))
(defmacro plane (defmacro plane
"Returns a [Plane](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/math/Plane.html)" "Returns a [Plane](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/math/Plane.html)."
[args & options] [args & options]
`(u/calls! ^Plane (apply plane* ~args) ~@options)) `(u/calls! ^Plane (apply plane* ~args) ~@options))
(defmacro plane! (defmacro plane!
"Calls a single method on a `plane`" "Calls a single method on a `plane`."
[object k & options] [object k & options]
`(u/call! ^Plane ~object ~k ~@options)) `(u/call! ^Plane ~object ~k ~@options))
; polygon ; polygon
(defn polygon* (defn polygon*
"The function version of `polygon`"
([] ([]
(Polygon.)) (Polygon.))
([vertices] ([vertices]
(Polygon. vertices))) (Polygon. vertices)))
(defmacro polygon (defmacro polygon
"Returns a [Polygon](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/math/Polygon.html)" "Returns a [Polygon](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/math/Polygon.html)."
[vertices & options] [vertices & options]
`(u/calls! ^Polygon (polygon* ~vertices) ~@options)) `(u/calls! ^Polygon (polygon* ~vertices) ~@options))
(defmacro polygon! (defmacro polygon!
"Calls a single method on a `polygon`" "Calls a single method on a `polygon`."
[object k & options] [object k & options]
`(u/call! ^Polygon ~object ~k ~@options)) `(u/call! ^Polygon ~object ~k ~@options))
; polyline ; polyline
(defn polyline* (defn polyline*
"The function version of `polyline`"
([] ([]
(Polyline.)) (Polyline.))
([vertices] ([vertices]
(Polyline. vertices))) (Polyline. vertices)))
(defmacro polyline (defmacro polyline
"Returns a [Polyline](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/math/Polyline.html)" "Returns a [Polyline](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/math/Polyline.html)."
[vertices & options] [vertices & options]
`(u/calls! ^Polyline (polyline* ~vertices) ~@options)) `(u/calls! ^Polyline (polyline* ~vertices) ~@options))
(defmacro polyline! (defmacro polyline!
"Calls a single method on a `polyline`" "Calls a single method on a `polyline`."
[object k & options] [object k & options]
`(u/call! ^Polyline ~object ~k ~@options)) `(u/call! ^Polyline ~object ~k ~@options))
; quaternion ; quaternion
(defn quaternion* (defn quaternion*
"The function version of `quaternion`"
([] ([]
(Quaternion.)) (Quaternion.))
([w x y z] ([w x y z]
(Quaternion. w x y z))) (Quaternion. w x y z)))
(defmacro quaternion (defmacro quaternion
"Returns a [Quaternion](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/math/Quaternion.html)" "Returns a [Quaternion](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/math/Quaternion.html)."
[w x y z & options] [w x y z & options]
`(u/calls! ^Quaternion (quaternion* ~w ~x ~y ~z) ~@options)) `(u/calls! ^Quaternion (quaternion* ~w ~x ~y ~z) ~@options))
(defmacro quaternion! (defmacro quaternion!
"Calls a single method on a `quaternion`" "Calls a single method on a `quaternion`."
[object k & options] [object k & options]
`(u/call! ^Quaternion ~object ~k ~@options)) `(u/call! ^Quaternion ~object ~k ~@options))
; rectangle ; rectangle
(defn rectangle* (defn rectangle*
"The function version of `rectangle`"
([] ([]
(Rectangle.)) (Rectangle.))
([x y width height] ([x y width height]
(Rectangle. x y width height))) (Rectangle. x y width height)))
(defmacro rectangle (defmacro rectangle
"Returns a [Rectangle](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/math/Rectangle.html)" "Returns a [Rectangle](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/math/Rectangle.html)."
[x y width height & options] [x y width height & options]
`(u/calls! ^Rectangle (rectangle* ~x ~y ~width ~height) ~@options)) `(u/calls! ^Rectangle (rectangle* ~x ~y ~width ~height) ~@options))
(defmacro rectangle! (defmacro rectangle!
"Calls a single method on a `rectangle`" "Calls a single method on a `rectangle`."
[object k & options] [object k & options]
`(u/call! ^Rectangle ~object ~k ~@options)) `(u/call! ^Rectangle ~object ~k ~@options))
; vector-2 ; vector-2
(defn vector-2* (defn vector-2*
"The function version of `vector-2`"
([] ([]
(Vector2.)) (Vector2.))
([x y] ([x y]
(Vector2. x y))) (Vector2. x y)))
(defmacro vector-2 (defmacro vector-2
"Returns a [Vector2](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/math/Vector2.html)" "Returns a [Vector2](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/math/Vector2.html)."
[x y & options] [x y & options]
`(u/calls! ^Vector2 (vector-2* ~x ~y) ~@options)) `(u/calls! ^Vector2 (vector-2* ~x ~y) ~@options))
(defmacro vector-2! (defmacro vector-2!
"Calls a single method on a `vector-2`" "Calls a single method on a `vector-2`."
[object k & options] [object k & options]
`(u/call! ^Vector2 ~object ~k ~@options)) `(u/call! ^Vector2 ~object ~k ~@options))
; vector-3 ; vector-3
(defn vector-3* (defn vector-3*
"The function version of `vector-3`"
([] ([]
(Vector3.)) (Vector3.))
([x y z] ([x y z]
(Vector3. x y z))) (Vector3. x y z)))
(defmacro vector-3 (defmacro vector-3
"Returns a [Vector3](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/math/Vector3.html)" "Returns a [Vector3](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/math/Vector3.html)."
[x y z & options] [x y z & options]
`(u/calls! ^Vector3 (vector-3* ~x ~y ~z) ~@options)) `(u/calls! ^Vector3 (vector-3* ~x ~y ~z) ~@options))
(defmacro vector-3! (defmacro vector-3!
"Calls a single method on a `vector-3`" "Calls a single method on a `vector-3`."
[object k & options] [object k & options]
`(u/call! ^Vector3 ~object ~k ~@options)) `(u/call! ^Vector3 ~object ~k ~@options))
; windowed-mean ; windowed-mean
(defn windowed-mean* (defn windowed-mean*
"The function version of `windowed-mean`"
[window-size] [window-size]
(WindowedMean. window-size)) (WindowedMean. window-size))
(defmacro windowed-mean (defmacro windowed-mean
"Returns a [WindowedMean](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/math/WindowedMean.html)" "Returns a [WindowedMean](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/math/WindowedMean.html)."
[window-size & options] [window-size & options]
`(u/calls! ^WindowedMean (windowed-mean* ~window-size) ~@options)) `(u/calls! ^WindowedMean (windowed-mean* ~window-size) ~@options))
(defmacro windowed-mean! (defmacro windowed-mean!
"Calls a single method on a `windowed-mean`" "Calls a single method on a `windowed-mean`."
[object k & options] [object k & options]
`(u/call! ^WindowedMean ~object ~k ~@options)) `(u/call! ^WindowedMean ~object ~k ~@options))

View File

@@ -15,7 +15,7 @@
[play_clj.entities ActorEntity])) [play_clj.entities ActorEntity]))
(defmacro drawable (defmacro drawable
"Returns a subclass of [BaseDrawable](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/utils/BaseDrawable.html) "Returns a subclass of [BaseDrawable](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/utils/BaseDrawable.html).
(drawable :texture-region)" (drawable :texture-region)"
[k & options] [k & options]
@@ -24,7 +24,7 @@
~@options)) ~@options))
(defmacro style (defmacro style
"Returns a style object whose class is determined by the keyword `k` "Returns a style object whose class is determined by the keyword `k`.
(style :check-box)" (style :check-box)"
[k & options] [k & options]
@@ -35,22 +35,21 @@
(defmacro skin (defmacro skin
"Returns a [Skin](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/ui/Skin.html) "Returns a [Skin](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/ui/Skin.html)
based on the file at `path` based on the file at `path`.
(skin \"uiskin.json\")" (skin \"uiskin.json\")"
[path & options] [path & options]
`(u/calls! ^Skin (Skin. (.internal ^Files (Gdx/files) ~path)) ~@options)) `(u/calls! ^Skin (Skin. (.internal ^Files (Gdx/files) ~path)) ~@options))
(defmacro align (defmacro align
"Returns a static field from [Align](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/utils/Align.html) "Returns a static field from [Align](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/utils/Align.html).
(align :center)" (align :center)"
[k] [k]
`~(u/gdx-field :scenes :scene2d :utils :Align (u/key->camel k))) `~(u/gdx-field :scenes :scene2d :utils :Align (u/key->camel k)))
(defn cell! (defn cell!
"Calls a single method on a [Cell](https://github.com/libgdx/libgdx/blob/master/gdx/src/com/esotericsoftware/tablelayout/Cell.java) "Calls a single method on a [Cell](https://github.com/libgdx/libgdx/blob/master/gdx/src/com/esotericsoftware/tablelayout/Cell.java)."
(this could probably be made into a macro...)"
[^Cell cell & args] [^Cell cell & args]
(let [method (first args) (let [method (first args)
[[a1 a2 a3 a4] rest-args] (split-with #(not (keyword? %)) (rest args))] [[a1 a2 a3 a4] rest-args] (split-with #(not (keyword? %)) (rest args))]
@@ -98,16 +97,13 @@ based on the file at `path`
cell)) cell))
(defmulti add-to-group! (defmulti add-to-group!
"Internal use only"
#(-> % first :object type) :default WidgetGroup) #(-> % first :object type) :default WidgetGroup)
(defn ^:private create-tree-node (defn ^:private create-tree-node
"Internal use only"
[child] [child]
{:object (Tree$Node. ^Actor (:object child))}) {:object (Tree$Node. ^Actor (:object child))})
(defn ^:private add-tree-nodes (defn ^:private add-tree-nodes
"Internal use only"
[parent children] [parent children]
(when-let [node (add-to-group! [parent (first children)])] (when-let [node (add-to-group! [parent (first children)])]
(doseq [child (rest children)] (doseq [child (rest children)]
@@ -151,26 +147,24 @@ based on the file at `path`
(add-tree-nodes parent child))) (add-tree-nodes parent child)))
(defn add! (defn add!
"Adds the entities in `children` to the `group` entity of type [WidgetGroup](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/ui/WidgetGroup.html)" "Adds the entities in `children` to the `group` entity of type [WidgetGroup](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/ui/WidgetGroup.html)."
[group & children] [group & children]
(doseq [child children] (doseq [child children]
(add-to-group! [group child])) (add-to-group! [group child]))
group) group)
(defn ^:private create-group (defn ^:private create-group
"Internal use only"
[^WidgetGroup group children] [^WidgetGroup group children]
(apply add! (ActorEntity. group) children)) (apply add! (ActorEntity. group) children))
; check-box ; check-box
(defn check-box* (defn check-box*
"The function version of `check-box`"
[^String text arg] [^String text arg]
(ActorEntity. (CheckBox. text arg))) (ActorEntity. (CheckBox. text arg)))
(defmacro check-box (defmacro check-box
"Returns an entity based on [CheckBox](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/ui/CheckBox.html) "Returns an entity based on [CheckBox](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/ui/CheckBox.html).
(check-box \"I'm a check box\" (style :check-box off on font color)) (check-box \"I'm a check box\" (style :check-box off on font color))
(check-box \"I'm a check box\" (skin \"uiskin.json\"))" (check-box \"I'm a check box\" (skin \"uiskin.json\"))"
@@ -180,19 +174,18 @@ based on the file at `path`
entity#)) entity#))
(defmacro check-box! (defmacro check-box!
"Calls a single method on a `check-box`" "Calls a single method on a `check-box`."
[entity k & options] [entity k & options]
`(u/call! ^Checkbox (u/get-obj ~entity :object) ~k ~@options)) `(u/call! ^Checkbox (u/get-obj ~entity :object) ~k ~@options))
; dialog ; dialog
(defn dialog* (defn dialog*
"The function version of `dialog`"
[text arg] [text arg]
(ActorEntity. (Dialog. text arg))) (ActorEntity. (Dialog. text arg)))
(defmacro dialog (defmacro dialog
"Returns an entity based on [Dialog](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/ui/Dialog.html) "Returns an entity based on [Dialog](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/ui/Dialog.html).
(dialog \"I'm a dialog\" (style :window font font-color background)) (dialog \"I'm a dialog\" (style :window font font-color background))
(dialog \"I'm a dialog\" (skin \"uiskin.json\"))" (dialog \"I'm a dialog\" (skin \"uiskin.json\"))"
@@ -202,19 +195,18 @@ based on the file at `path`
entity#)) entity#))
(defmacro dialog! (defmacro dialog!
"Calls a single method on a `dialog`" "Calls a single method on a `dialog`."
[entity k & options] [entity k & options]
`(u/call! ^Dialog (u/get-obj ~entity :object) ~k ~@options)) `(u/call! ^Dialog (u/get-obj ~entity :object) ~k ~@options))
; horizontal ; horizontal
(defn horizontal* (defn horizontal*
"The function version of `horizontal`"
[children] [children]
(create-group (HorizontalGroup.) children)) (create-group (HorizontalGroup.) children))
(defmacro horizontal (defmacro horizontal
"Returns an entity based on [HorizontalGroup](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/ui/HorizontalGroup.html) "Returns an entity based on [HorizontalGroup](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/ui/HorizontalGroup.html).
(horizontal [entity-1 entity-2])" (horizontal [entity-1 entity-2])"
[children & options] [children & options]
@@ -223,14 +215,13 @@ based on the file at `path`
entity#)) entity#))
(defmacro horizontal! (defmacro horizontal!
"Calls a single method on a `horizontal`" "Calls a single method on a `horizontal`."
[entity k & options] [entity k & options]
`(u/call! ^HorizontalGroup (u/get-obj ~entity :object) ~k ~@options)) `(u/call! ^HorizontalGroup (u/get-obj ~entity :object) ~k ~@options))
; image ; image
(defn image* (defn image*
"The function version of `image`"
[arg] [arg]
(ActorEntity. (ActorEntity.
(cond (cond
@@ -242,7 +233,7 @@ based on the file at `path`
(Image. arg)))) (Image. arg))))
(defmacro image (defmacro image
"Returns an entity based on [Image](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/ui/Image.html) "Returns an entity based on [Image](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/ui/Image.html).
(image \"image.png\")" (image \"image.png\")"
[arg & options] [arg & options]
@@ -251,19 +242,18 @@ based on the file at `path`
entity#)) entity#))
(defmacro image! (defmacro image!
"Calls a single method on a `image`" "Calls a single method on a `image`."
[entity k & options] [entity k & options]
`(u/call! ^Image (u/get-obj ~entity :object) ~k ~@options)) `(u/call! ^Image (u/get-obj ~entity :object) ~k ~@options))
; image-button ; image-button
(defn image-button* (defn image-button*
"The function version of `image-button`"
[arg] [arg]
(ActorEntity. (ImageButton. arg))) (ActorEntity. (ImageButton. arg)))
(defmacro image-button (defmacro image-button
"Returns an entity based on [ImageButton](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/ui/ImageButton.html) "Returns an entity based on [ImageButton](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/ui/ImageButton.html).
(image-button (style :image-button up dn check img-up img-dn img-check)) (image-button (style :image-button up dn check img-up img-dn img-check))
(image-button (skin \"uiskin.json\"))" (image-button (skin \"uiskin.json\"))"
@@ -273,19 +263,18 @@ based on the file at `path`
entity#)) entity#))
(defmacro image-button! (defmacro image-button!
"Calls a single method on a `image-button`" "Calls a single method on a `image-button`."
[entity k & options] [entity k & options]
`(u/call! ^ImageButton (u/get-obj ~entity :object) ~k ~@options)) `(u/call! ^ImageButton (u/get-obj ~entity :object) ~k ~@options))
; image-text-button ; image-text-button
(defn image-text-button* (defn image-text-button*
"The function version of `image-text-button`"
[^String text arg] [^String text arg]
(ActorEntity. (ImageTextButton. text arg))) (ActorEntity. (ImageTextButton. text arg)))
(defmacro image-text-button (defmacro image-text-button
"Returns an entity based on [ImageTextButton](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/ui/ImageTextButton.html) "Returns an entity based on [ImageTextButton](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/ui/ImageTextButton.html).
(image-text-button \"I'm an image text button\" (image-text-button \"I'm an image text button\"
(style :image-text-button up down checked font)) (style :image-text-button up down checked font))
@@ -296,14 +285,13 @@ based on the file at `path`
entity#)) entity#))
(defmacro image-text-button! (defmacro image-text-button!
"Calls a single method on a `image-text-button`" "Calls a single method on a `image-text-button`."
[entity k & options] [entity k & options]
`(u/call! ^ImageTextButton (u/get-obj ~entity :object) ~k ~@options)) `(u/call! ^ImageTextButton (u/get-obj ~entity :object) ~k ~@options))
; label ; label
(defn label* (defn label*
"The function version of `label`"
[^String text arg] [^String text arg]
(ActorEntity. (ActorEntity.
(if (isa? (type arg) Color) (if (isa? (type arg) Color)
@@ -311,7 +299,7 @@ based on the file at `path`
(Label. text arg)))) (Label. text arg))))
(defmacro label (defmacro label
"Returns an entity based on [Label](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/ui/Label.html) "Returns an entity based on [Label](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/ui/Label.html).
(label \"I'm a label\" (color :white)) (label \"I'm a label\" (color :white))
(label \"I'm a label\" (style :label (g2d/bitmap-font) (color :white))) (label \"I'm a label\" (style :label (g2d/bitmap-font) (color :white)))
@@ -322,19 +310,18 @@ based on the file at `path`
entity#)) entity#))
(defmacro label! (defmacro label!
"Calls a single method on a `label`" "Calls a single method on a `label`."
[entity k & options] [entity k & options]
`(u/call! ^Label (u/get-obj ~entity :object) ~k ~@options)) `(u/call! ^Label (u/get-obj ~entity :object) ~k ~@options))
; scroll-pane ; scroll-pane
(defn scroll-pane* (defn scroll-pane*
"The function version of `scroll-pane`"
[child arg] [child arg]
(ActorEntity. (ScrollPane. (u/get-obj child :object) arg))) (ActorEntity. (ScrollPane. (u/get-obj child :object) arg)))
(defmacro scroll-pane (defmacro scroll-pane
"Returns an entity based on [ScrollPane](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/ui/ScrollPane.html) "Returns an entity based on [ScrollPane](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/ui/ScrollPane.html).
(scroll-pane table-entity (style :scroll-pane back h h-knob v v-knob)) (scroll-pane table-entity (style :scroll-pane back h h-knob v v-knob))
(scroll-pane table-entity (skin \"uiskin.json\"))" (scroll-pane table-entity (skin \"uiskin.json\"))"
@@ -344,19 +331,18 @@ based on the file at `path`
entity#)) entity#))
(defmacro scroll-pane! (defmacro scroll-pane!
"Calls a single method on a `scroll-pane`" "Calls a single method on a `scroll-pane`."
[entity k & options] [entity k & options]
`(u/call! ^ScrollPane (u/get-obj ~entity :object) ~k ~@options)) `(u/call! ^ScrollPane (u/get-obj ~entity :object) ~k ~@options))
; select-box ; select-box
(defn select-box* (defn select-box*
"The function version of `select-box`"
[items arg] [items arg]
(ActorEntity. (SelectBox. (into-array items) arg))) (ActorEntity. (SelectBox. (into-array items) arg)))
(defmacro select-box (defmacro select-box
"Returns an entity based on [SelectBox](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/ui/SelectBox.html) "Returns an entity based on [SelectBox](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/ui/SelectBox.html).
(select-box [\"Item 1\" \"Item 2\" \"Item 3\"] (select-box [\"Item 1\" \"Item 2\" \"Item 3\"]
(style :select-box font color back scroll-style list-style)) (style :select-box font color back scroll-style list-style))
@@ -367,14 +353,13 @@ based on the file at `path`
entity#)) entity#))
(defmacro select-box! (defmacro select-box!
"Calls a single method on a `select-box`" "Calls a single method on a `select-box`."
[entity k & options] [entity k & options]
`(u/call! ^SelectBox (u/get-obj ~entity :object) ~k ~@options)) `(u/call! ^SelectBox (u/get-obj ~entity :object) ~k ~@options))
; slider ; slider
(defn slider* (defn slider*
"The function version of `slider`"
[{:keys [min max step vertical?] [{:keys [min max step vertical?]
:or {min 0 max 10 step 1 vertical? false}} :or {min 0 max 10 step 1 vertical? false}}
arg] arg]
@@ -382,7 +367,7 @@ based on the file at `path`
(Slider. (float min) (float max) (float step) vertical? arg))) (Slider. (float min) (float max) (float step) vertical? arg)))
(defmacro slider (defmacro slider
"Returns an entity based on [Slider](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/ui/Slider.html) "Returns an entity based on [Slider](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/ui/Slider.html).
(slider {:min 0 :max 10 :step 1 :vertical? false} (style :slider back knob)) (slider {:min 0 :max 10 :step 1 :vertical? false} (style :slider back knob))
(slider {:min 0 :max 10 :step 1 :vertical? false} (skin \"uiskin.json\"))" (slider {:min 0 :max 10 :step 1 :vertical? false} (skin \"uiskin.json\"))"
@@ -392,19 +377,18 @@ based on the file at `path`
entity#)) entity#))
(defmacro slider! (defmacro slider!
"Calls a single method on a `slider`" "Calls a single method on a `slider`."
[entity k & options] [entity k & options]
`(u/call! ^Slider (u/get-obj ~entity :object) ~k ~@options)) `(u/call! ^Slider (u/get-obj ~entity :object) ~k ~@options))
; stack ; stack
(defn stack* (defn stack*
"The function version of `stack`"
[children] [children]
(create-group (Stack.) children)) (create-group (Stack.) children))
(defmacro stack (defmacro stack
"Returns an entity based on [Stack](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/ui/Stack.html) "Returns an entity based on [Stack](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/ui/Stack.html).
(stack [entity-1 entity-2])" (stack [entity-1 entity-2])"
[children & options] [children & options]
@@ -413,19 +397,18 @@ based on the file at `path`
entity#)) entity#))
(defmacro stack! (defmacro stack!
"Calls a single method on a `stack`" "Calls a single method on a `stack`."
[entity k & options] [entity k & options]
`(u/call! ^Stack (u/get-obj ~entity :object) ~k ~@options)) `(u/call! ^Stack (u/get-obj ~entity :object) ~k ~@options))
; table ; table
(defn table* (defn table*
"The function version of `table`"
[children] [children]
(create-group (Table.) children)) (create-group (Table.) children))
(defmacro table (defmacro table
"Returns an entity based on [Table](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/ui/Table.html) "Returns an entity based on [Table](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/ui/Table.html).
(table [entity-1 entity-2])" (table [entity-1 entity-2])"
[children & options] [children & options]
@@ -434,19 +417,18 @@ based on the file at `path`
entity#)) entity#))
(defmacro table! (defmacro table!
"Calls a single method on a `table`" "Calls a single method on a `table`."
[entity k & options] [entity k & options]
`(u/call! ^Table (u/get-obj ~entity :object) ~k ~@options)) `(u/call! ^Table (u/get-obj ~entity :object) ~k ~@options))
; text-button ; text-button
(defn text-button* (defn text-button*
"The function version of `text-button`"
[^String text arg] [^String text arg]
(ActorEntity. (TextButton. text arg))) (ActorEntity. (TextButton. text arg)))
(defmacro text-button (defmacro text-button
"Returns an entity based on [TextButton](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/ui/TextButton.html) "Returns an entity based on [TextButton](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/ui/TextButton.html).
(text-button \"I'm a text button\" (style :text-button up dn checked font)) (text-button \"I'm a text button\" (style :text-button up dn checked font))
(text-button \"I'm a text button\" (skin \"uiskin.json\"))" (text-button \"I'm a text button\" (skin \"uiskin.json\"))"
@@ -456,19 +438,18 @@ based on the file at `path`
entity#)) entity#))
(defmacro text-button! (defmacro text-button!
"Calls a single method on a `text-button`" "Calls a single method on a `text-button`."
[entity k & options] [entity k & options]
`(u/call! ^TextButton (u/get-obj ~entity :object) ~k ~@options)) `(u/call! ^TextButton (u/get-obj ~entity :object) ~k ~@options))
; text-field ; text-field
(defn text-field* (defn text-field*
"The function version of `text-field`"
[^String text arg] [^String text arg]
(ActorEntity. (TextField. text arg))) (ActorEntity. (TextField. text arg)))
(defmacro text-field (defmacro text-field
"Returns an entity based on [TextField](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/ui/TextField.html) "Returns an entity based on [TextField](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/ui/TextField.html).
(text-field \"I'm a text field\" (style :text-field font col cur sel back)) (text-field \"I'm a text field\" (style :text-field font col cur sel back))
(text-field \"I'm a text field\" (skin \"uiskin.json\"))" (text-field \"I'm a text field\" (skin \"uiskin.json\"))"
@@ -478,19 +459,18 @@ based on the file at `path`
entity#)) entity#))
(defmacro text-field! (defmacro text-field!
"Calls a single method on a `text-field`" "Calls a single method on a `text-field`."
[entity k & options] [entity k & options]
`(u/call! ^TextField (u/get-obj ~entity :object) ~k ~@options)) `(u/call! ^TextField (u/get-obj ~entity :object) ~k ~@options))
; tree ; tree
(defn tree* (defn tree*
"The function version of `tree`"
[children arg] [children arg]
(create-group (Tree. arg) children)) (create-group (Tree. arg) children))
(defmacro tree (defmacro tree
"Returns an entity based on [Tree](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/ui/Tree.html) "Returns an entity based on [Tree](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/ui/Tree.html).
(tree [entity-1 entity-2] (style :tree plus minus selection)) (tree [entity-1 entity-2] (style :tree plus minus selection))
(tree [entity-1 entity-2] (skin \"uiskin.json\"))" (tree [entity-1 entity-2] (skin \"uiskin.json\"))"
@@ -500,19 +480,18 @@ based on the file at `path`
entity#)) entity#))
(defmacro tree! (defmacro tree!
"Calls a single method on a `tree`" "Calls a single method on a `tree`."
[entity k & options] [entity k & options]
`(u/call! ^Tree (u/get-obj ~entity :object) ~k ~@options)) `(u/call! ^Tree (u/get-obj ~entity :object) ~k ~@options))
; vertical ; vertical
(defn vertical* (defn vertical*
"The function version of `vertical`"
[children] [children]
(create-group (VerticalGroup.) children)) (create-group (VerticalGroup.) children))
(defmacro vertical (defmacro vertical
"Returns an entity based on [VerticalGroup](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/ui/VerticalGroup.html) "Returns an entity based on [VerticalGroup](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/ui/VerticalGroup.html).
(vertical [entity-1 entity-2])" (vertical [entity-1 entity-2])"
[children & options] [children & options]
@@ -521,19 +500,18 @@ based on the file at `path`
entity#)) entity#))
(defmacro vertical! (defmacro vertical!
"Calls a single method on a `vertical`" "Calls a single method on a `vertical`."
[entity k & options] [entity k & options]
`(u/call! ^VerticalGroup (u/get-obj ~entity :object) ~k ~@options)) `(u/call! ^VerticalGroup (u/get-obj ~entity :object) ~k ~@options))
; window ; window
(defn window* (defn window*
"The function version of `window`"
[children ^String title arg] [children ^String title arg]
(create-group (Window. title arg) children)) (create-group (Window. title arg) children))
(defmacro window (defmacro window
"Returns an entity based on [Window](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/ui/Window.html) "Returns an entity based on [Window](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/ui/Window.html).
(window [entity-1 entity-2] \"I'm a window\" (style :window title font col)) (window [entity-1 entity-2] \"I'm a window\" (style :window title font col))
(window [entity-1 entity-2] \"I'm a window\" (skin \"uiskin.json\"))" (window [entity-1 entity-2] \"I'm a window\" (skin \"uiskin.json\"))"
@@ -543,6 +521,6 @@ based on the file at `path`
entity#)) entity#))
(defmacro window! (defmacro window!
"Calls a single method on a `window`" "Calls a single method on a `window`."
[entity k & options] [entity k & options]
`(u/call! ^Window (u/get-obj ~entity :object) ~k ~@options)) `(u/call! ^Window (u/get-obj ~entity :object) ~k ~@options))

View File

@@ -5,12 +5,10 @@
; misc ; misc
(defn throw-key-not-found (defn throw-key-not-found
"Internal use only"
[k] [k]
(throw (Exception. (str "The keyword " k " is not found.")))) (throw (Exception. (str "The keyword " k " is not found."))))
(defn get-obj (defn get-obj
"Internal use only"
[obj k] [obj k]
(if (map? obj) (if (map? obj)
(or (get obj k) (or (get obj k)
@@ -22,31 +20,29 @@
(def ^:const main-package "com.badlogic.gdx") (def ^:const main-package "com.badlogic.gdx")
(defn ^:private split-key (defn ^:private split-key
"Internal use only"
[k] [k]
(-> k name (s/split #"-"))) (-> k name (s/split #"-")))
(defn ^:private join-keys (defn ^:private join-keys
"Internal use only"
[k-list] [k-list]
(->> k-list (map name) (s/join "."))) (->> k-list (map name) (s/join ".")))
(defn key->upper (defn key->upper
"Returns a string based on keyword `k` with upper case and underscores" "Returns a string based on keyword `k` with upper case and underscores."
[k] [k]
(->> (split-key k) (->> (split-key k)
(map s/upper-case) (map s/upper-case)
(s/join "_"))) (s/join "_")))
(defn key->pascal (defn key->pascal
"Returns a string based on keyword `k` with pascal case and no delimiters" "Returns a string based on keyword `k` with pascal case and no delimiters."
[k] [k]
(->> (split-key k) (->> (split-key k)
(map s/capitalize) (map s/capitalize)
(s/join ""))) (s/join "")))
(defn key->camel (defn key->camel
"Returns a string based on keyword `k` with camel case and no delimiters" "Returns a string based on keyword `k` with camel case and no delimiters."
[k] [k]
(let [parts (split-key k)] (let [parts (split-key k)]
(->> (rest parts) (->> (rest parts)
@@ -55,44 +51,42 @@
(s/join "")))) (s/join ""))))
(defn key->method (defn key->method
"Returns a symbol based on keyword `k` formatted as a method call" "Returns a symbol based on keyword `k` formatted as a method call."
[k] [k]
(symbol (str "." (key->camel k)))) (symbol (str "." (key->camel k))))
; classes/methods/fields ; classes/methods/fields
(defn ^:private add-divider (defn ^:private add-divider
"Internal use only"
[args divider] [args divider]
(let [[a1 a2] (take-last 2 args)] (let [[a1 a2] (take-last 2 args)]
(conj (vec (drop-last 2 args)) (str (name a1) divider (name a2))))) (conj (vec (drop-last 2 args)) (str (name a1) divider (name a2)))))
(defn gdx (defn gdx
"Returns a fully-qualified LibGDX symbol" "Returns a fully-qualified LibGDX symbol."
[& args] [& args]
(symbol (str main-package "." (join-keys args)))) (symbol (str main-package "." (join-keys args))))
(defn gdx-field (defn gdx-field
"Returns a fully-qualified LibGDX static method or field" "Returns a fully-qualified LibGDX static method or field."
[& args] [& args]
(apply gdx (add-divider args "/"))) (apply gdx (add-divider args "/")))
(defn gdx-class (defn gdx-class
"Returns a fully-qualified LibGDX static class" "Returns a fully-qualified LibGDX static class."
[& args] [& args]
(apply gdx (add-divider args "$"))) (apply gdx (add-divider args "$")))
; java interop ; java interop
(defmacro call! (defmacro call!
"Calls method `k` of `obj` with `args` "Calls method `k` of `obj` with `args`.
(call! \"I'm a string\" :index-of \"s\")" (call! \"I'm a string\" :index-of \"s\")"
[obj k & args] [obj k & args]
`(~(key->method k) ~obj ~@args)) `(~(key->method k) ~obj ~@args))
(defn create-method-calls (defn create-method-calls
"Internal use only"
[calls args] [calls args]
(let [method-name (first args) (let [method-name (first args)
[my-args rest-args] (split-with #(not (keyword? %)) (rest args))] [my-args rest-args] (split-with #(not (keyword? %)) (rest args))]
@@ -102,14 +96,13 @@
calls))) calls)))
(defmacro calls! (defmacro calls!
"Calls methods on `obj` "Calls methods on `obj`.
(calls! (java.util.ArrayList.) :add \"I'm a string\" :add \"So am I\")" (calls! (java.util.ArrayList.) :add \"I'm a string\" :add \"So am I\")"
[obj & args] [obj & args]
`(doto ~obj ~@(create-method-calls [] args))) `(doto ~obj ~@(create-method-calls [] args)))
(defn create-field-setters (defn create-field-setters
"Internal use only"
[obj {:keys [] :as args}] [obj {:keys [] :as args}]
(map (fn [[k v]] (map (fn [[k v]]
`(set! (. ~obj ~(symbol (key->camel k))) ~v)) `(set! (. ~obj ~(symbol (key->camel k))) ~v))
@@ -118,7 +111,7 @@
(defmacro fields! (defmacro fields!
"Sets fields on `obj` (it is important that `obj` is a symbol, because when "Sets fields on `obj` (it is important that `obj` is a symbol, because when
the macro expands it will use it several times, and you probably don't want a the macro expands it will use it several times, and you probably don't want a
new object to be created each time a field is set) new object to be created each time a field is set).
(fields! obj (fields! obj
:active true :active true
@@ -132,24 +125,22 @@ new object to be created each time a field is set)
; data structures ; data structures
(defn gdx-array* (defn gdx-array*
"The function version of `gdx-array`"
[clj-arr] [clj-arr]
(Array. true (into-array clj-arr) 1 (count clj-arr))) (Array. true (into-array clj-arr) 1 (count clj-arr)))
(defmacro gdx-array (defmacro gdx-array
"Returns an [Array](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/utils/Array.html) "Returns an [Array](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/utils/Array.html).
(gdx-array [1 2 3 4])" (gdx-array [1 2 3 4])"
[clj-arr & options] [clj-arr & options]
`(calls! ^Array (gdx-array* ~clj-arr) ~@options)) `(calls! ^Array (gdx-array* ~clj-arr) ~@options))
(defmacro gdx-array! (defmacro gdx-array!
"Calls a single method on a `gdx-array`" "Calls a single method on a `gdx-array`."
[object k & options] [object k & options]
`(call! ^Array ~object ~k ~@options)) `(call! ^Array ~object ~k ~@options))
(defn gdx-array-map* (defn gdx-array-map*
"The function version of `gdx-array-map`"
[clj-map] [clj-map]
(let [gdx-map (ArrayMap.)] (let [gdx-map (ArrayMap.)]
(doseq [[k v] clj-map] (doseq [[k v] clj-map]
@@ -157,13 +148,13 @@ new object to be created each time a field is set)
gdx-map)) gdx-map))
(defmacro gdx-array-map (defmacro gdx-array-map
"Returns an [ArrayMap](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/utils/ArrayMap.html) "Returns an [ArrayMap](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/utils/ArrayMap.html).
(gdx-array-map {:key-1 1 :key-2 2})" (gdx-array-map {:key-1 1 :key-2 2})"
[clj-map & options] [clj-map & options]
`(calls! ^ArrayMap (gdx-array-map* ~clj-map) ~@options)) `(calls! ^ArrayMap (gdx-array-map* ~clj-map) ~@options))
(defmacro gdx-array-map! (defmacro gdx-array-map!
"Calls a single method on a `gdx-array-map`" "Calls a single method on a `gdx-array-map`."
[object k & options] [object k & options]
`(call! ^ArrayMap ~object ~k ~@options)) `(call! ^ArrayMap ~object ~k ~@options))