load collider boxes

Press any key to quit" 10 10))
This commit is contained in:
Travis Shears 2026-04-11 07:58:04 +02:00
parent 63b9221590
commit 506cd5a28e
Signed by: travisshears
GPG key ID: CB9BF1910F3F7469
5 changed files with 858 additions and 100 deletions

View file

@ -13,17 +13,21 @@
(:content walls-tsx)
(remove string?)
(filter #(= (:tag %) :tile))
(map (fn [tile] (hash-map
:id (get-in tile [:attrs :id])
:boxes
(->> (:content tile)
(remove string?)
(map :content)
(flatten)
(remove string?)
(map :attrs)
(map #(select-keys % [:x :y :height :width]))
(map #(update-vals % (fn [v] (Math/round (Double/parseDouble v)))))))))))
(reduce (fn [acc tile]
(conj acc
{(Integer/parseInt (get-in tile [:attrs :id]))
(vec
(->> (:content tile)
(remove string?)
(map :content)
(flatten)
(remove string?)
(map :attrs)
(map #(select-keys % [:x :y :height :width]))
(map #(update-vals % (fn [v] (Math/round (Double/parseDouble v)))))))}))
{})))
(pprint/pprint wall-colliders)
(def level-001-tmx (xml/parse (io/reader "./tiled/level_001.tmx")))
(def level-001
@ -48,6 +52,7 @@
(hash-map
:tiles tiles
:wall-colliders wall-colliders
:spawns (vec (reduce (fn [acc tag]
(if (= (:tag tag) :object)
(conj acc