Here is a python script that can export the data from a tmx file. At this time it outputs the width, height and tile indices:
extract.py:
#!/usr/bin/python
import xml.etree.ElementTree as ET
import sys
import zlib
import base64
print sys.argv[1] + "->" + sys.argv[2]
tree = ET.parse(sys.argv[1])
root = tree.getroot()
width = root.attrib["width"]
height = root.attrib["height"]
fh = open(sys.argv[2],'wb')
fh.write(";;----\n")
fh.write("defb "+width+" ;; width\n")
fh.write("defb "+height+" ;; height\n")
layerindex = 0
for layer in root.iter('layer'):
dataindex = 0
for data in layer.iter('data'):
datab64 = data.text
datazlib = base64.b64decode(datab64)
uncompressed = zlib.decompress(datazlib)
uncompresseddatabytes = bytearray(uncompressed)
uncompressedintlength = len(uncompresseddatabytes)/4
c = 0
for i in range(0,uncompressedintlength):
offs = i*4
v1 = uncompresseddatabytes[offs+0]
v2 = uncompresseddatabytes[offs+1]
v3 = uncompresseddatabytes[offs+2]
v4 = uncompresseddatabytes[offs+3]
value = v1 + (v2<<8) + (v3<<16) + (v4<<24)
if c==0:
fh.write("defb ")
else:
fh.write(",")
fh.write(str(value))
c = c + 1
if c>=16:
c = 0
fh.write("\n")
fh.write(";;----")
fh.close()
Usage:
python extract.py level.tmx level.asm
output file looks like this:
;;----
defb 32 ;; width
defb 12 ;; height
defb 2,3,4,2,6,17,40,40,40,40,40,40,41,41,82,55
defb 11,13,14,3,15,2,3,4,2,3,13,14,12,2,3,11
defb 2,3,4,1,2,11,41,41,41,41,41,41,41,41,41,56
defb 2,77,78,78,78,80,3,4,5,6,77,78,78,78,80,4
defb 2,3,4,11,8,17,44,44,44,44,44,44,41,41,82,55
defb 1,84,81,79,81,83,3,4,15,8,84,79,79,81,83,4
defb 2,3,13,14,11,15,41,41,82,46,45,41,41,41,82,56
defb 8,10,10,60,62,63,63,63,63,63,63,64,16,2,3,4
defb 2,77,78,78,80,17,41,41,41,41,45,41,41,41,41,55
defb 11,2,3,61,65,66,67,67,67,67,67,68,16,2,3,4
defb 2,84,79,81,83,17,43,43,49,85,87,86,41,41,41,56
defb 13,14,3,61,69,70,71,71,71,71,74,72,16,2,3,4
defb 2,11,10,3,13,17,57,58,58,58,59,50,51,52,53,48
defb 1,10,3,61,73,76,75,70,71,71,74,72,16,2,3,4
defb 18,20,19,20,19,20,18,20,18,21,22,23,18,19,20,24
defb 18,24,19,24,19,20,18,24,21,19,24,18,20,18,20,19
defb 36,35,37,35,36,35,36,35,36,36,36,38,36,36,36,35
defb 37,37,35,35,36,35,93,94,95,96,97,98,35,36,35,36
defb 28,33,34,30,31,28,34,29,34,34,28,34,33,34,34,34
defb 34,28,34,29,34,34,33,28,34,34,33,29,34,34,33,90
defb 29,34,34,34,34,34,33,34,34,34,34,34,34,28,32,34
defb 28,34,29,34,34,30,88,89,90,91,92,34,33,29,34,34
defb 28,34,28,29,34,99,100,25,26,31,88,34,34,33,34,34
defb 34,29,34,34,28,34,34,28,33,34,34,34,34,28,34,33
;;----
Excellent work!
"Tiled" to anyone who doesn't know, is a very good program for tile creation and is very easy to use. The most important thing for me using this tile editor to piece the backgrounds is that it is quick to assemble them with this program.
I was trying to use TileStudio but couldn't get the onion skin to work, as well as the tiles at the bottom were tiny and I just had no idea how to zoom into them.
And "Tiled" (The Java version) is embedded into JavaCPC's Desktop ;)
That layout looks quite similar to Tile Studio with the tile map at the bottom.
Have to say - I'm having a much more fun time using Tiled than Dame.
Personally I love Promotion. For the CPC Bros game it was a really great help. Specially when dealing with the CPC palette.
I have Promotion but haven't used it. I've been using Paint Shop Pro for my projects, but Promotion is something I really need to start using.
Do you think you'll give the Snow Bros another try?
The CPC Bros game is something still pendant. The problem is that I have no time. As you can also see I didn't finish updating the user interface of the DSK-Tool with a better font and so...
Quote from: arnoldemu on 17:05, 11 January 14
Here is a python script that can export the data from a tmx file. At this time it outputs the width, height and tile indices:
This is great work, especially will have some Tiled output files to import into the CPC in the near future :)
Thanks for sharing.