|
|
|
@ -39,7 +39,7 @@
|
|
|
|
|
[(dec x)
|
|
|
|
|
(/ (- ix x) width)]))
|
|
|
|
|
|
|
|
|
|
(defn layer->dest [layer tileset data]
|
|
|
|
|
(defn layer->dest [tileset layer]
|
|
|
|
|
(map-indexed
|
|
|
|
|
(fn [ix tile]
|
|
|
|
|
(let [{:keys [width height]} layer
|
|
|
|
@ -50,7 +50,7 @@
|
|
|
|
|
:y (* dyc tileheight)
|
|
|
|
|
:w tilewidth
|
|
|
|
|
:h tileheight}))
|
|
|
|
|
data))
|
|
|
|
|
(:data layer)))
|
|
|
|
|
|
|
|
|
|
(defn draw-tile [ctx tileset image tileid dest]
|
|
|
|
|
(let [{:keys [tileheight tilewidth
|
|
|
|
@ -70,11 +70,8 @@
|
|
|
|
|
tileset-id (:tileset viewport)
|
|
|
|
|
image (tileset-id images)
|
|
|
|
|
tileset (map-def->tileset def (:tileset viewport))]
|
|
|
|
|
(doseq [layer layers
|
|
|
|
|
:let [destinations (->> (:data layer)
|
|
|
|
|
(layer->dest layer tileset)
|
|
|
|
|
(filter #(not= 0 (:tile %))))]]
|
|
|
|
|
(doseq [dest destinations
|
|
|
|
|
(doseq [layer layers]
|
|
|
|
|
(doseq [dest layer
|
|
|
|
|
:let [dx (- (:x dest) (:x viewport))
|
|
|
|
|
dy (- (:y dest) (:y viewport))]]
|
|
|
|
|
(draw-tile ctx tileset image
|
|
|
|
|