Skip to content

Instantly share code, notes, and snippets.

@duncanmak
Created February 4, 2010 21:41
Show Gist options
  • Save duncanmak/295146 to your computer and use it in GitHub Desktop.
Save duncanmak/295146 to your computer and use it in GitHub Desktop.
(defn calculate-offset [value file s r c]
(println "Calculating offset for" (.getName file) "at" [s r c])
(if-let [tile (get-tile s r c)]
(really-calculate-offset file (:file tile))
(do (Thread/sleep 60000)
(recur value file s r c))))
(defn make-offset [file sec row col]
(let [->offset #(calculate-offset %1 file sec %2 %3)
row-1 (dec row) row+1 (inc row)
col-1 (dec col) col+1 (inc col)]
(struct-map Offset
:north (send (agent []) ->offset row-1 col)
:south (send (agent []) ->offset row+1 col)
:east (send (agent []) ->offset row col+1)
:west (send (agent []) ->offset row col-1))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment