Categories

Thursday 12 February 2015

Tile maps

    Most of this week I have been trying to create a good and working parsing code for tile maps created with the tool tiled. I started trying to copy the code from my last project which was based on tiles. That did not work out that well, since that code was not made to work with the files that the program Tiled outputs and since I hadn't fully understood how file parsing works in C++ so my code just returned errors. I got frustrated and searched the web for an easy solution.
I found this project: https://github.com/bjorn/tiled/wiki/TMX-Map-Format

     It seemed like a good solution, and it probably was if only I could understand it, which I couldn't. So I spent a lot of time trying to figure what was needed to make it work, then I gave up to find something simpler. Then I found this: http://en.sfml-dev.org/forums/index.php?topic=3023.0

    It seemed simple at first glance since it was only two classes of code. I started removing parts that I saw as redundant, like the creation of sprites which I manage elsewhere in my code. I realized that this code was dependent on another libary called tinyxml, so I downloaded that and included it. Then I realized this code was made for an older version of SFML than what I am using for my project. So after combating this code and trying to translate things that I did not understand for hours I gave up, because I saw no end to it and I didn't think the program would run after all the changes that was needed to make it work with my code.

    So finally I got back to trying to do my own parser. I worked until I got an error that I did not manage to get around. Searched for a long time on forums for a solution until finally I gave up and decided to ask about it on a forum myself. I got an answer within half an hour that solved all my problems.

    If I had only asked for help on a forum in the first place I would have saved a tremendous amount of time this week that was spent feeling confused and angered about not finding a solution. At the same time I learned much about how to implement and understand code from others so that was nice.

Here is a picture showing the result off the walls (The black squares surronding the diver.) that was generated from a text file loaded by my parser.



No comments:

Post a Comment