Jump to content
  • Advertisement
Sign in to follow this  
SoulHeart

How to read a tiled map editor file

This topic is 2472 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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())

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites
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)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!