Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: 'Tiled' Tile-map Loader  (Read 200929 times)

0 Members and 3 Guests are viewing this topic.

zachprinz

  • Newbie
  • *
  • Posts: 18
    • View Profile
Re: 'Tiled' Tile-map Loader
« Reply #90 on: November 13, 2013, 05:03:03 pm »
Thanks :)

So this is a new format which replaces the tsx schema? Or an additional format which allows multiple images to make up a single tsx/tileset? The commit date of the xsd file is from 3 years ago and the file itself says it was last updated 6/7/2008 so I'm a little dubious as to how up to date the schema is. I've always followed this which states that it is version 1.0 (not 0.7.0, which the xsd file implies).

If anyone else asks for this I may add it to the existing formats (while not replacing them) but for now I'll not act on it. If anyone wants to contribute this, however, I'll be more than happy to consider it :)

Ooh, you're right. My bad. I hadn't actually used the schema (just the changes I saw in the .tmx files.) I edited my post to include the document type definition, it looks like he documented the changes somewhere around 0.9.0.

These changes are in addition to the previous tilesets. So a regular tileset will still appear the same way in XML.

And that's fine. Like I said I've got my code working.
« Last Edit: November 13, 2013, 05:05:48 pm by zachprinz »

Sixoul

  • Newbie
  • *
  • Posts: 17
    • View Profile
Re: 'Tiled' Tile-map Loader
« Reply #91 on: November 14, 2013, 04:43:09 am »
I got something basic set up and I was wondering what I can do to improve this. I can see the lines where the tiles are placed and I'm only getting 20fps, according to fraps. Here's a video, it doesn't show up too well but you can see the lines between some of the tiles.


Thanks for any help I'm really new still.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: 'Tiled' Tile-map Loader
« Reply #92 on: November 14, 2013, 07:41:57 am »
I got something basic set up and I was wondering what I can do to improve this. I can see the lines where the tiles are placed and I'm only getting 20fps, according to fraps.
Make sure the tiles or view are always set to integer values (no 1.13 but just 1), it should remove the line issue.
As for FPS the FRAPS measuring isn't always the best way to get the FPS value, but it's quite possibly correct, it all depends on your implementation and PC power.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

fallahn

  • Hero Member
  • *****
  • Posts: 507
  • Buns.
    • View Profile
    • Trederia
Re: 'Tiled' Tile-map Loader
« Reply #93 on: November 15, 2013, 11:27:23 am »
A few reasons I can think of:
You're using an old version. The latest is on GitHub
You're running in debug mode as opposed to release (although the frame rate drop should still not be that low)
You're drawing the debug layer and/or quadtree debug layer which can be slow
Fraps is limiting the frame rate

I've added an example called 'Benchmark' to the repository. Try building and running it in release mode. On my office machine (i5 quad core, ATi 7750, Win 7 64) I get just over 3000fps. You can use the cursor keys to move around - I've not experienced any tearing.


wintertime

  • Sr. Member
  • ****
  • Posts: 255
    • View Profile
Re: 'Tiled' Tile-map Loader
« Reply #94 on: November 15, 2013, 11:40:46 am »
I was looking at the file with the benchmark and I have some suggestions:
- You may want to display milliseconds/microseconds per frame, because fps is nonlinear and not a good measurement for performance.
- And you are measuring the time in the middle of the frame not after the swap(display), so its actually not the time of one frame but a mix of part of the time from previous frame and part of the time from 2 frames ago.

Sixoul

  • Newbie
  • *
  • Posts: 17
    • View Profile
Re: 'Tiled' Tile-map Loader
« Reply #95 on: December 06, 2013, 10:51:01 pm »
So I had to take a break for a while due to classes and finals and I came back without changing any code from my last issue to get an error. I think the last thing I did was take a new map with the same name since my friend said he enjoyed making maps like that. I set up a breakpoint and it seems to create the error when it loads the map.

Debug Assertion Failed!

Program: C:\Windows\system32\MSVCP110D.dll
File: c:\program files (x86)\microsoft visual studio 11.0\vc\include\vector
Line: 1140

Expression: vector subscript out of range

For information on how your program can cause an assertion
failure, see the Visual C++ documentation on asserts.

(Press Retry to debug the application)

        sf::RenderWindow gameWindow(sf::VideoMode(Game::baseWidth, Game::baseHeight), "Legend of Link");
        tmx::MapLoader ml("map/");
        ml.Load("test_terrain.tmx");   //breaks here
 

fallahn

  • Hero Member
  • *****
  • Posts: 507
  • Buns.
    • View Profile
    • Trederia
Re: 'Tiled' Tile-map Loader
« Reply #96 on: December 07, 2013, 01:50:10 pm »
Sounds like this error. Try moving the images / tilesets to the same directory as the map file, and updating the paths in the map file itself. I'll make a note on the tracker to fix this :)

Sixoul

  • Newbie
  • *
  • Posts: 17
    • View Profile
Re: 'Tiled' Tile-map Loader
« Reply #97 on: December 08, 2013, 06:12:47 am »
Thanks. I didn't even notice my tileset were set up differently.

zachprinz

  • Newbie
  • *
  • Posts: 18
    • View Profile
Re: 'Tiled' Tile-map Loader
« Reply #98 on: December 10, 2013, 04:45:02 am »
Hey, I've been running performance analysis on some of my code and drawing a 25x25 map that has 2 layers and uses 1 sprite sheet through Tiled is holding about 29% of the samples. Is this normal?


fallahn

  • Hero Member
  • *****
  • Posts: 507
  • Buns.
    • View Profile
    • Trederia
Re: 'Tiled' Tile-map Loader
« Reply #99 on: December 10, 2013, 11:31:43 am »
No idea. I've never tried any kind of analysis before and, to be honest, I have no idea what 29% of the samples means. However, if you want to try analysing the samples in the repository and perhaps the vertex array samples from the SFML tutorials for comparison I'd be interested in seeing the results.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: 'Tiled' Tile-map Loader
« Reply #100 on: December 10, 2013, 11:46:29 am »
Hey, I've been running performance analysis on some of my code and drawing a 25x25 map that has 2 layers and uses 1 sprite sheet through Tiled is holding about 29% of the samples. Is this normal?
Can't you tell your profiler where to find SFML's source code and resolve all those "sfml-graphics-d-2.dll" into something more useful?

It's normal that draw calls take up some time, whether it's normal with your setup is impossible to tell with the given information.
Is it already a performance issue on your end, or are you doing some premature optimization testing? ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

zachprinz

  • Newbie
  • *
  • Posts: 18
    • View Profile
Re: 'Tiled' Tile-map Loader
« Reply #101 on: December 10, 2013, 03:45:11 pm »
No idea. I've never tried any kind of analysis before and, to be honest, I have no idea what 29% of the samples means. However, if you want to try analysing the samples in the repository and perhaps the vertex array samples from the SFML tutorials for comparison I'd be interested in seeing the results.

I'll be looking into it. I'll post back what I find.

Hey, I've been running performance analysis on some of my code and drawing a 25x25 map that has 2 layers and uses 1 sprite sheet through Tiled is holding about 29% of the samples. Is this normal?
Can't you tell your profiler where to find SFML's source code and resolve all those "sfml-graphics-d-2.dll" into something more useful?

It's normal that draw calls take up some time, whether it's normal with your setup is impossible to tell with the given information.
Is it already a performance issue on your end, or are you doing some premature optimization testing? ;)
That would be a nifty trick, I'll figure out how to do that seeing as like you said the info past m_DrawLayer is pretty useless.

I've been testing my code on different machines and focusing heavy on optimization lately. My goal is a solid 60 fps on Intel HD 4000 integrated graphics. I've gone from 20 to 35-40 in the last 10 days so so far so good.

EDIT: So for my purposes (Considering all animated tiles and objects are handled by my engine and not the tile map) just loading a .png of the level actually doubled my frame rate. I didn't end up testing the examples from the github. I may in the future if I find a need to use Tiled Map Loader to draw my maps.
« Last Edit: December 12, 2013, 12:46:31 am by zachprinz »

Keyeszx

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: 'Tiled' Tile-map Loader
« Reply #102 on: December 19, 2013, 01:07:30 am »
If I wanted to use the Tiled editor to set points where say a chest would appear, the player spawns, or enemy spawns how would I do that? Would I use the object layer like you explained in the collision post?
« Last Edit: December 19, 2013, 01:42:09 am by Keyeszx »

fallahn

  • Hero Member
  • *****
  • Posts: 507
  • Buns.
    • View Profile
    • Trederia
Re: 'Tiled' Tile-map Loader
« Reply #103 on: December 19, 2013, 10:33:06 am »
I'd probably create an object layer for each type, so one for spawns, one for chests etc. Then, when parsing the map, grab the layer by name and create entities at each object position. Something like:

foreach layer in map.layers
    if layer.name == "spawn"
        foreach object in layer.objects
            createItem(object.position)
 

Kojay

  • Full Member
  • ***
  • Posts: 104
    • View Profile
Re: 'Tiled' Tile-map Loader
« Reply #104 on: December 20, 2013, 12:52:24 am »
Going through the code, it is not clear that vertex arrays are taken advantage of to draw each layer in a single call. As far as I can tell, each tile is represented by a sprite and each of those is drawn individually. Instead, each tile should only hold 4 sf::Vertex; in the draw function, if the tile is visible, then append its vertices to the vertex array to be drawn.

 

anything