oakes / play-clj

A Clojure game library
The Unlicense
940 stars 72 forks source link

Urgent: key-code accepts symbols as arguments #104

Closed ghost closed 7 years ago

ghost commented 7 years ago

Source:

(defmacro key-code
  [k]
  (u/gdx-field "Input$Keys" (u/key->upper k)))

Suppose you invoke (key-code :w) you will get 51 as expected

Now suppose you invoke (key-code w) and have or haven't bound w to anything. You get 51. This isn't expected.

Because the macro parses symbols, its impossible to wrap a function around it. For instance:

[(key-code :a) (key-code :b) (key-code :c) (key-code :d)]
[29 30 31 32]
 (map (fn [a] (key-code a)) [:a :b :c :d])
[29 29 29 29]
ghost commented 7 years ago

Pull request for fix: #106