<commit_before>(in-ns 'play-clj.core)

; graphics

(defn clear!
  ([] (clear! 0 0 0 0))
  ([r g b a]
    (doto (Gdx/gl)
      (.glClearColor r g b a)
      (.glClear GL20/GL_COLOR_BUFFER_BIT))))

(defn game*
  [key]
  (case key
    :width `(.getWidth (Gdx/graphics))
    :height `(.getHeight (Gdx/graphics))
    :is-fullscreen? `(.isFullscreen (Gdx/graphics))
    :is-touched? `(.isTouched (Gdx/input))
    :x `(.getX (Gdx/input))
    :y `(.getY (Gdx/input))
    nil))

(defmacro game
  [key]
  `~(game* key))

; 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))

(defn resolve-touch
  [key]
  (case key
    :down `(> (game :y) (* (game :height) (/ 2 3)))
    :up `(< (game :y) (/ (game :height) 3))
    :left `(< (game :x) (/ (game :width) 3))
    :right `(> (game :x) (* (game :width) (/ 2 3)))
    false))

(defmacro is-pressed?
  [key]
  `(.isKeyPressed (Gdx/input) ~(resolve-key key)))

(defmacro is-touched?
  ([]
    `(game :is-touched?))
  ([key]
    `(and (game :is-touched?) ~(resolve-touch key))))<commit_msg>Remove unnecessary duplication<commit_after>(in-ns 'play-clj.core)

; graphics

(defn clear!
  ([] (clear! 0 0 0 0))
  ([r g b a]
    (doto (Gdx/gl)
      (.glClearColor r g b a)
      (.glClear GL20/GL_COLOR_BUFFER_BIT))))

(defn game*
  [key]
  (case key
    :width `(.getWidth (Gdx/graphics))
    :height `(.getHeight (Gdx/graphics))
    :is-fullscreen? `(.isFullscreen (Gdx/graphics))
    :x `(.getX (Gdx/input))
    :y `(.getY (Gdx/input))
    nil))

(defmacro game
  [key]
  `~(game* key))

; 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))

(defn resolve-touch
  [key]
  (case key
    :down `(> (game :y) (* (game :height) (/ 2 3)))
    :up `(< (game :y) (/ (game :height) 3))
    :left `(< (game :x) (/ (game :width) 3))
    :right `(> (game :x) (* (game :width) (/ 2 3)))
    false))

(defmacro is-pressed?
  [key]
  `(.isKeyPressed (Gdx/input) ~(resolve-key key)))

(defmacro is-touched?
  ([]
    `(.isTouched (Gdx/input)))
  ([key]
    `(and (is-touched?) ~(resolve-touch key))))
{'fraction_non_alphanumeric': 0.20416843896214376, 'fraction_numerical': 0.010208421948107189, 'mean_word_length': 2.7274167987321714, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3926240', 'n_tokens_mistral': 1054, 'n_tokens_neox': 976, 'n_words': 237}