add objects as seprate key in level

This commit is contained in:
Travis Shears 2026-04-19 21:39:37 +02:00
parent a457893d14
commit e00250fd84
Signed by: travisshears
GPG key ID: CB9BF1910F3F7469
3 changed files with 14 additions and 6 deletions

View file

@ -73,6 +73,14 @@
(fn [x tile] (conj {:x (* x 25) :y (* y 25)} tile))
row))) tiles))
:objects
(let [objects (:content (first (filter #(= (get-in % [:attrs :name]) "objects") (:content map-tmx))))]
(vec (map (fn [obj]
(let [attrs (dissoc (:attrs obj) :id)
tags (flatten (map :content (:content obj)))
properties (map #(hash-map (keyword (get-in % [:attrs :name])) (get-in % [:attrs :value])) tags)]
(into attrs properties))) objects)))
:spawns
(let [spawns (first (filter #(= (get-in % [:attrs :name]) "spawns") (:content map-tmx)))
player-1 (first (filter #(= (get-in % [:attrs :name]) "player_1") (:content spawns)))
@ -86,7 +94,7 @@
:tutorial (parse-map tutorial-map-tmx)}
:colliders colliders})
;; (pprint (get-in levels [:levels :level-001 :spawns]))
(pprint (get-in levels [:levels :tutorial :objects]))
;; (pprint/pprint {:row (first (:tiles level-001))})
;; (pprint/pprint (pr-str level-001))

View file

@ -30,11 +30,11 @@
"expandedObjectLayers": [
2
],
"scale": 2.2046,
"selectedLayer": 1,
"scale": 1.1429,
"selectedLayer": 0,
"viewCenter": {
"x": 636.1698267259367,
"y": 1051.8914995917626
"x": 657.5378423309126,
"y": 883.7168606177268
}
},
"walls.tsx": {

File diff suppressed because one or more lines are too long