 (defn draw-line [term line]
   (run!
     (partial draw-x term) line))
-
-(defn shorten-line [level line]
-  (def shortened-line (take-while #(let [[x y] %
-                                         x (min (dec window-width)  (max 0 x))
-                                         y (min (dec window-height) (max 0 y))
-                                         current-block (get-in level [x y])
-                                         solid  (has-some current-block :solid)]
-                                     (not solid))
-                                  line))
-  (if (apply not= (map last [shortened-line line]))
-    (concat shortened-line (list (nth line (count shortened-line))))
-    line))
 
 (defn put-block [character buffer block]
   (let [{:keys [x y inhabitants color visible]} block


(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 shorten-line [level line]
  (def shortened-line (take-while #(let [[x y] %
                                         current-block (get-in level [x y])
                                         solid  (has-some current-block :solid)]
                                     (not solid))
                                  line))
  (if (apply not= (map last [shortened-line line]))
    (concat shortened-line (list (nth line (count shortened-line))))
    line))

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

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