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