From 7a4e126b3dd923c9df7ad09287ff1d677b97595f Mon Sep 17 00:00:00 2001 From: oakes Date: Sun, 19 Jan 2014 22:21:14 -0500 Subject: [PATCH] Add more docstrings --- src/play_clj/core.clj | 5 +++-- src/play_clj/core_global.clj | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/src/play_clj/core.clj b/src/play_clj/core.clj index 571d0bd..20dd3e5 100644 --- a/src/play_clj/core.clj +++ b/src/play_clj/core.clj @@ -74,7 +74,7 @@ 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 - (defscreen text-screen + (defscreen main-screen :on-show (fn [screen entities] (update! screen :renderer (stage)) @@ -136,7 +136,8 @@ object, sets it as the screen for the `game`, and runs the functions from (defn update! "Runs the equivalent of `(swap! screen-atom assoc ...)`, where `screen-atom` -is the atom storing the screen map behind the scenes +is the atom storing the screen map behind the scenes, and returns the new screen +map (update! screen :renderer (stage)) " diff --git a/src/play_clj/core_global.clj b/src/play_clj/core_global.clj index f790117..2bed469 100644 --- a/src/play_clj/core_global.clj +++ b/src/play_clj/core_global.clj @@ -3,6 +3,11 @@ ; graphics (defn clear! + "Clears the screen with a uniform color, defaulting to black + + (clear!) + (clear! 0.5 0.5 1 1) +" ([] (clear! 0 0 0 0)) ([r g b a] @@ -11,6 +16,8 @@ (.glClear GL20/GL_COLOR_BUFFER_BIT)))) (defmacro color + "Returns a [Color](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/Color.html) +object" [& args] `~(if (keyword? (first args)) `(Color. ^Color (u/static-field-upper :graphics :Color ~(first args))) @@ -19,30 +26,58 @@ ; interop (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!\") +" [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) +" [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\") +" [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) +" [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) +" [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) +" [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/\") +" [k & options] `(u/call! ^Net (Gdx/net) ~k ~@options))