diff --git a/src/play_clj/core.clj b/src/play_clj/core.clj index 9c65840..b9c1c54 100644 --- a/src/play_clj/core.clj +++ b/src/play_clj/core.clj @@ -98,8 +98,7 @@ object" object, sets it as the screen for the `game`, and runs the functions from `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] (let [add-inputs! (fn [] (input! :set-input-processor (InputMultiplexer.)) @@ -123,7 +122,6 @@ object, sets it as the screen for the `game`, and runs the functions from is the atom storing the screen map behind the scenes, and returns the new screen map - (update! screen :renderer (stage)) -" + (update! screen :renderer (stage))" [{:keys [update-fn!]} & {:keys [] :as args}] (update-fn! args)) diff --git a/src/play_clj/core_global.clj b/src/play_clj/core_global.clj index 60f7aa0..ad1771e 100644 --- a/src/play_clj/core_global.clj +++ b/src/play_clj/core_global.clj @@ -6,8 +6,7 @@ "Clears the screen with a uniform color, defaulting to black (clear!) - (clear! 0.5 0.5 1 1) -" + (clear! 0.5 0.5 1 1)" ([] (clear! 0 0 0 0)) ([r g b a] @@ -19,8 +18,7 @@ "Returns a [Color](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/Color.html) (color :white) - (color 1 1 1 1) -" + (color 1 1 1 1)" [& args] `~(if (keyword? (first args)) `(Color. ^Color (u/static-field-upper :graphics :Color ~(first args))) @@ -31,56 +29,49 @@ (defmacro app! "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] `(u/call! ^Application (Gdx/app) ~k ~@options)) (defmacro audio! "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] `(u/call! ^Audio (Gdx/audio) ~k ~@options)) (defmacro files! "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] `(u/call! ^Files (Gdx/files) ~k ~@options)) (defmacro gl! "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] `(u/call! ^GL20 (Gdx/gl20) ~k ~@options)) (defmacro graphics! "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] `(u/call! ^Graphics (Gdx/graphics) ~k ~@options)) (defmacro input! "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] `(u/call! ^Input (Gdx/input) ~k ~@options)) (defmacro net! "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] `(u/call! ^Net (Gdx/net) ~k ~@options)) @@ -90,8 +81,7 @@ "Calls the global method cooresponding to `k` in a more Clojuresque way (game :width) - (game :is-touched?) -" + (game :is-touched?)" [k] (case k :width (graphics! :get-width) @@ -107,8 +97,7 @@ "Returns the static field cooresponding to `k` from [Input.Keys](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/Input.Keys.html) (key-code :a) - (key-code :page-down) -" + (key-code :page-down)" [k] `~(symbol (str u/main-package ".Input$Keys/" (u/key->upper k)))) @@ -116,8 +105,7 @@ "Returns a boolean indicating if the key cooresponding to `k` is being pressed (is-pressed? :a) - (is-pressed? :page-down) -" + (is-pressed? :page-down)" [k] `(input! :is-key-pressed (key-code ~k))) diff --git a/src/play_clj/core_graphics.clj b/src/play_clj/core_graphics.clj index 942279d..0ac6229 100644 --- a/src/play_clj/core_graphics.clj +++ b/src/play_clj/core_graphics.clj @@ -19,8 +19,7 @@ macros that create the renderers will call this themselves)" (defmacro tiled-map! "Calls a single method on a `tiled-map` - (tiled-map! screen :get-layers) -" + (tiled-map! screen :get-layers)" [screen k & options] `(let [^BatchTiledMapRenderer object# (u/get-obj ~screen :renderer)] (u/call! ^TiledMap (.getMap object#) ~k ~@options))) @@ -29,8 +28,7 @@ macros that create the renderers will call this themselves)" "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` - (tiled-map-layers screen) -" + (tiled-map-layers screen)" [screen] (let [^BatchTiledMapRenderer renderer (u/get-obj screen :renderer) ^MapLayers layers (-> renderer .getMap .getLayers)] @@ -50,8 +48,7 @@ objects cooresponding to each layer in the tiled map in `screen` "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` - (tiled-map-layer screen \"water\") -" + (tiled-map-layer screen \"water\")" [screen layer & options] `(let [^TiledMapTileLayer object# (tiled-map-layer* ~screen ~layer)] (u/calls! object# ~@options))) @@ -60,8 +57,7 @@ from the tiled map in `screen` that matches `layer` "Calls a single method on a `tiled-map-layer` (tiled-map-layer! (tiled-map-layer screen \"water\") - :set-cell 0 0 nil) -" + :set-cell 0 0 nil)" [object k & options] `(u/call! ^TiledMapTileLayer (cast TiledMapTileLayer ~object) ~k ~@options)) @@ -74,8 +70,7 @@ from the tiled map in `screen` that matches `layer` "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` - (tiled-map-cell screen \"water\" 0 0) -" + (tiled-map-cell screen \"water\" 0 0)" [screen layer x y & options] `(let [^TiledMapTileLayer$Cell object# (tiled-map-cell* ~screen ~layer ~x ~y)] (u/calls! object# ~@options))) @@ -84,8 +79,7 @@ from the tiled map in `screen` from the given `layer` and position `x` and `y` "Calls a single method on a `tiled-map-cell` (tiled-map-cell! (tiled-map-cell screen \"water\" 0 0) - :set-rotation 90) -" + :set-rotation 90)" [object k & options] `(u/call! ^TiledMapTileLayer$Cell ~object ~k ~@options)) @@ -100,8 +94,7 @@ from the tiled map in `screen` from the given `layer` and position `x` and `y` "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 - (orthogonal-tiled-map \"level1.tmx\" (/ 1 8)) -" + (orthogonal-tiled-map \"level1.tmx\" (/ 1 8))" [path unit & options] `(u/calls! ^OrthogonalTiledMapRenderer (orthogonal-tiled-map* ~path ~unit) ~@options)) @@ -121,8 +114,7 @@ with the tiled map file at `path` and `unit` scale "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 - (isometric-tiled-map \"level1.tmx\" (/ 1 8)) -" + (isometric-tiled-map \"level1.tmx\" (/ 1 8))" [path unit & options] `(u/calls! ^IsometricTiledMapRenderer (isometric-tiled-map* ~path ~unit) ~@options)) @@ -143,8 +135,7 @@ with the tiled map file at `path` and `unit` scale "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 - (isometric-staggered-tiled-map \"level1.tmx\" (/ 1 8)) -" + (isometric-staggered-tiled-map \"level1.tmx\" (/ 1 8))" [path unit & options] `(u/calls! ^IsometricStaggeredTiledMapRenderer (isometric-staggered-tiled-map* ~path ~unit) @@ -166,8 +157,7 @@ with the tiled map file at `path` and `unit` scale "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 - (hexagonal-tiled-map \"level1.tmx\" (/ 1 8)) -" + (hexagonal-tiled-map \"level1.tmx\" (/ 1 8))" [path unit & options] `(u/calls! ^HexagonalTiledMapRenderer (hexagonal-tiled-map* ~path ~unit) ~@options)) @@ -186,8 +176,7 @@ with the tiled map file at `path` and `unit` scale (defmacro stage "Returns a [Stage](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/Stage.html) - (stage) -" + (stage)" [& options] `(u/calls! ^Stage (stage*) ~@options)) @@ -243,8 +232,7 @@ with the tiled map file at `path` and `unit` scale (defn draw! "Draws the `entities` with the renderer from `screen` - (draw! screen entities) -" + (draw! screen entities)" [{:keys [renderer] :as screen} entities] (assert renderer) (let [^SpriteBatch batch (batch screen)] @@ -272,8 +260,7 @@ with the tiled map file at `path` and `unit` scale "Calls the renderer from `screen` and optionally draws and returns the `entities` - (render! screen entities) -" + (render! screen entities)" ([{:keys [renderer] :as screen}] (cond (isa? (type renderer) BatchTiledMapRenderer) @@ -294,8 +281,7 @@ with the tiled map file at `path` and `unit` scale (defmacro orthographic "Returns an [OrthographicCamera](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/OrthographicCamera.html) - (orthographic) -" + (orthographic)" [& options] `(let [^OrthographicCamera object# (orthographic*)] (u/calls! object# ~@options))) @@ -314,8 +300,7 @@ with the tiled map file at `path` and `unit` scale (defmacro perspective "Returns an [PerspectiveCamera](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/PerspectiveCamera.html) - (perspective) -" + (perspective)" [& options] `(let [^PerspectiveCamera object# (perspective*)] (u/calls! object# ~@options))) @@ -329,8 +314,7 @@ with the tiled map file at `path` and `unit` scale (defn size! "Sets the size of the camera in `screen` - (size! screen 480 360) -" + (size! screen 480 360)" [screen width height] (let [^OrthographicCamera camera (u/get-obj screen :camera)] (assert camera) @@ -340,8 +324,7 @@ with the tiled map file at `path` and `unit` scale "Sets the width of the camera in `screen`, adjusting the height so the ratio remains in tact - (width! screen 480) -" + (width! screen 480)" [screen new-width] (size! screen new-width (* new-width (/ (game :height) (game :width))))) @@ -349,8 +332,7 @@ remains in tact "Sets the height of the camera in `screen`, adjusting the width so the ratio remains in tact - (height! screen 360) -" + (height! screen 360)" [screen new-height] (size! screen (* new-height (/ (game :width) (game :height))) new-height)) diff --git a/src/play_clj/g2d.clj b/src/play_clj/g2d.clj index 8fbacbb..c757161 100644 --- a/src/play_clj/g2d.clj +++ b/src/play_clj/g2d.clj @@ -7,8 +7,7 @@ "Returns a [BitmapFont](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/g2d/BitmapFont.html) (bitmap-font) - (bitmap-font file-handle region) -" + (bitmap-font file-handle region)" [& options] `(BitmapFont. ~@options)) @@ -31,8 +30,7 @@ (texture \"image.png\" :flip true false) (texture \"image.png\" :flip true false - :set-region 0 0 100 100) -" + :set-region 0 0 100 100)" [arg & options] `(let [entity# (texture* ~arg)] (u/calls! ^TextureRegion (u/get-obj entity# :object) ~@options) @@ -42,8 +40,7 @@ "Calls a single method on a `texture` (texture! entity :flip true false) - (texture! entity :get-region-width) -" + (texture! entity :get-region-width)" [entity k & options] `(u/call! ^TextureRegion (u/get-obj ~entity :object) ~k ~@options)) @@ -55,8 +52,7 @@ (play-mode :loop-random) (play-mode :loop-reversed) (play-mode :normal) - (play-mode :reversed) -" + (play-mode :reversed)" [key] `(u/static-field-upper :graphics :g2d :Animation ~key)) @@ -72,16 +68,14 @@ (animation 0.2 [walk-1 walk-2 walk-3] - :set-play-mode (play-mode :loop-pingpong)) -" + :set-play-mode (play-mode :loop-pingpong))" [duration textures & options] `(u/calls! ^Animation (animation* ~duration ~textures) ~@options)) (defmacro 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] `(u/call! ^Animation ~object ~k ~@options)) @@ -89,8 +83,7 @@ "Returns a `texture` entity with a frame from `animation` based on the total time the `screen` has been showing - (animation->texture screen anim) -" + (animation->texture screen anim)" ([{:keys [total-time]} ^Animation animation] (texture* (.getKeyFrame animation total-time true))) ([{:keys [total-time]} ^Animation animation is-looping?] diff --git a/src/play_clj/g2d_physics.clj b/src/play_clj/g2d_physics.clj index 83cb9bd..72178e7 100644 --- a/src/play_clj/g2d_physics.clj +++ b/src/play_clj/g2d_physics.clj @@ -19,8 +19,7 @@ (defmacro box-2d "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] `(let [^World object# (box-2d* ~gravity-x ~gravity-y)] (u/calls! object# ~@options))) @@ -42,8 +41,7 @@ (defmacro body-def "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] `(let [^BodyDef object# (BodyDef.)] (set! (. object# type) ~(body-type k)) @@ -113,8 +111,7 @@ (defmacro joint-def "Returns a [JointDef](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/physics/box2d/JointDef.html) - (joint-def :rope) -" + (joint-def :rope)" [k & options] `(let [object# (~(joint-init k))] (u/fields! object# ~@options)))