How to read a tiled map editor file

Started by
5 comments, last by SoulHeart 12 years, 1 month ago
I recently started using Tiled Map Editor and I'm not sure how to get my program to read the map file. I'll be using sfml with tiled. So if anyone out there can explain this as thoroughly as possible it would really help me out. Also, if you want to through in some extras such as characters with sfml/tiled(I can get a character implemented in sfml but i'm not sure how to do it in tiled), map properties(collisions, etc.), and basic side scrolling. Thanks guys.
Advertisement
https://github.com/b.../TMX-Map-Format

The TMX file format is XML based. Something like pugixml or TinyXML could process it. Chances are also high that people have already done this!

Scrolling is done by transforming coordinates from world space to view space. Your tiles/characters will be in the world space and to draw them you can transform them to the view space. Commonly what you do is have a camera position (the camera has a position in world space) and then to draw your objects in view space, you find the position of your object in world space relative to the camera. ViewX=WorldX - CameraX and ViewY = WorldY - CameraY. If I have a world that is 1600 wide with a window of 800, a world position on X axis of 900 and a camera position of 200, then my ViewX would be: 900-200 = 700. If my camera position was at 800 then 900-800 = 100 and finally if my camera was at the same X axis as my object (900) then it would be 900-900 = 0.

So you are not moving your objects when you scroll, you are drawing them at coordinates relative to the position of the camera.
I'm not sure on how to link tinyxml to codeblocks...
I don't know which file i need to link
TinyXML as far as I remember is not a library. You simply include the relevant files in your project and include the headers. I suppose you might be able to compile it as a library yourself.. Google can help here... I searched myself and came up with a number of helpful links just now.
ok I've been making some progress with it. One last thing(hopefully)....
It says you have to set drawing bounds before drawing. Can you explain how to do this and maybe what it is doing. The example that was give is.....

level.SetDrawingBounds(somesfview.GetRect())

ok I've been making some progress with it. One last thing(hopefully)....
It says you have to set drawing bounds before drawing. Can you explain how to do this and maybe what it is doing. The example that was give is.....

level.SetDrawingBounds(somesfview.GetRect())


That is the bounds of the viewable area. It is the region that is visible.
I couldn't figure out how to set the drawing bounds. Can you show me an example.(I'm the world's biggest programming noob)

This topic is closed to new replies.

Advertisement