 (ns clj-mini-apps.pong
-	(:require [quil.core :as q :include-macros true]
+  (:require [quil.core :as q :include-macros true]
             [quil.middleware :as m]
             [jayq.core :refer [$]]
-	          [jayq.util :refer [log]]))
+            [jayq.util :refer [log]]))
 
 (defn ^:export init []
   (when (and js/document (.-getElementById js/document))

  :key-pressed handle-input
  :draw draw-game
  :update update-game
  :middleware [m/fun-mode])
  (if (= 2 (count (:ball state)))
    (as-> state state
      (assoc-in state [:ball :x-dir] (rand-nth [+ -]))
      (assoc-in state [:ball :y-dir] (rand-nth [+ -]))
      (update-ball state))
    state))

(defn update-ball
  [state]
  ;(log "update-ball")
  (if (:is-running? state)
    (as-> state state
      (update-in state [:ball :y] (:y-dir (:ball state)) ball-speed)
      (update-in state [:ball :x] (:x-dir (:ball state)) ball-speed))
