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

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

0 Members and 3 Guests are viewing this topic.

fallahn

  • Hero Member
  • *****
  • Posts: 507
  • Buns.
    • View Profile
    • Trederia
Re: 'Tiled' Tile-map Loader
« Reply #45 on: September 14, 2013, 12:29:34 pm »
I guess it depends on how you use the quad tree. if you had a large world which needed to maintain the position of all the objects within it then building the tree once and adding/removing objects would probably be more efficient. In my racing game both the vehicle and the view move, however, and most of the initial culling is done simply by ignoring everything which isn't visible (as there is no way the car will collide with anything outside the view). Because the view is moving it effectively moves the root node and therefore necessitates rebuilding each time. It's no real performance hit anyway, I can render over 3000fps on my machine at work :) The quad tree node class is pretty flexible and I'm sure it wouldn't take much to modify it to allow for adding / removing objects as they move if anyone needed it. FWIW the quad tree code is based on this article.

The car game itself has come a long way since (it doesn't even have cars any more...) and won't have a rotating view as I have very specific ideas for it. I'm glad you like what you see, however ;) Eventually I will post something about it in the projects forum.

Jove

  • Full Member
  • ***
  • Posts: 114
    • View Profile
    • http://www.jestofevekites.com/
Re: 'Tiled' Tile-map Loader
« Reply #46 on: September 14, 2013, 02:15:05 pm »
That's fair comment. My world simulation is quite large with stuff interacting off-screen, so yeah.
{much better code}

mflash

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: 'Tiled' Tile-map Loader
« Reply #47 on: September 14, 2013, 08:25:16 pm »
Well, in fact I'm trying to get an undergraduate class to understand the basic principles of collision detection in games, so a tile layer with collision info seemed to be the easiest way. It's also very quick to put it together in Tiled, for instance. But of course you're right: it depends on the particular application. A quadtree is usually a sensible idea, but it just seemed overkill in my case  :)

BigZiggityZ

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: 'Tiled' Tile-map Loader
« Reply #48 on: September 21, 2013, 03:45:58 am »
I'm trying to use your code, which looks great by the way. Whenever I call a function, I get an unresolved external symbol error message. My guess would be I didn't set it up correctly. I'm using visual studio 2012. I went into the project properties and added the "include" directory to the additional includes field. Is there anything else I need to do? Thanks!

zsbzsb

  • Hero Member
  • *****
  • Posts: 1409
  • Active Maintainer of CSFML/SFML.NET
    • View Profile
    • My little corner...
    • Email
Re: 'Tiled' Tile-map Loader
« Reply #49 on: September 21, 2013, 05:36:20 am »
I went into the project properties and added the "include" directory to the additional includes field. Is there anything else I need to do? Thanks!

Well ever consider that even 'Tiled' needs libs?
Motion / MotionNET - Complete video / audio playback for SFML / SFML.NET

NetEXT - An SFML.NET Extension Library based on Thor

fallahn

  • Hero Member
  • *****
  • Posts: 507
  • Buns.
    • View Profile
    • Trederia
Re: 'Tiled' Tile-map Loader
« Reply #50 on: September 21, 2013, 09:53:15 am »
Well you don't say what the errors actually are, but at a guess I would say you need to link zlib 1.2.7 or higher, as mentioned in the included readme

BigZiggityZ

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: 'Tiled' Tile-map Loader
« Reply #51 on: September 22, 2013, 08:47:42 pm »
Okay, I have linked zlib, and I am still getting the errors. Here's my code:

#include <MapLoader.h>
#include <SFML/Graphics.hpp>

int main()
{
        tmx::MapLoader myLoader("resources/maps/");
        myLoader.Load("rpgtest.tmx");
        sf::RenderWindow window(sf::VideoMode(300, 300), "TEST");
        while (window.isOpen())
        {
                sf::Event event;
        while (window.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
                        {
                window.close();
                        }
                }
                window.clear();
                myLoader.Draw(window);
                window.display();
        }
}

And the error messages:
Quote
1>------ Build started: Project: RPGengine, Configuration: Debug Win32 ------
1>  main.cpp
1>main.obj : error LNK2019: unresolved external symbol "public: __thiscall tmx::MapLoader::MapLoader(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (??0MapLoader@tmx@@QAE@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "public: __thiscall tmx::MapLoader::~MapLoader(void)" (??1MapLoader@tmx@@QAE@XZ) referenced in function _main
1>main.obj : 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> >)" (?Load@MapLoader@tmx@@QAE?B_NV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "public: void __thiscall tmx::MapLoader::Draw(class sf::RenderTarget &)" (?Draw@MapLoader@tmx@@QAEXAAVRenderTarget@sf@@@Z) referenced in function _main
1>D:\Documents\Programming\C++\SFML Games\RPGengine\Debug\RPGengine.exe : fatal error LNK1120: 4 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

fallahn

  • Hero Member
  • *****
  • Posts: 507
  • Buns.
    • View Profile
    • Trederia
Re: 'Tiled' Tile-map Loader
« Reply #52 on: September 22, 2013, 09:30:59 pm »
hmm. Sounds like you haven't added the cpp files to your project

BigZiggityZ

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: 'Tiled' Tile-map Loader
« Reply #53 on: September 23, 2013, 02:43:54 am »
Good lord, I am a moron. It's working beautifully. Thanks!

Epiplon

  • Newbie
  • *
  • Posts: 12
    • View Profile
    • Email
Re: 'Tiled' Tile-map Loader
« Reply #54 on: September 24, 2013, 06:14:49 pm »
Hi!
Is it possible to compile it to a .dll? Any instructions on how I can achieve that?
I'm trying to use it on a C# project.

fallahn

  • Hero Member
  • *****
  • Posts: 507
  • Buns.
    • View Profile
    • Trederia
Re: 'Tiled' Tile-map Loader
« Reply #55 on: September 24, 2013, 07:13:54 pm »
The broad answer is 'probably, yes' - but I wouldn't know how to. I think it would work better as a straight port to the C# binding of SFML as I believe there is also a C# binding for zlib (which the class relies on) and the pugixml stuff can be replaced as .net/mono has direct support for XML.

zsbzsb

  • Hero Member
  • *****
  • Posts: 1409
  • Active Maintainer of CSFML/SFML.NET
    • View Profile
    • My little corner...
    • Email
Re: 'Tiled' Tile-map Loader
« Reply #56 on: September 24, 2013, 08:55:54 pm »
Hi!
Is it possible to compile it to a .dll? Any instructions on how I can achieve that?
I'm trying to use it on a C# project.

You have two options here, either do a native port of 'Tiled' directly in C# or write a C function style interface and then use P/Invoke to call the C functions which will then call the C++ code. If are serious about having 'Tiled' in .NET I would recommend you go with the first option since it seems you are probably not familiar with writing C code and manual memory management with everything that entails.
« Last Edit: September 24, 2013, 09:00:12 pm by zsbzsb »
Motion / MotionNET - Complete video / audio playback for SFML / SFML.NET

NetEXT - An SFML.NET Extension Library based on Thor

Epiplon

  • Newbie
  • *
  • Posts: 12
    • View Profile
    • Email
Re: 'Tiled' Tile-map Loader
« Reply #57 on: September 25, 2013, 06:13:32 pm »
do a native port of 'Tiled' directly in C#

Well, it seems the best option then. I know dynamic memory allocation in C, but it's a lot of work for now.
So I've already started a native C# project and hope to see it functioning in a few days.  :)

Thanks!

zsbzsb

  • Hero Member
  • *****
  • Posts: 1409
  • Active Maintainer of CSFML/SFML.NET
    • View Profile
    • My little corner...
    • Email
Re: 'Tiled' Tile-map Loader
« Reply #58 on: September 25, 2013, 06:34:51 pm »
Well, it seems the best option then. I know dynamic memory allocation in C, but it's a lot of work for now.
So I've already started a native C# project and hope to see it functioning in a few days.  :)

That sounds great, I am sure your port will be used  :)
Motion / MotionNET - Complete video / audio playback for SFML / SFML.NET

NetEXT - An SFML.NET Extension Library based on Thor

rooski

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: 'Tiled' Tile-map Loader
« Reply #59 on: October 13, 2013, 02:43:33 am »
ive linked everything and i get this compile error complaining about what i assume is zlib...

\TmxMapLoader\src\MapLoaderPrivate.cpp|830|undefined reference to `inflateInit2_'

could i be because im using zlib 1.2.8 ?

 

anything