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

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

0 Members and 1 Guest are viewing this topic.

xzbobzx

  • Newbie
  • *
  • Posts: 26
    • View Profile
Re: 'Tiled' Tile-map Loader
« Reply #75 on: October 22, 2013, 08:56:23 pm »
Whaaaat went wrong here?



Using SFML 2.1.
Any idea what could have caused this?
It compiled fine.
« Last Edit: October 22, 2013, 09:00:39 pm by xzbobzx »

FRex

  • Hero Member
  • *****
  • Posts: 1848
  • Back to C++ gamedev with SFML in May 2023
    • View Profile
    • Email
Re: 'Tiled' Tile-map Loader
« Reply #76 on: October 22, 2013, 09:06:13 pm »
As stated, you access std::vector element past its size.
Back to C++ gamedev with SFML in May 2023

xzbobzx

  • Newbie
  • *
  • Posts: 26
    • View Profile
Re: 'Tiled' Tile-map Loader
« Reply #77 on: October 22, 2013, 09:07:15 pm »
As stated, you access std::vector element past its size.

So my map is too big?

I have no idea what it means.
« Last Edit: October 22, 2013, 09:19:47 pm by xzbobzx »

fallahn

  • Hero Member
  • *****
  • Posts: 507
  • Buns.
    • View Profile
    • Trederia
Re: 'Tiled' Tile-map Loader
« Reply #78 on: October 22, 2013, 09:23:52 pm »
erk. Can you provide me with a map / tileset that causes this?

xzbobzx

  • Newbie
  • *
  • Posts: 26
    • View Profile
Re: 'Tiled' Tile-map Loader
« Reply #79 on: October 22, 2013, 09:24:48 pm »
erk. Can you provide me with a map / tileset that causes this?

Here we go.

fallahn

  • Hero Member
  • *****
  • Posts: 507
  • Buns.
    • View Profile
    • Trederia
Re: 'Tiled' Tile-map Loader
« Reply #80 on: October 22, 2013, 09:31:00 pm »
Thanks. You didn't include the png file, but my first impression is that the loader doesn't like the path to the png file in the tsx file. As a work around try putting the png file in the same folder as the tsx and edit the tsx file so

<image source="../Projects/Minecraft.png" width="256" height="256"/>
 

becomes

<image source="Minecraft.png" width="256" height="256"/>
 

oh and the tsx / png should be in the same dir as the tmx file, which will need

<tileset firstgid="1" source="../../../../Tiled/Minecraft.tsx"/>
 

changing to

<tileset firstgid="1" source="Minecraft.tsx"/>
 
« Last Edit: October 22, 2013, 09:34:09 pm by fallahn »

xzbobzx

  • Newbie
  • *
  • Posts: 26
    • View Profile
Re: 'Tiled' Tile-map Loader
« Reply #81 on: October 22, 2013, 09:38:39 pm »
Thanks, the Minecraft.png was indeed in the same folder. I changed the <image source> bit but no luck, still gives me exactly the same error.

This is so weird.

edit: lemme try the tmx thing

xzbobzx

  • Newbie
  • *
  • Posts: 26
    • View Profile
Re: 'Tiled' Tile-map Loader
« Reply #82 on: October 22, 2013, 09:41:02 pm »
Works like a charm!

A bit more laggy than I hoped but then again 16x16 sprites are quite tiny. That and I'm multitasking while playing a game anyway.

Thanks so much!
« Last Edit: October 22, 2013, 09:44:19 pm by xzbobzx »

fallahn

  • Hero Member
  • *****
  • Posts: 507
  • Buns.
    • View Profile
    • Trederia
Re: 'Tiled' Tile-map Loader
« Reply #83 on: October 22, 2013, 09:51:48 pm »
No problem. It's a shame it doesn't really handle file paths properly but ISTR it involved either linking to boost::filesystem and I didn't want to add an extra dependency, or writing a proper file handler myself (which I'm too lazy to do :P ) I guess it ought to handle these errors a bit better though. I'll put it on the todo list for the next version.

zachprinz

  • Newbie
  • *
  • Posts: 18
    • View Profile
Re: 'Tiled' Tile-map Loader
« Reply #84 on: November 11, 2013, 11:43:55 pm »
There's a new feature in Tiled which is immensely helpful called "Collection of Images" tileset. It's xml code is a little different from the xml generated for regular tilesets and if I'm not missing something (hope I am) it throws off the map loader. I'm going to look and see if I can't find a fix for it in a little.

Just thought I'd let you know if you didn't already.

Love the map loader by the way.

fallahn

  • Hero Member
  • *****
  • Posts: 507
  • Buns.
    • View Profile
    • Trederia
Re: 'Tiled' Tile-map Loader
« Reply #85 on: November 12, 2013, 10:41:51 am »
Oh, thanks! I hadn't seen this yet, I shall definitely look into it. Once I get my act together I'll move the map loader to github so it'll be easier for other people to contribute  8)

zachprinz

  • Newbie
  • *
  • Posts: 18
    • View Profile
Re: 'Tiled' Tile-map Loader
« Reply #86 on: November 12, 2013, 05:59:36 pm »
Oh, thanks! I hadn't seen this yet, I shall definitely look into it. Once I get my act together I'll move the map loader to github so it'll be easier for other people to contribute  8)

I was able to get it working for my needs. However I've already modded how the loader draws image objects (which are the only things I use collection of images for) so my fix is fairly narrow and probably wouldn't help much.  I'll use yours as soon as you finish it, I'm sure it'll be much more complete.

Also Github would be awesome. I was honestly a little surprised you didn't make a separate thread for your loader considering its completely different from the original one posted here. Anyways, Thanks for all the work you do on it  :)

fallahn

  • Hero Member
  • *****
  • Posts: 507
  • Buns.
    • View Profile
    • Trederia
Re: 'Tiled' Tile-map Loader
« Reply #87 on: November 13, 2013, 12:33:29 pm »
Do you have any links/examples for Collection of Images tile sets? I can't seem to find anything about it on the Tiled site.

Also, as promised GitHub page :)

zachprinz

  • Newbie
  • *
  • Posts: 18
    • View Profile
Re: 'Tiled' Tile-map Loader
« Reply #88 on: November 13, 2013, 04:07:06 pm »
Do you have any links/examples for Collection of Images tile sets? I can't seem to find anything about it on the Tiled site.

Also, as promised GitHub page :)
Yeah, https://github.com/bjorn/tiled/blob/6221c0c6cfa6d8fdbcbacb7c360d0e4fb7180b45/docs/map.xsd is a link to the schema definition for the TMX (XML) files that get outputted. If you ctrl-f for "image.tileset" those are the changes that he made.

The actual changes to the xml are pretty minimal, where previously you would have a tileset arranged like this:

Quote
<tileset firstgid="" name="" tilewidth="" tileheight="">
     <image source="" width="" height=""/>
     <tile id="">
          <properties>
               <property name"" value=""/>
          </properties>
     </tile>
</tileset>

you now have

Quote
<tileset firstgid="" name="" tilewidth="" tileheight="">
     <!-- no image here-->
     <tile id="">
          <properties>
               <property name"" value=""/>
          </properties>
          <image source="" width="" height=""/>
     </tile>
</tileset>

Also he explains the new format on the page you linked in your github https://github.com/bjorn/tiled/wiki/TMX-Map-Format

Quote
<tileset ...>
    <tile id="[n]">
        <!-- an embedded image --> //Not sure what this is
        <image format="png"> //
            <data encoding="base64">//
                ...
            </data>//
        </image>//
    </tile>
    <tile id="[n]">
        <!-- an individually referenced image for a single tile -->
        <image source="file.png"/>
    </tile>
    ...
</tileset>
« Last Edit: November 13, 2013, 04:58:31 pm by zachprinz »

fallahn

  • Hero Member
  • *****
  • Posts: 507
  • Buns.
    • View Profile
    • Trederia
Re: 'Tiled' Tile-map Loader
« Reply #89 on: November 13, 2013, 04:56:10 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 :)

 

anything