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

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

0 Members and 1 Guest are viewing this topic.

fallahn

  • Sr. Member
  • ****
  • Posts: 492
  • Buns.
    • View Profile
    • Trederia
Re: 'Tiled' Tile-map Loader
« Reply #135 on: April 09, 2014, 09:31:06 pm »
Have you added the CPP files (except tmx2box2d.CPP) in the tmx source folder to your project?

Conor

  • Newbie
  • *
  • Posts: 4
    • View Profile
    • Email
Re: 'Tiled' Tile-map Loader
« Reply #136 on: April 09, 2014, 09:57:57 pm »
OMG thank you so much. You've seriously made my day. A quick reply, exactly what I needed, I just didn't realize things were done that way I thought it was all about like, including .h or .hpp files and then they find the .cpp files for me or something.

Thanks very much!

Conor

Noob

  • Newbie
  • *
  • Posts: 15
    • View Profile
Re: 'Tiled' Tile-map Loader
« Reply #137 on: April 10, 2014, 01:03:22 pm »
Can the order in which the layers are drawn be changed?

I want to have my player sprite be able to appear to be fully/partially behind objects if an object is in front of them, i.e. further down on the screen than the player.

Like this:


I was thinking something along the lines of using the quad-tree system used for collision to find anything that is close enough to be considered for reordering, then draw anything that is further up on the Y than where the player's sprite is first, then draw anything below the player on top.

Is this feasible?
Killing goblins at Lumbridge. Windows 7 - 64 bit. AMD Radeon HD 6700. Using VS2012 Express, SFML 2.1 - Static.

Grimshaw

  • Hero Member
  • *****
  • Posts: 631
  • Nephilim SDK
    • View Profile
Re: 'Tiled' Tile-map Loader
« Reply #138 on: April 10, 2014, 01:09:06 pm »
Or you can render tiles top to bottom, so when the tree is rendering, it will already occlude the player behind it. When the player is below the tree, it would appear on top of the tree, because the tree would be drawn before.. I think this _might_ be a solution to that problem :p

Noob

  • Newbie
  • *
  • Posts: 15
    • View Profile
Re: 'Tiled' Tile-map Loader
« Reply #139 on: April 10, 2014, 01:15:03 pm »
Uhhh... That is pretty much what I am proposing.

The thing is that the whole map gets drawn, then the player.
I need to be able to slot my player in between the different layers to achieve the effect of the bottom being in front of the player.
Killing goblins at Lumbridge. Windows 7 - 64 bit. AMD Radeon HD 6700. Using VS2012 Express, SFML 2.1 - Static.

fallahn

  • Sr. Member
  • ****
  • Posts: 492
  • Buns.
    • View Profile
    • Trederia
Re: 'Tiled' Tile-map Loader
« Reply #140 on: April 10, 2014, 01:55:32 pm »
There's no specific z-ordering as such (although there was a partial implementation of being able to insert sprites onto specific layers - I don't remember where I got to with that) but you can draw a specific layer with

MapLoader::Draw(sf::RenderTarget& rt, sf::Uint16 index, bool debug = false)

so with a bit of finagling you could come up with some logic which decides which layer should be drawn and when

Noob

  • Newbie
  • *
  • Posts: 15
    • View Profile
Re: 'Tiled' Tile-map Loader
« Reply #141 on: April 10, 2014, 08:59:07 pm »
...

actually when I wrote that it wasn't true that the map loader performed culling of vertex arrays which weren't in view. I've updated the source on github so now it does.

Does it do it automatically?

I decided to test it out on a 512 x 512 tile map @ 64 x 64px tile size, where the map is just 4 layers, each one representing each quarter of the map.



I load the map and run the program in release, and get around 10-12 FPS no matter where the view currently is. It is the same if the view is right in a corner of the map, or on top of where all the layers meet.

Am I doing something very wrong?

(Yes I've updated to the most recent github version of the maploader.)
Killing goblins at Lumbridge. Windows 7 - 64 bit. AMD Radeon HD 6700. Using VS2012 Express, SFML 2.1 - Static.

fallahn

  • Sr. Member
  • ****
  • Posts: 492
  • Buns.
    • View Profile
    • Trederia
Re: 'Tiled' Tile-map Loader
« Reply #142 on: April 10, 2014, 10:38:59 pm »
It *should* do it automatically...

but to be perfectly honest I've not thoroughly tested it (thanks to our good friend Real Life)

The idea is this: when the map loader parses layers of tiles it creates a vertex array for every tileset per layer. Each tile is made up of 4 vertices which are appended to the vertex array. Every time a tile quad is appended to the vertex array (which belongs to the LayerSet class) the vertex array updates its AABB (again, belonging to the LayerSet class). When each layerset is drawn its AABB is tested against the view port to test if it is visible, and cull it if it is not.

If you want to test this (I'm sorry but I really don't have the time myself) then the lines to note are:
here, here and here.

zmertens

  • Jr. Member
  • **
  • Posts: 80
    • View Profile
Re: 'Tiled' Tile-map Loader
« Reply #143 on: April 13, 2014, 03:53:54 am »
This project looks really cool, but I'm having some difficulties building the example programs (in this case, Benchmark.cpp). I've looked at all the posts in this thread and I think I'm having an issue with the zlib library and Visual Studio 2012 ( I'm a VS newbie ). I have a feeling I'm making a common mistake and hopefully somebody might be able to catch it  8).

So, I have a VS project set up for TMX and SFML, it looks like the screenshot in my attachments. I think I have the TMX files linked correctly with Visual Studio. I know how to get SFML working, so I can check that off. I downloaded the zlib library from zlib.net ( the one with the DLL ) because I saw somebody post that earlier in the thread. It's called " zlib128-dll " and has a .dll file within called " zlib1.dll ". I put the zlib1.dll file in the debug folder in my project like I do with SFML .dll's for dynamic linking.

In Project Properties->Configuration->C/C++->General I have this:
Code: [Select]
C:\Program Files (x86)\SFML-2.1\include;C:\sfml-tmxloader-master\sfml-tmxloader-master\include;C:\zlib128-dll\include;
Then in Project Properties->Configuration->Linker->General
Code: [Select]
C:\Program Files (x86)\SFML-2.1\lib;C:\zlib128-dll\lib;
Lastly, in Project Properties->Configuration->Linked->Input->Additional Dependencies
Code: [Select]
sfml-system-d.lib;sfml-graphics-d.lib;sfml-main-d.lib;sfml-window-d.lib;
I trimmed the last line a bit because the rest of the  library files are probably irrelevant for this ( like kernel32.lib ). Any suggestions?
The truth will set you free but first it will piss you off.

fallahn

  • Sr. Member
  • ****
  • Posts: 492
  • Buns.
    • View Profile
    • Trederia
Re: 'Tiled' Tile-map Loader
« Reply #144 on: April 13, 2014, 08:21:09 am »
I don't see a reference to the zlib .lib on the last line? Also you need to add the pugixml CPP file to your project.

zmertens

  • Jr. Member
  • **
  • Posts: 80
    • View Profile
Re: 'Tiled' Tile-map Loader
« Reply #145 on: April 13, 2014, 08:21:32 pm »
Oh, I knew it was something small. Thanks. This looks really neat.

Is there a preferred way to make the Tiled images? Do you just make them with a paint program like GIMP or MS Paint?
« Last Edit: April 13, 2014, 08:24:03 pm by ZM »
The truth will set you free but first it will piss you off.

Loopback

  • Newbie
  • *
  • Posts: 10
    • View Profile
    • Email
Re: 'Tiled' Tile-map Loader
« Reply #146 on: April 15, 2014, 05:58:59 pm »
Hi Everyone! I'm new here and I'm trying to code a mini game. I'm having a bit of a problem I haven't been able to resolve. Could anyone help me please?

My main problem is that I can not acces (Get information about) my tiles. I can have everything about my objects but not about my tiles. How is that? How can I fix it? What am I doing wrong? Could you guys help me please?

P.S: Attach image with code and prints.


fallahn

  • Sr. Member
  • ****
  • Posts: 492
  • Buns.
    • View Profile
    • Trederia
Re: 'Tiled' Tile-map Loader
« Reply #147 on: April 16, 2014, 10:24:43 am »
Unfortunately the map loader doesn't store information about each individual tile, you'll have to add the functionality yourself

Conor

  • Newbie
  • *
  • Posts: 4
    • View Profile
    • Email
Re: 'Tiled' Tile-map Loader
« Reply #148 on: April 16, 2014, 11:04:29 pm »
Hello again. I've been working with your great Map Loader. I've drawn some collision boxes in TileD and I'm trying to get the rectangle or its x and y values. How do I achieve this? What is QuadTrees? Thanks in advance. :D

fallahn

  • Sr. Member
  • ****
  • Posts: 492
  • Buns.
    • View Profile
    • Trederia
Re: 'Tiled' Tile-map Loader
« Reply #149 on: April 16, 2014, 11:11:43 pm »

 

anything