Tiled TMX Reader/Writer for BlitzMax

BlitzMax Forums/BlitzMax Programming/Tiled TMX Reader/Writer for BlitzMax

computercoder(Posted 2013) [#1]
Anyone interested in code for reading and writing Tiled Map Editor TMX formatted files?

I wrote code that reads and writes TMX files, although it is currently not complete. I thought about opening the code up for the community to have and perhaps make into a community project.

It has been a while (perhaps a year or more) since I have looked at the source, so I cannot remember what features are there and which features are not. I do know it reads and writes at the minimum XML, CSV, and I want to say Base 64 compressed GZIP. I believe it was left at reading ZLIB.

If this project does go community, I will need to change out my copyrights and change it to something perhaps like BSD or GLPL or even ZLIB.

I figured perhaps it was time (again) for me to contribute back to the community :)


computercoder(Posted 2013) [#2]
I looked at the source to see where things set with it.

I found that the Reader code is capable of reading XML, CSV, Base64 and ZLIB. GZIP part was having issues as I remember and thats just where it was left off.

As far as the Writer code, it can write XML, CSV and Base64. Again, I stopped working on the ZLIB/GZIP code in order to wrap up the Reader code with GZIP and ZLIB. When I stopped working on it, this is where it was at.

I use Brucey's excellent BaH.Libxml module for reading XML, and I believe the source I used for Base64 came from him as well. Instead of having yet another dependency, I just swallowed in the source to that.

The rest of the code is 100% mine. I did look at the code to Tiled for accuracy into what the reader and writer should expect in and out. I matched the outputs with the inputs and the code can readily switch between formats. It auto-detects the format supplied in the TMX file and reads it accordingly. Same is true with the writer, it knows what you want to set as the output format and saves it accordingly.

The code is NOT far from being complete - at least as a basic functionality, and will work with most of the features in Tiled 0.9.0. They added some nice new features, but I am not planning on adding those in at this time.

I envisioned it to be more of a complete map handling tool so that it reads and writes the TMX files, and once loaded, it will handle the map movement and know all things about the map using a few simple methods that integrate easily into your game. The map becomes an afterthought, but still provides you everything you need to make your game work as expected. Anything in the map is readily available, and the map does not slow the performance of the game. It was to support both Isometric and Orthogonal styles. Detect the maop edges, move all layers in whichever direction they are to move, and let the game know what tiles should be displayed. I de-coupled the graphic rendering from the map itself, so the game will still need to support the display portion. The idea here is to make it easier to change the graphics display without having to change the map engine. Same map functionality, just you pick the presentation layer.

I wrote this reader/writer for several languages - BlitzMax, C#, REALbasic, and Java. The C# port is far more complete out of them all, and works in Mono, Xamarin Studio and VS.Net. The completeness is dependent upon the language and its capabilities as to what features the engine supports.

The Max version is the only one I am considering releasing as a community project.


Brucey(Posted 2013) [#3]
I then switched over to BlitzMax (again) and wrote one for that language, which is nearly complete, but due to limitations of the language, I left out a few features.


What are the limitations of the BlitzMax language, in your opinion?


computercoder(Posted 2013) [#4]
To be completely honest, BlitzMax is a very extensible language. As I recall when I was working with the Zlib and GZip stuff, it didn't want to cooperate so well there. Zlib I believe was ok, but GZip didn't work without doing some tinkering with the source files. I realize that seems pretty poor of a pick, but seriously, I don't have a great deal of time to tinker around in VERY unfamiliar turf. Don't get me wrong, I enjoy challenges, but I was on a mission to at least finish the project I started.

Since my work pushed us all into a C# shop now, I re-directed my focus on C#, hence the rebirthing of my Tiled Reader/Writer in C# for me.

Most limitations are my own. I wanted to also include the JSON port of Tiled as well. I have the writer working very well, but couldn't quite get the reader written correctly. I'm sure someone these days has that covered now too.

I was not meaning to gripe about the language here, it was more me saying I left out stuff because I didn't know how to make it work using Max with the tools and knowledge base I had. Yeah, I suppose I shoulda just asked, but there's me and my independence thing. I like the challenges and try to figure out things on my own before I ever consider asking for help.