 
 (defn fov [character]
   (let [{:keys [x y direction view-distance]} character
-        ;x (inc (rem x window-width))
-        ;y (inc (rem y window-height))
         ends (end-points character)
         lines (map #(let [dx (first %)
                           dy (second %)

                          end   #js[dx dy]]
                      (take view-distance (js->clj (bresenham start end))))
                   ends)]
    lines))

(defn viewable-coords [character level]
  (->> (fov character)
       (map (partial shorten-line level))
       (apply concat)))

(defn blocks-around [character]
  (let [{:keys [x y]} character
        x-low (-> x (/ window-width) js/Math.floor (* window-width))
        x-hi (+ x-low window-width)
        y-low (-> y (/ window-height) js/Math.floor (* window-height))
        y-hi (+ y-low window-height)
        row-array (range x-low x-hi)
        col-array (range y-low y-hi)]
    (apply concat
           (for [x row-array]
             (vec (map #(vec [x %]) col-array))))))



(defn show-map-direct [term level character]
  (let [get-in-level (partial get-in level)]

(defn draw-line [term line]
  (run!
    (partial draw-x term) line))

(defn put-block [character buffer block]
  (let [{:keys [x y inhabitants color visible]} block
