Improve body functions and allow graphics macros to work on both the screen and the objects themselves

This commit is contained in:
oakes
2014-01-17 18:11:37 -05:00
parent 6b1eda86c8
commit b703780089
5 changed files with 69 additions and 43 deletions

View File

@@ -49,8 +49,8 @@
; input/output
(defn game
[key]
(case key
[k]
(case k
:width (graphics! :get-width)
:height (graphics! :get-height)
:fps (graphics! :get-frames-per-second)
@@ -58,15 +58,15 @@
:is-touched? (input! :is-touched)
:x (input! :get-x)
:y (input! :get-y)
nil))
(u/throw-key-not-found k)))
(defmacro key-code
[key]
`~(symbol (str u/main-package ".Input$Keys/" (u/key->upper key))))
[k]
`~(symbol (str u/main-package ".Input$Keys/" (u/key->upper k))))
(defmacro is-pressed?
[key]
`(input! :is-key-pressed (key-code ~key)))
[k]
`(input! :is-key-pressed (key-code ~k)))
(defn ^:private input-processor
[{:keys [on-key-down on-key-typed on-key-up on-mouse-moved