get loading of generated level data working

"

"
This commit is contained in:
Travis Shears 2026-04-10 15:27:29 +02:00
parent 8f89883cb8
commit 9fc3881247
Signed by: travisshears
GPG key ID: CB9BF1910F3F7469
4 changed files with 24 additions and 23 deletions

View file

@ -40,32 +40,32 @@
(map #(str/split % #","))
(map (fn [row] (map Integer/parseInt row)))))
tiles (map-indexed
(fn [y row]
(map-indexed
(fn [x tile-id] {:x (* x 25) :y (* y 25) :tile-id tile-id})
row)) tile-nums)]
tiles (vec (map-indexed
(fn [y row]
(vec (map-indexed
(fn [x tile-id] {:x (* x 25) :y (* y 25) :tile-id tile-id})
row))) tile-nums))]
(hash-map
:tiles tiles
:spawns (reduce (fn [acc tag]
(if (= (:tag tag) :object)
(conj acc
(hash-map
:name (get-in tag [:attrs :name])
:x (Math/round (Double/parseDouble (get-in tag [:attrs :x])))
:y (Math/round (Double/parseDouble (get-in tag [:attrs :y])))))
acc)) '() (:content (first (filter #(= (get-in % [:attrs :name]) "spawns") tags)))))))
:spawns (vec (reduce (fn [acc tag]
(if (= (:tag tag) :object)
(conj acc
(hash-map
:name (get-in tag [:attrs :name])
:x (Math/round (Double/parseDouble (get-in tag [:attrs :x])))
:y (Math/round (Double/parseDouble (get-in tag [:attrs :y])))))
acc)) '() (:content (first (filter #(= (get-in % [:attrs :name]) "spawns") tags))))))))
(pprint/pprint {:row (first (:tiles level-001))})
;; :wall-colliders wall-colliders})
;; (fs/write-lines "level_001.lua" (pr-str '(local name "travis")))
;; (pprint/pprint (pr-str level-001))
(fs/write-lines "../level-001.fnl" ["(local level-001"
(pr-str level-001)
")\n\n"
"{ :level-01 level-01 }"])
(fs/write-lines "../levels.fnl" ["(local levels"
(str/replace (pr-str {:level01 level-001}) #",+" "")
")\n\n"
"{ :levels levels }"])
;; (str "return " (pr-str {:tile (ffirst (:tiles level-001))
;; :wall-colliders wall-colliders