Any Tiled .tmx Parser for BlitzMax?

BlitzMax Forums/BlitzMax Programming/Any Tiled .tmx Parser for BlitzMax?

braxton(Posted 2015) [#1]
Does anyone have a sample, snippet or possibly a module to share that can read Tiled's xml .tmx map format (mapeditor.org) maps in BlitzMax?

I have been trying to convert some Monkey-X code but cannot seem to get it working :/


col(Posted 2015) [#2]
Hiya,

Brucey has XML parsing module(s) here

Does that help?


braxton(Posted 2015) [#3]
Hi col,

Thanks for your reply, I am indeed using Brucey's awesome bah.libxml to parse the xml map file, the problem appears to be interpreting the various nodes within the xml as they appear to use different methods depending on the version of tiled used, some have data exported within the xml as csv (which I can handle albeit crudely) while newer versions use base64+zlib data and I am not sure how to handle this to decompress the map to an array let alone handle multiple tilesets, which is why I have been looking for some code as a starting point.

I thought for sure that someone else might have encountered and tackled these issues as it is such a versatile tile map editor.

I did initially try to convert these c++ libs to BlitzMax

github.com/baylej/tmx ; github.com/jube/libtmx ; github.com/halsafar/libtmx-parser

without any luck though, the needed glue code is out of my depth, maybe it's just me and xml but it is all a bit over my head it seems :/


grable(Posted 2015) [#4]
Does it have to be converted into BlitzMax?

github.com/baylej/tmx is pure C and even has a binary release, so if you dont mind extra dlls it is the easiest to interface with.

No need to reinvent the wheel ;)

EDIT: I Hacked together a bare bones module using the binary release if your interested:
tmx.bmx

tmx_glue.bmx

tmx_glue.c


Note: NOT tested!


braxton(Posted 2015) [#5]
Hi grable, thank you so much I really do appreciate you taking the time to look at this, and for what you have done so far it is really awesome!

It definitely does not have to be in BlitzMax, I was only hoping to be able to access Tiled's .tmx maps from within BlitzMax using whatever libraries, modules and or code I could find or create.

I really do not mind using dlls at all, it is a lot better than reinventing the wheel, especially as Tiled is evolving with each new version.

I tried using "win32" instead of "C" among other things and wondered why it wasn't working right when I attempted wrapping the libraries. I certainly never got as far as you did in such a short space of time, and it has taken me a lot longer.

Your glue code is very impressive as is Brucey's. I have been trying my hand at wrapping nih.at/libzip as an exercise but it is not quite there yet.

I still have a lot to learn with regards to wrapping but it is what makes BlitzMax great in my opinion and expandable. I am going to study this carefully. I really am very grateful for what you have done.