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


(defn move-player-paddle
  [state direction]
  ;(log "move-player-paddle")
  (if (= direction :down)
    (update-in state [:player :y] + speed)
    (update-in state [:player :y] - speed)))

(defn start-game
  [state]
  ;(log "start-game")
  (if (= 2 (count (:ball state)))
    (as-> state state
      (assoc-in state [:ball :x-dir] (rand-nth [+ -]))

(defn on-collision [state]
  (let [ball-x (:x (:ball state))
        ball-y (:y (:ball state))
        top-wall (+ 2 (+ 9 7.5))
        btm-wall (- (- 490 7.5) 2)
        not-dir #({+ -, - +} %)]
    (cond
      ;;check w/ top/btm walls
      (not (and (> ball-y top-wall)
                (< ball-y btm-wall)))
      (update-in state [:ball :y-dir] not-dir)

      ;;check w/ player paddle
      (< ball-x (+ (:x (:player state))
                   paddle-width))
      (update-in state [:ball :x-dir] not-dir)

      ;;check w/ cpu paddle
      (> ball-x (- (:x (:computer state))
                   paddle-width))
      (update-in state [:ball :x-dir] not-dir)

      :else state)))

(defn draw-game
  [state]
  (do
    (q/rect-mode :corner)
    (q/fill 255)
