.db 0x5, 0x60, 0x1, 0x60, 0xf, 0x60, 0x1, 0x60
.db 0xf, 0x60, 0x1, 0x60, 0xf, 0x60, 0x1, 0x60
.db 0xf, 0x60, 0x1, 0x60, 0x2, 0x60, 0x4, 0x44
-.db 0x9, 0x60, 0x1, 0x60, 0x7, 0x60, 0x3, 0x62
-.db 0x5, 0x60, 0x1, 0x60, 0x7, 0x60, 0x3, 0x62
-.db 0x5, 0x60, 0x1, 0x60, 0x7, 0x60, 0x3, 0x62
-.db 0x5, 0x60, 0x1, 0x60, 0xf, 0x60, 0x1, 0x60
+.db 0x8, 0x60, 0x1, 0x6e, 0x1, 0x60, 0x7, 0x60
+.db 0x3, 0x62, 0x4, 0x60, 0x1, 0x6e, 0x1, 0x60
+.db 0x7, 0x60, 0x3, 0x62, 0x5, 0x60, 0x1, 0x60
+.db 0x7, 0x60, 0x3, 0x62, 0x5, 0x60, 0x1, 0x60
.db 0xf, 0x60, 0x1, 0x60, 0xf, 0x60, 0x1, 0x60
-.db 0xf, 0x60, 0x1, 0x62, 0xe, 0x60, 0x1, 0x42
+.db 0xf, 0x60, 0x1, 0x60, 0xf, 0x60, 0x1, 0x62
+.db 0xe, 0x60, 0x1, 0x42
.db 0x00 ; termiante data
default_map_tile_flags:
.db 0x27, 0x0, 0x4, 0x1, 0x48, 0x0, 0x4, 0x1
-.db 0x89, 0x0
+.db 0x8, 0x0, 0x1, 0x2, 0xf, 0x0, 0x1, 0x3
+.db 0x70, 0x0
.db 0x00 ; termiante data
map_name = "noname"
NAME_LEN = 8
-FLAGS = {
- 'f_collision': 0x01
- }
-
TILE_FLAGS = [0] * 256
+MAP_W = 16
+MAP_H = 16
+
+# set by layer properties
+# flags_x,y
+BG_FLAGS = [0] * MAP_W * MAP_H
if len(sys.argv) < 3:
print("Usage: tmx2map.py <source> <map name>")
split = data.split(",")
flags = []
for i, byte in enumerate(split):
- flags.append(TILE_FLAGS[int(byte)-1])
+ flags.append(TILE_FLAGS[int(byte)-1] | BG_FLAGS[i])
print_data(flags, name, 'tile_flags', convert_none)
def print_header(name):
if child.tag == 'properties':
for sub_child in child:
if sub_child.tag == 'property':
- for flag in FLAGS:
- if sub_child.attrib['name'] == flag:
- TILE_FLAGS[int(tile.attrib['id'])] |= FLAGS[flag]
+ if sub_child.attrib['name'] == 'flags':
+ TILE_FLAGS[int(tile.attrib['id'])] |= int(sub_child.attrib['value'])
# get all flags and write them to TILE_FLAGS
def get_flags(tileset):
return
+def read_bg_props(data):
+ for child in data:
+ name = child.attrib['name']
+ if name.startswith('flags_'):
+ name = name.replace('flags_', '')
+ coords = name.split(',')
+ tile_index = int(coords[1]) * MAP_W + int(coords[0])
+ BG_FLAGS[tile_index] = int(child.attrib['value'])
+
def convert(src, name):
tree = ET.parse(src)
root = tree.getroot()
for child in root:
if child.tag == "layer":
for data in child:
- print_bg_data(data.text, name, child.attrib['name'])
- print_bg_flags(data.text, name, child.attrib['name'])
+ if data.tag == "properties":
+ read_bg_props(data)
+ else:
+ print_bg_data(data.text, name, child.attrib['name'])
+ print_bg_flags(data.text, name, child.attrib['name'])
elif child.tag == "tileset":
get_flags(child)