From ef6b9473fc251ecca4944f5d18a77ef95c036886 Mon Sep 17 00:00:00 2001 From: Dominic Masters Date: Sun, 15 Jun 2025 10:43:01 -0500 Subject: [PATCH] Prepping for entities in map compiler --- data/chunks/chunk_0_0.json | 34 ---------------------------------- data/chunks/chunk_2_1.json | 29 ----------------------------- data/map project.tiled-project | 14 ++++++++++++++ data/map project.tiled-session | 13 +++++++++++++ data/map.tmj | 24 +++++++++++++++++++++--- data/templates/NPC.tx | 4 ++++ tools/mapcompile/mapcompile.py | 25 +++++++++++++++++++++++-- 7 files changed, 75 insertions(+), 68 deletions(-) delete mode 100644 data/chunks/chunk_0_0.json delete mode 100644 data/chunks/chunk_2_1.json create mode 100644 data/map project.tiled-project create mode 100644 data/map project.tiled-session create mode 100644 data/templates/NPC.tx diff --git a/data/chunks/chunk_0_0.json b/data/chunks/chunk_0_0.json deleted file mode 100644 index b5cecbd..0000000 --- a/data/chunks/chunk_0_0.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "chunk": { - "position": [ 0, 0 ], - "baseLayer": [ - [ 1, 1, 1, 1, 1, 1, 1, 1 ], - [ 1, 1, 1, 1, 1, 1, 1, 1 ], - [ 1, 1, 1, 1, 1, 1, 1, 1 ], - [ 1, 1, 1, 1, 1, 1, 1, 1 ], - [ 1, 1, 1, 1, 1, 1, 1, 1 ], - [ 1, 1, 1, 1, 1, 1, 1, 1 ], - [ 1, 1, 1, 1, 1, 1, 1, 1 ], - [ 1, 1, 1, 1, 1, 1, 1, 1 ] - ], - "overlayLayer": [ - [ 1, 1, 1, 1, 1, 1, 1, 1 ], - [ 1, 1, 1, 1, 1, 1, 1, 1 ], - [ 1, 1, 1, 1, 1, 1, 1, 1 ], - [ 1, 1, 1, 1, 1, 1, 1, 1 ], - [ 1, 1, 1, 1, 1, 1, 1, 1 ], - [ 1, 1, 1, 1, 1, 1, 1, 1 ], - [ 1, 1, 1, 1, 1, 1, 1, 1 ], - [ 1, 1, 1, 1, 1, 1, 1, 1 ] - ], - "entities": [ - { - "type": "npc", - "x": "3", - "y": "3" - } - ], - "triggers": [ - ] - } -} diff --git a/data/chunks/chunk_2_1.json b/data/chunks/chunk_2_1.json deleted file mode 100644 index 080182f..0000000 --- a/data/chunks/chunk_2_1.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "chunk": { - "position": [ 2, 1 ], - "baseLayer": [ - [ 1, 1, 1, 1, 1, 1, 1, 1 ], - [ 1, 1, 1, 1, 1, 1, 1, 1 ], - [ 1, 1, 1, 1, 1, 1, 1, 1 ], - [ 1, 1, 1, 1, 1, 1, 1, 1 ], - [ 1, 1, 1, 1, 1, 1, 1, 1 ], - [ 1, 1, 1, 1, 1, 1, 1, 1 ], - [ 1, 1, 1, 1, 1, 1, 1, 1 ], - [ 1, 1, 1, 1, 1, 1, 1, 1 ] - ], - "overlayLayer": [ - [ 1, 1, 1, 1, 1, 1, 1, 1 ], - [ 1, 1, 1, 1, 1, 1, 1, 1 ], - [ 1, 1, 1, 1, 1, 1, 1, 1 ], - [ 1, 1, 1, 1, 1, 1, 1, 1 ], - [ 1, 1, 1, 1, 1, 1, 1, 1 ], - [ 1, 1, 1, 1, 1, 1, 1, 1 ], - [ 1, 1, 1, 1, 1, 1, 1, 1 ], - [ 1, 1, 1, 1, 1, 1, 1, 1 ] - ], - "entities": [ - ], - "triggers": [ - ] - } -} diff --git a/data/map project.tiled-project b/data/map project.tiled-project new file mode 100644 index 0000000..d0eb592 --- /dev/null +++ b/data/map project.tiled-project @@ -0,0 +1,14 @@ +{ + "automappingRulesFile": "", + "commands": [ + ], + "compatibilityVersion": 1100, + "extensionsPath": "extensions", + "folders": [ + "." + ], + "properties": [ + ], + "propertyTypes": [ + ] +} diff --git a/data/map project.tiled-session b/data/map project.tiled-session new file mode 100644 index 0000000..5b98607 --- /dev/null +++ b/data/map project.tiled-session @@ -0,0 +1,13 @@ +{ + "activeFile": "", + "expandedProjectPaths": [ + ], + "fileStates": { + }, + "last.objectTemplatePath": "/home/yourwishes/htdocs/dusk/data/templates", + "openFiles": [ + ], + "project": "map project.tiled-project", + "recentFiles": [ + ] +} diff --git a/data/map.tmj b/data/map.tmj index c63268e..5ce74e0 100644 --- a/data/map.tmj +++ b/data/map.tmj @@ -2,6 +2,23 @@ "height":20, "infinite":true, "layers":[ + { + "draworder":"topdown", + "id":3, + "name":"Object Layer 1", + "objects":[ + { + "id":1, + "template":"templates\/NPC.tx", + "x":150.666666666667, + "y":96.3333333333333 + }], + "opacity":1, + "type":"objectgroup", + "visible":true, + "x":0, + "y":0 + }, { "chunks":[ { @@ -182,7 +199,8 @@ }], "height":32, "id":1, - "name":"Tile Layer 1", + "locked":true, + "name":"Base Layer", "opacity":1, "startx":0, "starty":0, @@ -192,8 +210,8 @@ "x":0, "y":0 }], - "nextlayerid":2, - "nextobjectid":1, + "nextlayerid":5, + "nextobjectid":3, "orientation":"orthogonal", "renderorder":"right-down", "tiledversion":"1.11.1", diff --git a/data/templates/NPC.tx b/data/templates/NPC.tx new file mode 100644 index 0000000..6fc98bc --- /dev/null +++ b/data/templates/NPC.tx @@ -0,0 +1,4 @@ + + diff --git a/tools/mapcompile/mapcompile.py b/tools/mapcompile/mapcompile.py index 9689dfc..5db739a 100644 --- a/tools/mapcompile/mapcompile.py +++ b/tools/mapcompile/mapcompile.py @@ -67,8 +67,29 @@ if len(layers) == 0: print(f"Error: Input file '{inputFile}' does not contain any layers.") sys.exit(1) +# Object layer +objectLayer = None +for layer in layers: + if layer.get('type') == 'objectgroup': + objectLayer = layer + break + +if objectLayer is None: + print(f"Error: Input file '{inputFile}' does not contain an object layer.") + sys.exit(1) + +# Tile Layers +tileLayers = [] +for layer in layers: + if layer.get('type') == 'tilelayer': + tileLayers.append(layer) + +if len(tileLayers) == 0: + print(f"Error: Input file '{inputFile}' does not contain any tile layers.") + sys.exit(1) + # First layer -firstLayer = layers[0] +firstLayer = tileLayers[0] if 'width' not in firstLayer or 'height' not in firstLayer: print(f"Error: First layer in '{inputFile}' does not contain 'width' or 'height' key.") sys.exit(1) @@ -112,7 +133,7 @@ for chunkY in range(mapHeightInRealChunks): chunkLayers = [] # For each layer... - for layerIndex, layer in enumerate(layers): + for layerIndex, layer in enumerate(tileLayers): foundChunk = None if 'chunks' not in layer or not isinstance(layer['chunks'], list): print(f"Error: Layer {layerIndex} in '{inputFile}' does not contain 'chunks' key.")