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

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

0 Members and 4 Guests are viewing this topic.

zmertens

  • Jr. Member
  • **
  • Posts: 80
    • View Profile
Re: 'Tiled' Tile-map Loader
« Reply #165 on: May 01, 2014, 08:49:16 am »
Simpl,

I had CMake errors with an SFML project last week and I needed to have SFML_ROOT defined in the path variables. And SFML_ROOT would link to where my SFML libraries are located on my computer ( specifically the Cmake folder in SFML ). I'm not sure if that'll help you. It looks like you need a destination to install though, did you specify a destination in the "where to build the binaries" if you're using CMake GUI?
The truth will set you free but first it will piss you off.

fallahn

  • Hero Member
  • *****
  • Posts: 507
  • Buns.
    • View Profile
    • Trederia
Re: 'Tiled' Tile-map Loader
« Reply #166 on: May 01, 2014, 10:48:58 am »
I'm assuming you're trying to build on windows. There's a line which installs the pugixml lib on linux which should have an 'if(UNIX)' condition which I haven't added yet. Commenting this out should fix it for now.

MJBrune

  • Newbie
  • *
  • Posts: 13
    • View Profile
    • Email
Re: 'Tiled' Tile-map Loader
« Reply #167 on: June 05, 2014, 08:16:54 am »
I'm currently having issues with the TMX loader and setting object's visablity to false to have them not drawn.

if (handleEvent.type == sf::Event::EventType::KeyPressed && sf::Keyboard::isKeyPressed(sf::Keyboard::E))
                for(auto layer = ml.GetLayers().begin(); layer != ml.GetLayers().end(); ++layer)
                {
                        if(layer->name == "Interactables")
                        {
                                for(auto object = layer->objects.begin(); object != layer->objects.end(); ++object)
                                {
                                        if (object->Contains(sf::Vector2f(tankSprite.getPosition().x, tankSprite.getPosition().y)))
                                        {
                                                if (object->GetType() == "Computer")
                                                {
                                                        for(auto object2 = layer->objects.begin(); object2 != layer->objects.end(); ++object2)
                                                        {
                                                                if (object2->GetType() == "Laser")
                                                                        if (object2->GetName() == object->GetName())
                                                                        {
                                                                                object2->SetVisible(false);
                                                                                object2->SetProperty("State", "Off");
                                                                        }
                                                        }
                                                }
                                        }
                                }
                        }
                }
That's how I am doing it but when I look at the map the object is still being drawn. I've checked to make sure the objects I want are not being set to visable when drawn with
for(auto layer = ml.GetLayers().begin(); layer != ml.GetLayers().end(); ++layer)
        {
                if(layer->name == "Interactables")
                {
                        for(auto object = layer->objects.begin(); object != layer->objects.end(); ++object)
                        {
                                if (object->Visible())
                                        std::cout << "STILL THERE! " << object->GetType() << std::endl;
                        }
                }
        }

Sorry if this code is rather sloppy, I've been quickly writing it as a proof of concept for tmx loader. Any insight to what I am doing wrong and why the objects are still being drawn on the screen would be greatly appreciated.

Thanks,
MJBrune

fallahn

  • Hero Member
  • *****
  • Posts: 507
  • Buns.
    • View Profile
    • Trederia
Re: 'Tiled' Tile-map Loader
« Reply #168 on: June 05, 2014, 10:42:54 am »
You're right. I've had a look and the object visibility flag has no effect. This is because originally objects were drawn with sprites, but have since been updated so that all objects are now part of a vertex array - making it much harder to change the visibility of individual objects (if not impossible). An oversight on my part. I can only suggest that to attach your own sprites to objects if you want an immediate fix, until I decide how to proceed on this.

MJBrune

  • Newbie
  • *
  • Posts: 13
    • View Profile
    • Email
Re: 'Tiled' Tile-map Loader
« Reply #169 on: June 09, 2014, 11:28:27 pm »
Just a shot in the dark but couldn't you store all the vertices in an object and when the visibility flag is set you can then calculate to draw only the visible objects? Somehow taking advantage of https://www.opengl.org/sdk/docs/man/docbook4/xhtml/glDrawRangeElements.xml this function?

fallahn

  • Hero Member
  • *****
  • Posts: 507
  • Buns.
    • View Profile
    • Trederia
Re: 'Tiled' Tile-map Loader
« Reply #170 on: June 10, 2014, 10:39:17 am »
That looks like a reasonable tactic. I had considered the possibility of rewriting much of the drawing code using OpenGL, although I have very little time to work on this right now (beyond opening a new issue). Pull requests are always welcome ;)

0dayv

  • Newbie
  • *
  • Posts: 1
    • View Profile
Re: 'Tiled' Tile-map Loader
« Reply #171 on: July 11, 2014, 05:40:20 pm »
Hello !

I'm new in SFML programming, but thank you very much for your tmxloader, it's very useful !
I'm trying to add an object in the map, it's quite easy (I used your example AddRemoveObjects.cpp) but I can't figure out how to give the object a texture.
The object is well created and drawn, I can see it with DrawDebugShape() but it remains an empty box with no texture.

I tried to create a LayerSet with the good texture, AddTile and then use SedQuad on my object, but this has no effect.

Can you help me ?

Thank you !

fallahn

  • Hero Member
  • *****
  • Posts: 507
  • Buns.
    • View Profile
    • Trederia
Re: 'Tiled' Tile-map Loader
« Reply #172 on: July 11, 2014, 06:43:36 pm »
I've not actually tried this (it's been a while since I looked at the map loader) but I think you're on the right track. The layerset you create has to be attached to a layer to be drawn iirc, and the object needs its type set to 'tile'.

Bombseb

  • Newbie
  • *
  • Posts: 19
    • View Profile
Re: 'Tiled' Tile-map Loader
« Reply #173 on: July 14, 2014, 04:02:46 pm »
Hi there !

I try to use the TMX map loader with QTCreator (under Ubuntu)

When I compile I get those errors :

Quote
15:57:23: Running steps for project TestTML...
15:57:23: Configuration unchanged, skipping qmake step.
15:57:23: Starting: "/usr/bin/make"
g++ -m64 -o TestTML main.o MapLoaderPrivate.o MapLoaderPublic.o QuadTreeNode.o pugixml.o   -L/home/seb/Progs/libs/SFML-2.1/lib -lsfml-graphics -lsfml-window -lsfml-system
/usr/bin/ld: MapLoaderPrivate.o: undefined reference to symbol 'inflateInit2_'
//lib/x86_64-linux-gnu/libz.so.1: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
make: *** [TestTML] Error 1
15:57:23: The process "/usr/bin/make" exited with code 2.
Error while building/deploying project TestTML (kit: Desktop)
When executing step 'Make'
15:57:23: Elapsed time: 00:00.

I also get a lot of warnings, but it looks like the errors have something to do with the zlib ?

If I do a "locate libz.so" in a terminal, I get this :

Quote
/lib/i386-linux-gnu/libz.so.1
/lib/i386-linux-gnu/libz.so.1.2.8
/lib/x86_64-linux-gnu/libz.so.1
/lib/x86_64-linux-gnu/libz.so.1.2.8
/usr/lib/x86_64-linux-gnu/libz.so

Bombseb

  • Newbie
  • *
  • Posts: 19
    • View Profile
Re: 'Tiled' Tile-map Loader
« Reply #174 on: July 14, 2014, 08:57:45 pm »
Could you help me please ?  :'(

Strelok

  • Full Member
  • ***
  • Posts: 139
    • View Profile
    • GitHub
Re: 'Tiled' Tile-map Loader
« Reply #175 on: July 14, 2014, 09:01:42 pm »
-lzlib?

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: 'Tiled' Tile-map Loader
« Reply #176 on: July 14, 2014, 09:15:04 pm »
Could you help me please ?  :'(
It's not so friendly to push the thread only after 5 hours, especially considering that this is not a general SFML topic that the whole community can answer, but a user's project. The developer most probably has a life apart from this project, so have some patience and research on your own while you're waiting...
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Bombseb

  • Newbie
  • *
  • Posts: 19
    • View Profile
Re: 'Tiled' Tile-map Loader
« Reply #177 on: July 14, 2014, 10:36:50 pm »
Hello,

It's ok, I found where was the problem, I added "-lz" to my .pro file...

Quote
-lzlib

Thank you, it's not -lzlib but you put me on the track.

@Nexus : Sorry

fallahn

  • Hero Member
  • *****
  • Posts: 507
  • Buns.
    • View Profile
    • Trederia
Re: 'Tiled' Tile-map Loader
« Reply #178 on: July 31, 2014, 10:35:03 am »
Well from the looks of it you're checking to see if the player has fallen into the object, and stop the falling when it has, but you never move the player back out again. Presumably it'll never move, because left/right are always false while the object contains the player. At a most basic level I use the MapObject function GetCollisionNormal() (I think it's called) and use it to reflect the player's current velocity which will move it back out of the object again. For a much better article on 2D platformers, I like this article, however.

eyeliner

  • Newbie
  • *
  • Posts: 19
    • View Profile
Re: 'Tiled' Tile-map Loader
« Reply #179 on: September 11, 2014, 11:58:20 am »
I feel dumb stupid, but could you explain how to build your TMXLoader? On windows. With VS2013 Express.

I don't work with C++ and I have absolutely no idea about what to do to build it. Or is there a binary somewhere that I can't see?

Thanks.
« Last Edit: September 11, 2014, 12:02:14 pm by eyeliner »

 

anything