Make is-pressed? work with all keys

This commit is contained in:
oakes
2014-01-09 22:46:57 -05:00
parent 9bb4f0a1e4
commit f631626060
4 changed files with 34 additions and 39 deletions

View File

@@ -20,6 +20,8 @@
[& options]
`(BitmapFont. ~@options))
; input/output
(defn game
[key]
(case key
@@ -32,19 +34,8 @@
:y (.getY (Gdx/input))
nil))
; input
(defn resolve-key
[key]
(if (keyword? key)
(case key
:up Input$Keys/DPAD_UP
:down Input$Keys/DPAD_DOWN
:left Input$Keys/DPAD_LEFT
:right Input$Keys/DPAD_RIGHT
nil)
key))
(defmacro is-pressed?
[key]
`(.isKeyPressed (Gdx/input) ~(resolve-key key)))
`(.isKeyPressed (Gdx/input)
~(symbol (str utils/gdx-package ".Input$Keys/"
(utils/key->static-field key)))))