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

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

0 Members and 2 Guests are viewing this topic.

fallahn

  • Sr. Member
  • ****
  • Posts: 492
  • Buns.
    • View Profile
    • Trederia
Re: 'Tiled' Tile-map Loader
« Reply #60 on: October 13, 2013, 09:51:25 pm »
That is indeed a linker error referring to zlib - although I've tried the loader with 1.2.8 and it works fine using the static build / VS11. Did you make sure to replace the zlib.h and zconf.h file included with the map loader with the ones from the newer version of zlib? (I really shouldn't have included the headers with the distribution, my bad)

The Ozzie

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: 'Tiled' Tile-map Loader
« Reply #61 on: October 16, 2013, 01:22:17 am »
Hate to bring up an old thread, but I keep getting this error and I can't find the source of it. I have everything linked properly and I've tried adding all of the files to the project. I'm using fallahn's code btw. And it seems that someone else had this problem but their fix didn't fix mine.

Error   2       error LNK2019: unresolved external symbol "public: virtual __thiscall tmx::MapLoader::~MapLoader(void)" (??1MapLoader@tmx@@UAE@XZ) referenced in function _main C:\Users\ozneh_000\Documents\Visual Studio 2012\Projects\FFF\FFF\main.obj       FFF
Error   3       error LNK2019: unresolved external symbol "public: bool const __thiscall tmx::MapLoader::Load(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?Load@MapLoader@tmx@@QAE?B_NABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) referenced in function _main   C:\Users\ozneh_000\Documents\Visual Studio 2012\Projects\FFF\FFF\main.obj       FFF
Error   4       error LNK2019: unresolved external symbol "public: void __thiscall tmx::MapLoader::Draw(class sf::RenderTarget &,enum tmx::MapLayer::DrawType)" (?Draw@MapLoader@tmx@@QAEXAAVRenderTarget@sf@@W4DrawType@MapLayer@2@@Z) referenced in function _main    C:\Users\ozneh_000\Documents\Visual Studio 2012\Projects\FFF\FFF\main.obj       FFF
Error   5       error LNK1120: 4 unresolved externals   C:\Users\ozneh_000\Documents\Visual Studio 2012\Projects\FFF\Debug\FFF.exe      1       1       FFF
 


fallahn

  • Sr. Member
  • ****
  • Posts: 492
  • Buns.
    • View Profile
    • Trederia
Re: 'Tiled' Tile-map Loader
« Reply #62 on: October 16, 2013, 10:27:38 am »
You've tried this? The linker can't find the symbols most likely because the correct obj file (MapLoaderPublic.obj) has not been compiled as the corresponding cpp file(s) are missing.

The Ozzie

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: 'Tiled' Tile-map Loader
« Reply #63 on: October 17, 2013, 03:04:14 am »
I have those added now, but I am getting even more errors.

Quote
Error   36   error LNK1120: 26 unresolved externals   C:\Users\ozneh_000\Documents\Visual Studio 2012\Projects\FFF\Debug\FFF.exe   FFF
Error   28   error LNK2001: unresolved external symbol "public: __thiscall pugi::xml_document::~xml_document(void)" (??1xml_document@pugi@@QAE@XZ)   C:\Users\ozneh_000\Documents\Visual Studio 2012\Projects\FFF\FFF\MapLoaderPublic.obj   FFF
Error   26   error LNK2001: unresolved external symbol "public: __thiscall pugi::xml_document::xml_document(void)" (??0xml_document@pugi@@QAE@XZ)   C:\Users\ozneh_000\Documents\Visual Studio 2012\Projects\FFF\FFF\MapLoaderPublic.obj   FFF
Error   10   error LNK2001: unresolved external symbol "public: __thiscall pugi::xml_node::operator void (__cdecl*)(class pugi::xml_node * * *)(void)const " (??Bxml_node@pugi@@QBEP6AXPAPAPAV01@@ZXZ)   C:\Users\ozneh_000\Documents\Visual Studio 2012\Projects\FFF\FFF\MapLoaderPublic.obj   FFF
Error   22   error LNK2001: unresolved external symbol "public: __thiscall pugi::xml_parse_result::operator bool(void)const " (??Bxml_parse_result@pugi@@QBE_NXZ)   C:\Users\ozneh_000\Documents\Visual Studio 2012\Projects\FFF\FFF\MapLoaderPublic.obj   FFF
Error   12   error LNK2001: unresolved external symbol "public: bool __thiscall pugi::xml_node::operator!(void)const " (??7xml_node@pugi@@QBE_NXZ)   C:\Users\ozneh_000\Documents\Visual Studio 2012\Projects\FFF\FFF\MapLoaderPublic.obj   FFF
Error   24   error LNK2001: unresolved external symbol "public: char const * __thiscall pugi::xml_parse_result::description(void)const " (?description@xml_parse_result@pugi@@QBEPBDXZ)   C:\Users\ozneh_000\Documents\Visual Studio 2012\Projects\FFF\FFF\MapLoaderPublic.obj   FFF
Error   17   error LNK2001: unresolved external symbol "public: class pugi::xml_node __thiscall pugi::xml_node::child(char const *)const " (?child@xml_node@pugi@@QBE?AV12@PBD@Z)   C:\Users\ozneh_000\Documents\Visual Studio 2012\Projects\FFF\FFF\MapLoaderPublic.obj   FFF
Error   14   error LNK2001: unresolved external symbol "public: class pugi::xml_node __thiscall pugi::xml_node::first_child(void)const " (?first_child@xml_node@pugi@@QBE?AV12@XZ)   C:\Users\ozneh_000\Documents\Visual Studio 2012\Projects\FFF\FFF\MapLoaderPublic.obj   FFF
Error   30   error LNK2001: unresolved external symbol "public: struct pugi::xml_parse_result __thiscall pugi::xml_document::load_file(char const *,unsigned int,enum pugi::xml_encoding)" (?load_file@xml_document@pugi@@QAE?AUxml_parse_result@2@PBDIW4xml_encoding@2@@Z)   C:\Users\ozneh_000\Documents\Visual Studio 2012\Projects\FFF\FFF\MapLoaderPublic.obj   FFF
Error   1   error LNK2019: unresolved external symbol "public: __thiscall pugi::xml_attribute::operator void (__cdecl*)(class pugi::xml_attribute * * *)(void)const " (??Bxml_attribute@pugi@@QBEP6AXPAPAPAV01@@ZXZ) referenced in function "private: bool const __thiscall tmx::MapLoader::m_ParseImageLayer(class pugi::xml_node const &)" (?m_ParseImageLayer@MapLoader@tmx@@AAE?B_NABVxml_node@pugi@@@Z)   C:\Users\ozneh_000\Documents\Visual Studio 2012\Projects\FFF\FFF\MapLoaderPrivate.obj   FFF
Error   27   error LNK2019: unresolved external symbol "public: __thiscall pugi::xml_document::~xml_document(void)" (??1xml_document@pugi@@QAE@XZ) referenced in function "private: bool const __thiscall tmx::MapLoader::m_ParseTileSets(class pugi::xml_node const &)" (?m_ParseTileSets@MapLoader@tmx@@AAE?B_NABVxml_node@pugi@@@Z)   C:\Users\ozneh_000\Documents\Visual Studio 2012\Projects\FFF\FFF\MapLoaderPrivate.obj   FFF
Error   25   error LNK2019: unresolved external symbol "public: __thiscall pugi::xml_document::xml_document(void)" (??0xml_document@pugi@@QAE@XZ) referenced in function "private: bool const __thiscall tmx::MapLoader::m_ParseTileSets(class pugi::xml_node const &)" (?m_ParseTileSets@MapLoader@tmx@@AAE?B_NABVxml_node@pugi@@@Z)   C:\Users\ozneh_000\Documents\Visual Studio 2012\Projects\FFF\FFF\MapLoaderPrivate.obj   FFF
Error   9   error LNK2019: unresolved external symbol "public: __thiscall pugi::xml_node::operator void (__cdecl*)(class pugi::xml_node * * *)(void)const " (??Bxml_node@pugi@@QBEP6AXPAPAPAV01@@ZXZ) referenced in function "private: bool const __thiscall tmx::MapLoader::m_ParseImageLayer(class pugi::xml_node const &)" (?m_ParseImageLayer@MapLoader@tmx@@AAE?B_NABVxml_node@pugi@@@Z)   C:\Users\ozneh_000\Documents\Visual Studio 2012\Projects\FFF\FFF\MapLoaderPrivate.obj   FFF
Error   8   error LNK2019: unresolved external symbol "public: __thiscall pugi::xml_node::xml_node(void)" (??0xml_node@pugi@@QAE@XZ) referenced in function "private: bool const __thiscall tmx::MapLoader::m_ParseImageLayer(class pugi::xml_node const &)" (?m_ParseImageLayer@MapLoader@tmx@@AAE?B_NABVxml_node@pugi@@@Z)   C:\Users\ozneh_000\Documents\Visual Studio 2012\Projects\FFF\FFF\MapLoaderPrivate.obj   FFF
Error   21   error LNK2019: unresolved external symbol "public: __thiscall pugi::xml_parse_result::operator bool(void)const " (??Bxml_parse_result@pugi@@QBE_NXZ) referenced in function "private: bool const __thiscall tmx::MapLoader::m_ParseTileSets(class pugi::xml_node const &)" (?m_ParseTileSets@MapLoader@tmx@@AAE?B_NABVxml_node@pugi@@@Z)   C:\Users\ozneh_000\Documents\Visual Studio 2012\Projects\FFF\FFF\MapLoaderPrivate.obj   FFF
Error   7   error LNK2019: unresolved external symbol "public: bool __thiscall pugi::xml_attribute::as_bool(bool)const " (?as_bool@xml_attribute@pugi@@QBE_N_N@Z) referenced in function "private: bool const __thiscall tmx::MapLoader::m_ParseLayer(class pugi::xml_node const &)" (?m_ParseLayer@MapLoader@tmx@@AAE?B_NABVxml_node@pugi@@@Z)   C:\Users\ozneh_000\Documents\Visual Studio 2012\Projects\FFF\FFF\MapLoaderPrivate.obj   FFF
Error   2   error LNK2019: unresolved external symbol "public: bool __thiscall pugi::xml_attribute::operator!(void)const " (??7xml_attribute@pugi@@QBE_NXZ) referenced in function "private: bool const __thiscall tmx::MapLoader::m_ParseImageLayer(class pugi::xml_node const &)" (?m_ParseImageLayer@MapLoader@tmx@@AAE?B_NABVxml_node@pugi@@@Z)   C:\Users\ozneh_000\Documents\Visual Studio 2012\Projects\FFF\FFF\MapLoaderPrivate.obj   FFF
Error   11   error LNK2019: unresolved external symbol "public: bool __thiscall pugi::xml_node::operator!(void)const " (??7xml_node@pugi@@QBE_NXZ) referenced in function "private: bool const __thiscall tmx::MapLoader::m_ParseImageLayer(class pugi::xml_node const &)" (?m_ParseImageLayer@MapLoader@tmx@@AAE?B_NABVxml_node@pugi@@@Z)   C:\Users\ozneh_000\Documents\Visual Studio 2012\Projects\FFF\FFF\MapLoaderPrivate.obj   FFF
Error   3   error LNK2019: unresolved external symbol "public: char const * __thiscall pugi::xml_attribute::as_string(char const *)const " (?as_string@xml_attribute@pugi@@QBEPBDPBD@Z) referenced in function "private: bool const __thiscall tmx::MapLoader::m_ParseImageLayer(class pugi::xml_node const &)" (?m_ParseImageLayer@MapLoader@tmx@@AAE?B_NABVxml_node@pugi@@@Z)   C:\Users\ozneh_000\Documents\Visual Studio 2012\Projects\FFF\FFF\MapLoaderPrivate.obj   FFF
Error   34   error LNK2019: unresolved external symbol "public: char const * __thiscall pugi::xml_node::name(void)const " (?name@xml_node@pugi@@QBEPBDXZ) referenced in function "public: bool const __thiscall tmx::MapLoader::Load(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?Load@MapLoader@tmx@@QAE?B_NABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)   C:\Users\ozneh_000\Documents\Visual Studio 2012\Projects\FFF\FFF\MapLoaderPublic.obj   FFF
Error   23   error LNK2019: unresolved external symbol "public: char const * __thiscall pugi::xml_parse_result::description(void)const " (?description@xml_parse_result@pugi@@QBEPBDXZ) referenced in function "private: bool const __thiscall tmx::MapLoader::m_ParseTileSets(class pugi::xml_node const &)" (?m_ParseTileSets@MapLoader@tmx@@AAE?B_NABVxml_node@pugi@@@Z)   C:\Users\ozneh_000\Documents\Visual Studio 2012\Projects\FFF\FFF\MapLoaderPrivate.obj   FFF
Error   20   error LNK2019: unresolved external symbol "public: char const * __thiscall pugi::xml_text::as_string(char const *)const " (?as_string@xml_text@pugi@@QBEPBDPBD@Z) referenced in function "private: bool const __thiscall tmx::MapLoader::m_ParseLayer(class pugi::xml_node const &)" (?m_ParseLayer@MapLoader@tmx@@AAE?B_NABVxml_node@pugi@@@Z)   C:\Users\ozneh_000\Documents\Visual Studio 2012\Projects\FFF\FFF\MapLoaderPrivate.obj   FFF
Error   18   error LNK2019: unresolved external symbol "public: class pugi::xml_attribute __thiscall pugi::xml_node::attribute(char const *)const " (?attribute@xml_node@pugi@@QBE?AVxml_attribute@2@PBD@Z) referenced in function "private: bool const __thiscall tmx::MapLoader::m_ParseImageLayer(class pugi::xml_node const &)" (?m_ParseImageLayer@MapLoader@tmx@@AAE?B_NABVxml_node@pugi@@@Z)   C:\Users\ozneh_000\Documents\Visual Studio 2012\Projects\FFF\FFF\MapLoaderPrivate.obj   FFF
Error   16   error LNK2019: unresolved external symbol "public: class pugi::xml_node __thiscall pugi::xml_node::child(char const *)const " (?child@xml_node@pugi@@QBE?AV12@PBD@Z) referenced in function "private: bool const __thiscall tmx::MapLoader::m_ParseImageLayer(class pugi::xml_node const &)" (?m_ParseImageLayer@MapLoader@tmx@@AAE?B_NABVxml_node@pugi@@@Z)   C:\Users\ozneh_000\Documents\Visual Studio 2012\Projects\FFF\FFF\MapLoaderPrivate.obj   FFF
Error   13   error LNK2019: unresolved external symbol "public: class pugi::xml_node __thiscall pugi::xml_node::first_child(void)const " (?first_child@xml_node@pugi@@QBE?AV12@XZ) referenced in function "private: bool const __thiscall tmx::MapLoader::m_ParseObjectgroup(class pugi::xml_node const &)" (?m_ParseObjectgroup@MapLoader@tmx@@AAE?B_NABVxml_node@pugi@@@Z)   C:\Users\ozneh_000\Documents\Visual Studio 2012\Projects\FFF\FFF\MapLoaderPrivate.obj   FFF
Error   19   error LNK2019: unresolved external symbol "public: class pugi::xml_node __thiscall pugi::xml_node::next_sibling(char const *)const " (?next_sibling@xml_node@pugi@@QBE?AV12@PBD@Z) referenced in function "private: bool const __thiscall tmx::MapLoader::m_ParseLayer(class pugi::xml_node const &)" (?m_ParseLayer@MapLoader@tmx@@AAE?B_NABVxml_node@pugi@@@Z)   C:\Users\ozneh_000\Documents\Visual Studio 2012\Projects\FFF\FFF\MapLoaderPrivate.obj   FFF
Error   35   error LNK2019: unresolved external symbol "public: class pugi::xml_node __thiscall pugi::xml_node::next_sibling(void)const " (?next_sibling@xml_node@pugi@@QBE?AV12@XZ) referenced in function "public: bool const __thiscall tmx::MapLoader::Load(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?Load@MapLoader@tmx@@QAE?B_NABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)   C:\Users\ozneh_000\Documents\Visual Studio 2012\Projects\FFF\FFF\MapLoaderPublic.obj   FFF
Error   15   error LNK2019: unresolved external symbol "public: class pugi::xml_text __thiscall pugi::xml_node::text(void)const " (?text@xml_node@pugi@@QBE?AVxml_text@2@XZ) referenced in function "private: bool const __thiscall tmx::MapLoader::m_ParseLayer(class pugi::xml_node const &)" (?m_ParseLayer@MapLoader@tmx@@AAE?B_NABVxml_node@pugi@@@Z)   C:\Users\ozneh_000\Documents\Visual Studio 2012\Projects\FFF\FFF\MapLoaderPrivate.obj   FFF
Error   6   error LNK2019: unresolved external symbol "public: float __thiscall pugi::xml_attribute::as_float(float)const " (?as_float@xml_attribute@pugi@@QBEMM@Z) referenced in function "private: bool const __thiscall tmx::MapLoader::m_ParseImageLayer(class pugi::xml_node const &)" (?m_ParseImageLayer@MapLoader@tmx@@AAE?B_NABVxml_node@pugi@@@Z)   C:\Users\ozneh_000\Documents\Visual Studio 2012\Projects\FFF\FFF\MapLoaderPrivate.obj   FFF
Error   4   error LNK2019: unresolved external symbol "public: int __thiscall pugi::xml_attribute::as_int(int)const " (?as_int@xml_attribute@pugi@@QBEHH@Z) referenced in function "private: bool const __thiscall tmx::MapLoader::m_ParseLayer(class pugi::xml_node const &)" (?m_ParseLayer@MapLoader@tmx@@AAE?B_NABVxml_node@pugi@@@Z)   C:\Users\ozneh_000\Documents\Visual Studio 2012\Projects\FFF\FFF\MapLoaderPrivate.obj   FFF
Error   29   error LNK2019: unresolved external symbol "public: struct pugi::xml_parse_result __thiscall pugi::xml_document::load_file(char const *,unsigned int,enum pugi::xml_encoding)" (?load_file@xml_document@pugi@@QAE?AUxml_parse_result@2@PBDIW4xml_encoding@2@@Z) referenced in function "private: bool const __thiscall tmx::MapLoader::m_ParseTileSets(class pugi::xml_node const &)" (?m_ParseTileSets@MapLoader@tmx@@AAE?B_NABVxml_node@pugi@@@Z)   C:\Users\ozneh_000\Documents\Visual Studio 2012\Projects\FFF\FFF\MapLoaderPrivate.obj   FFF
Error   5   error LNK2019: unresolved external symbol "public: unsigned int __thiscall pugi::xml_attribute::as_uint(unsigned int)const " (?as_uint@xml_attribute@pugi@@QBEII@Z) referenced in function "private: bool const __thiscall tmx::MapLoader::m_ProcessTiles(class pugi::xml_node const &)" (?m_ProcessTiles@MapLoader@tmx@@AAE?B_NABVxml_node@pugi@@@Z)   C:\Users\ozneh_000\Documents\Visual Studio 2012\Projects\FFF\FFF\MapLoaderPrivate.obj   FFF
Error   31   error LNK2019: unresolved external symbol _inflate referenced in function "private: bool const __thiscall tmx::MapLoader::m_Decompress(char const *,class std::vector<unsigned char,class std::allocator<unsigned char> > &,int,int)" (?m_Decompress@MapLoader@tmx@@AAE?B_NPBDAAV?$vector@EV?$allocator@E@std@@@std@@HH@Z)   C:\Users\ozneh_000\Documents\Visual Studio 2012\Projects\FFF\FFF\MapLoaderPrivate.obj   FFF
Error   32   error LNK2019: unresolved external symbol _inflateEnd referenced in function "private: bool const __thiscall tmx::MapLoader::m_Decompress(char const *,class std::vector<unsigned char,class std::allocator<unsigned char> > &,int,int)" (?m_Decompress@MapLoader@tmx@@AAE?B_NPBDAAV?$vector@EV?$allocator@E@std@@@std@@HH@Z)   C:\Users\ozneh_000\Documents\Visual Studio 2012\Projects\FFF\FFF\MapLoaderPrivate.obj   FFF
Error   33   error LNK2019: unresolved external symbol _inflateInit2_ referenced in function "private: bool const __thiscall tmx::MapLoader::m_Decompress(char const *,class std::vector<unsigned char,class std::allocator<unsigned char> > &,int,int)" (?m_Decompress@MapLoader@tmx@@AAE?B_NPBDAAV?$vector@EV?$allocator@E@std@@@std@@HH@Z)   C:\Users\ozneh_000\Documents\Visual Studio 2012\Projects\FFF\FFF\MapLoaderPrivate.obj   FFF

Sorry, I know that's a lot.

wintertime

  • Sr. Member
  • ****
  • Posts: 255
    • View Profile
Re: 'Tiled' Tile-map Loader
« Reply #64 on: October 17, 2013, 09:53:27 am »
Its so easy, just read the messages and you see "LNK" and "unresolved external symbols" and many function names. That means you did not LiNK a number of external symbols, namely functions and from the names they belong to "pugi" and "zlib".
Now just add those libraries in the project settings and/or adjust the library search path so they can be found and linked... ;)

fallahn

  • Sr. Member
  • ****
  • Posts: 492
  • Buns.
    • View Profile
    • Trederia
Re: 'Tiled' Tile-map Loader
« Reply #65 on: October 17, 2013, 11:06:37 am »
FWIW the VS2012 project settings for the demo project (included in the archive) look like this:



assuming you are linking statically

The Ozzie

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: 'Tiled' Tile-map Loader
« Reply #66 on: October 17, 2013, 11:06:51 pm »
Okay, I think it's a zlib problem. Here are my configs:



Then in c/c++ General -> additional include directories:

C:\SFML-2.1\include;C:\Users\ozneh_000\Documents\TmxMapLoader\include

Linker -> general - > Additional library dependencies

C:\SFML-2.1\lib

Linker -> input -> Additional dependencies

zlibstat.lib;sfml-graphics-d.lib;sfml-window-d.lib;sfml-audio-d.lib;sfml-system-d.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)

And the errors i'm getting now are about the m_Decompress function in the MapLoader class:

Quote
Error   2   error LNK2019: unresolved external symbol _inflate referenced in function "private: bool const __thiscall tmx::MapLoader::m_Decompress(char const *,class std::vector<unsigned char,class std::allocator<unsigned char> > &,int,int)" (?m_Decompress@MapLoader@tmx@@AAE?B_NPBDAAV?$vector@EV?$allocator@E@std@@@std@@HH@Z)   C:\Users\ozneh_000\Documents\Visual Studio 2012\Projects\FFF\FFF\MapLoaderPrivate.obj   FFF
Error   3   error LNK2019: unresolved external symbol _inflateEnd referenced in function "private: bool const __thiscall tmx::MapLoader::m_Decompress(char const *,class std::vector<unsigned char,class std::allocator<unsigned char> > &,int,int)" (?m_Decompress@MapLoader@tmx@@AAE?B_NPBDAAV?$vector@EV?$allocator@E@std@@@std@@HH@Z)   C:\Users\ozneh_000\Documents\Visual Studio 2012\Projects\FFF\FFF\MapLoaderPrivate.obj   FFF
Error   4   error LNK2019: unresolved external symbol _inflateInit2_ referenced in function "private: bool const __thiscall tmx::MapLoader::m_Decompress(char const *,class std::vector<unsigned char,class std::allocator<unsigned char> > &,int,int)" (?m_Decompress@MapLoader@tmx@@AAE?B_NPBDAAV?$vector@EV?$allocator@E@std@@@std@@HH@Z)   C:\Users\ozneh_000\Documents\Visual Studio 2012\Projects\FFF\FFF\MapLoaderPrivate.obj   FFF

Thanks for all the help guys

fallahn

  • Sr. Member
  • ****
  • Posts: 492
  • Buns.
    • View Profile
    • Trederia
Re: 'Tiled' Tile-map Loader
« Reply #67 on: October 17, 2013, 11:23:55 pm »
You need to download and compile zlib, and copy the resulting zlib/zlibstat.lib file to your lib directory. Google will point you in the right direction :-)

The Ozzie

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: 'Tiled' Tile-map Loader
« Reply #68 on: October 18, 2013, 01:14:15 am »
This is reaaally bothering me that this isn't working. Is it possible for me to message you somewhere like skype where it is instant messaging? I really appreciate your help.

wintertime

  • Sr. Member
  • ****
  • Posts: 255
    • View Profile
Re: 'Tiled' Tile-map Loader
« Reply #69 on: October 18, 2013, 01:51:48 am »
Just go to zlib.net, scroll down a bit and get the package with the DLL. :P

The Ozzie

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: 'Tiled' Tile-map Loader
« Reply #70 on: October 18, 2013, 02:06:14 am »
Just go to zlib.net, scroll down a bit and get the package with the DLL. :P

My god. You fixed it! Thank you so much. I can't believe it was that simple

The Ozzie

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: 'Tiled' Tile-map Loader
« Reply #71 on: October 18, 2013, 06:43:45 am »
Alright one last thing, is there anyway to return a tile number? I plan on doing collision like

if (player.intersects(dirtTile)) { //collision here }

Or how would you implement collision with your engine?

Thanks

fallahn

  • Sr. Member
  • ****
  • Posts: 492
  • Buns.
    • View Profile
    • Trederia
Re: 'Tiled' Tile-map Loader
« Reply #72 on: October 18, 2013, 10:53:50 am »
You can't access an individual tile as there is no discreet tile data as such, each layer is a group of vertices in an array representing multiple tiles (see the SFML vertex array tutorial for how this works). The map loader takes the approach of using Objects, defined in Tiled, which represent areas which you might query for collision. The objects are available either via the GetLayers() function where each layer has a vector of MapObjects which belong to that layer, or you can retrieve an optimised vector of pointers to MapObjects via the QuadTree. The MapObject class itself then has functions like Intersects(MapObject) or Contains(point) which can be used for rudimentary collision detection. You can, of course, add more functions to the MapObject class to help with custom collision testing. There's an example of using the QuadTree here.

CodingNewbie

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: 'Tiled' Tile-map Loader
« Reply #73 on: October 19, 2013, 02:17:55 am »
First of all, thank you creating such a useful tool.  It is much appreciated :).

Alright, now, I've been trying to figure out a way to handle collision with your code, but I'm coming up short.  If I create more than 2 layers on a Tiled map, the layers don't look right when they load.  So, I made 1 .tmx with 2 layers (which is all visable tiles), and then a second .tmx with a single layer with invisible tiles (for collision).  I've been trying every method I could find to load the tiles from the Collision.tmx and not allow the animatedSprite to pass through them, but nothing is working.  Here is my code at the moment:

#include "stdafx.h"
#include "zlib.h"
#include "MapLoader.h"
#include "AnimatedSprite.h"
#include "Animation.h"
#include "zconf.h"
#include <luabind/luabind.hpp>
#include <SFML/System.hpp>
#include <SFML/Window.hpp>
#include <SFML/Graphics.hpp>
#include <SFML/Audio.hpp>
#include <string>
#include <iostream>

int main()
{
    sf::Vector2i screenDimensions(720, 420);
    sf::RenderWindow window(sf::VideoMode(screenDimensions.x, screenDimensions.y), "Pokemon Clone");

    // load texture
    sf::Texture texture;
    texture.loadFromFile("Player.png");

        //create map loader and load map
        tmx::MapLoader ml("Maps/");
        tmx::MapLoader mll("Maps/");
        ml.Load("Pallet Town.tmx");
        mll.Load("Collision.tmx");


    // push frames
    Animation walkingAnimationDown;
    walkingAnimationDown.setSpriteSheet(texture);
        walkingAnimationDown.addFrame(sf::IntRect(16, 0, 16, 20));
    walkingAnimationDown.addFrame(sf::IntRect(32, 0, 16, 20));
    walkingAnimationDown.addFrame(sf::IntRect(16, 0, 16, 20));
    walkingAnimationDown.addFrame(sf::IntRect(0, 0, 16, 20));

    Animation walkingAnimationLeft;
    walkingAnimationLeft.setSpriteSheet(texture);
    walkingAnimationLeft.addFrame(sf::IntRect(16, 40, 16, 20));
    walkingAnimationLeft.addFrame(sf::IntRect(32, 40, 16, 20));
    walkingAnimationLeft.addFrame(sf::IntRect(16, 40, 16, 20));
    walkingAnimationLeft.addFrame(sf::IntRect(0, 40, 16, 20));

    Animation walkingAnimationRight;
    walkingAnimationRight.setSpriteSheet(texture);
    walkingAnimationRight.addFrame(sf::IntRect(16, 60, 16, 20));
    walkingAnimationRight.addFrame(sf::IntRect(32, 60, 16, 20));
    walkingAnimationRight.addFrame(sf::IntRect(16, 60, 16, 20));
    walkingAnimationRight.addFrame(sf::IntRect(0, 60, 16, 20));

    Animation walkingAnimationUp;
    walkingAnimationUp.setSpriteSheet(texture);
        walkingAnimationUp.addFrame(sf::IntRect(16, 20, 16, 20));
    walkingAnimationUp.addFrame(sf::IntRect(32, 20, 16, 20));
    walkingAnimationUp.addFrame(sf::IntRect(16, 20, 16, 20));
    walkingAnimationUp.addFrame(sf::IntRect(0, 20, 16, 20));

    // set up AnimatesSprite
    AnimatedSprite animatedSprite(sf::seconds(0.13));
    animatedSprite.setAnimation(walkingAnimationDown);
    animatedSprite.pause();
    animatedSprite.setPosition(700, 400);
       
    sf::Clock frameClock;

        sf::Music music;

        if(!music.openFromFile("Pallet Town Theme.ogg"))
                std::cout << "ERROR: Can't find Pallet Town Theme.ogg" << std::endl;

        music.play();
        music.setLoop(true);

    float speed = 0.045f;
    bool bNoKeyWasPressed = true;

    while (window.isOpen())
    {
        sf::Event event;
        while (window.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
                window.close();
            if (event.type == sf::Event::KeyPressed && event.key.code == sf::Keyboard::Escape)
                window.close();
                        if (event.type == sf::Event::LostFocus)
                        {
                                music.pause();
                               
                        }
                        if (event.type == sf::Event::GainedFocus)
                                music.play();
        }
               
        if(sf::Keyboard::isKeyPressed(sf::Keyboard::Up))
        {
            if(animatedSprite.getAnimation() != &walkingAnimationUp)
            {
                 animatedSprite.setAnimation(walkingAnimationUp);
            }
            animatedSprite.play();
                        animatedSprite.move(0, -speed);
                        animatedSprite.move(0, 0);
            bNoKeyWasPressed = false;
        }
        else if(sf::Keyboard::isKeyPressed(sf::Keyboard::Down))
        {
            if(animatedSprite.getAnimation() != &walkingAnimationDown)
            {
                animatedSprite.setAnimation(walkingAnimationDown);
            }
            animatedSprite.play();
            animatedSprite.move(0, speed);
            bNoKeyWasPressed = false;
        }
        else if(sf::Keyboard::isKeyPressed(sf::Keyboard::Right))
        {
            if(animatedSprite.getAnimation() != &walkingAnimationRight)
            {
                animatedSprite.setAnimation(walkingAnimationRight);
            }
            animatedSprite.play();
            animatedSprite.move(speed, 0);
            bNoKeyWasPressed = false;
        }
        else if(sf::Keyboard::isKeyPressed(sf::Keyboard::Left))
        {
            if(animatedSprite.getAnimation() != &walkingAnimationLeft)
            {
                animatedSprite.setAnimation(walkingAnimationLeft);
            }
            animatedSprite.play();
            animatedSprite.move(-speed, 0);
            bNoKeyWasPressed = false;
        }

        else if(bNoKeyWasPressed)
        {
            animatedSprite.pause();
        }
        bNoKeyWasPressed = true;

        // update AnimatedSprite
        animatedSprite.update(frameClock.restart());

        window.clear();
                window.draw(ml);
                ml.Draw(window, tmx::MapLayer::Back);
                window.draw(animatedSprite);
                ml.Draw(window, tmx::MapLayer::Front);
                mll.Draw(window, tmx::MapLayer::All);

        window.display();
    }

    return 0;
}
 

fallahn

  • Sr. Member
  • ****
  • Posts: 492
  • Buns.
    • View Profile
    • Trederia
Re: 'Tiled' Tile-map Loader (Collision testing)
« Reply #74 on: October 19, 2013, 11:08:12 am »
You can set the transparency of a layer via a slider in Tiled, which will allow you to hide layers if you need to. On the other hand I handle collision detection slightly differently - my reply became rather lengthy, so I've turned it into a blog post here. Hope it helps :)

 

anything