Skip to content

Instantly share code, notes, and snippets.

@swannodette
Created November 11, 2013 20:08
Show Gist options
  • Save swannodette/7419486 to your computer and use it in GitHub Desktop.
Save swannodette/7419486 to your computer and use it in GitHub Desktop.
(defn computer-down? [{{computer-y :y} :computer
{ball-y :y} :ball player-height :player-height :as state}]
(and (> (- computer-y 20) ball-y) (>= (- computer-y (/ player-height 2)) 0)))
;; vs.
(defn computer-down? [{:keys [ball computer] :as st}]
(let [cy (:y computer)]
(and (> (- cy 20) (:y ball))
(>= (- cy (/ (:player-height st) 2)) 0))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment