Prepping for entities in map compiler
This commit is contained in:
@ -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": [
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
@ -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": [
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
14
data/map project.tiled-project
Normal file
14
data/map project.tiled-project
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
{
|
||||||
|
"automappingRulesFile": "",
|
||||||
|
"commands": [
|
||||||
|
],
|
||||||
|
"compatibilityVersion": 1100,
|
||||||
|
"extensionsPath": "extensions",
|
||||||
|
"folders": [
|
||||||
|
"."
|
||||||
|
],
|
||||||
|
"properties": [
|
||||||
|
],
|
||||||
|
"propertyTypes": [
|
||||||
|
]
|
||||||
|
}
|
13
data/map project.tiled-session
Normal file
13
data/map project.tiled-session
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
{
|
||||||
|
"activeFile": "",
|
||||||
|
"expandedProjectPaths": [
|
||||||
|
],
|
||||||
|
"fileStates": {
|
||||||
|
},
|
||||||
|
"last.objectTemplatePath": "/home/yourwishes/htdocs/dusk/data/templates",
|
||||||
|
"openFiles": [
|
||||||
|
],
|
||||||
|
"project": "map project.tiled-project",
|
||||||
|
"recentFiles": [
|
||||||
|
]
|
||||||
|
}
|
24
data/map.tmj
24
data/map.tmj
@ -2,6 +2,23 @@
|
|||||||
"height":20,
|
"height":20,
|
||||||
"infinite":true,
|
"infinite":true,
|
||||||
"layers":[
|
"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":[
|
"chunks":[
|
||||||
{
|
{
|
||||||
@ -182,7 +199,8 @@
|
|||||||
}],
|
}],
|
||||||
"height":32,
|
"height":32,
|
||||||
"id":1,
|
"id":1,
|
||||||
"name":"Tile Layer 1",
|
"locked":true,
|
||||||
|
"name":"Base Layer",
|
||||||
"opacity":1,
|
"opacity":1,
|
||||||
"startx":0,
|
"startx":0,
|
||||||
"starty":0,
|
"starty":0,
|
||||||
@ -192,8 +210,8 @@
|
|||||||
"x":0,
|
"x":0,
|
||||||
"y":0
|
"y":0
|
||||||
}],
|
}],
|
||||||
"nextlayerid":2,
|
"nextlayerid":5,
|
||||||
"nextobjectid":1,
|
"nextobjectid":3,
|
||||||
"orientation":"orthogonal",
|
"orientation":"orthogonal",
|
||||||
"renderorder":"right-down",
|
"renderorder":"right-down",
|
||||||
"tiledversion":"1.11.1",
|
"tiledversion":"1.11.1",
|
||||||
|
4
data/templates/NPC.tx
Normal file
4
data/templates/NPC.tx
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<template>
|
||||||
|
<object name="NPC" width="16" height="16"/>
|
||||||
|
</template>
|
@ -67,8 +67,29 @@ if len(layers) == 0:
|
|||||||
print(f"Error: Input file '{inputFile}' does not contain any layers.")
|
print(f"Error: Input file '{inputFile}' does not contain any layers.")
|
||||||
sys.exit(1)
|
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
|
# First layer
|
||||||
firstLayer = layers[0]
|
firstLayer = tileLayers[0]
|
||||||
if 'width' not in firstLayer or 'height' not in firstLayer:
|
if 'width' not in firstLayer or 'height' not in firstLayer:
|
||||||
print(f"Error: First layer in '{inputFile}' does not contain 'width' or 'height' key.")
|
print(f"Error: First layer in '{inputFile}' does not contain 'width' or 'height' key.")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
@ -112,7 +133,7 @@ for chunkY in range(mapHeightInRealChunks):
|
|||||||
chunkLayers = []
|
chunkLayers = []
|
||||||
|
|
||||||
# For each layer...
|
# For each layer...
|
||||||
for layerIndex, layer in enumerate(layers):
|
for layerIndex, layer in enumerate(tileLayers):
|
||||||
foundChunk = None
|
foundChunk = None
|
||||||
if 'chunks' not in layer or not isinstance(layer['chunks'], list):
|
if 'chunks' not in layer or not isinstance(layer['chunks'], list):
|
||||||
print(f"Error: Layer {layerIndex} in '{inputFile}' does not contain 'chunks' key.")
|
print(f"Error: Layer {layerIndex} in '{inputFile}' does not contain 'chunks' key.")
|
||||||
|
Reference in New Issue
Block a user