Raylib: [IDEA] Tiled tmx support

Created on 10 Jun 2017  路  15Comments  路  Source: raysan5/raylib

I think Tiled is a nice way to create levels for games.

There is a C librarythat is able to parse the tmx file format.
It has examples for its usage with allegro and sdl, maybe we should add an example with raylib?

This is their example folder.

I started doing this but I am not too much familiar with raylib yet, and thus its very hard for me. Maybe someone can help? :)

enhancement help wanted

Most helpful comment

Just linking to a TMX loading example.

All 15 comments

Or would including that lib with some nicer wrapper functions or writing own raylib tmx parser be more appropriate?
I think Tiled is quite popular, and is also heavily used from Love2d people. This could be a good step towards making raylib more popular again?

Hi @jubalh!

I love Tiled but I think tmx support is out of scope of raylib, it would be more proper for a raylib code example. I prefer to keep the library with basic generic functionality for any kind of game; tmx is very game-type centric.

Creating a raylib example for TMX library shouldn't be difficult but it requires some time...

Hi @raysan5 !

Creating a raylib example for TMX library shouldn't be difficult but it requires some time...

Do you think you can find some time for doing this? It would be awesome.

I also created an issue for it on the tmx c library.

Hey @jubalh!

It's on my list, really, but I'm a bit overloaded with several things in my daily work and I can't find the time to work in deep in most of the pending issues... just have some small time spots that don't give me enough concentration space to work on complex issues...

Could you setup a basic example with some .tmx map + required textures + expected result screenshot to start working with it? It would be easier for me to go straight to loading and drawing implementations.

I totally understand. And I definitely don't want to push :)

I think https://github.com/baylej/tmx/blob/master/examples/sdl/sdl.c is a very good thing to look it. Basically it shows how to use the tmx library to get the content out of the .tmx file. It then uses SDL to draw the content. https://github.com/baylej/tmx/blob/master/examples/allegro/allegro.c shows the same for allegro.
As I see it, you could just use one of those, and adapt the SDL calls to the raylib calls. allegro and sdl usage of tmx are very similar they just use their respective APIs to draw unto a canvas and get the canvas it seems.

In https://github.com/baylej/tmx/tree/master/examples/data he also has example .tmx files.

I just looked through my harddisk and realized that I still have my attempt of writing the raylib example. I committed it now and pushed it to: https://github.com/jubalh/tmx/tree/master/examples/raylib

raylib.c was about taking the sdl example and changing it to use raylib calls.
raylib2.c was starting with a base raylib project and adding the tmx calls.

I didn't get very far. Also for time reasons, but even more so because I don't know enough about raylib and drawing things on the screen in general.

Hi there,
I still think TMX support would be something worthwhile. Especially for people coming from love2d this would be a thing they would miss. It would attract more users of raylib I think. And one doesnt need to invent their own map format.

Maybe having this issue open would also encourage more that someone works on it than having it closed ;)

ok, let's give it another opportunity...

Just to clarify: how would support for Tiled's TMX format be implemented for raylib? As @raysan5 mentioned, it seems like a lot of game-specific behavior would be written if a LoadLevel-esque call were to be implemented, so it doesn't seem like it belongs in raylib itself. Given that, I'd imagine there would be two options:

  1. Implement a raylib example (as mentioned above) that can render a level created in Tiled
  2. Consider the issue out-of-scope for raylib and address this in the issue that @jubalh opened in https://github.com/baylej/tmx/issues/31

I'd imagine option 2 is the most viable considering that baylej/tmx already has examples for allegro and sdl. The examples appear to be abstracted in a manner where re-implementing the existing functions with raylib instead would be the most straightforward route.

Raylib plays oggs. For me this is not much different and plans to do networking. For me this is not more out of scope.
It has to parse xml files and create structs for this which then can be displayed.

Love2D and others do it too.

I agree that adding an example to the tmx library would be an alternative.

But since raylib adds networking and so many non core game related things it could as well add a tmx module of itself. So that the syntax, usage and naming is closer to raylib than an external library like tmx.

@jubalh networking is a feature that many games today could require, independently of the game style, same as ogg playing... but TMX map support is a very specific requirement for a specific kind of game and for maps created with a specific tool (Tiled).

Supporting that format on raylib is not that trivial, requires lot of work and despite being a possible addition, it's definetely very low priority for me. As always, I'm open to collaboration and accept PR requests.

Also consider that all external libraries included in raylib to support specific file-formats are single-file header-only.

@terrehbyte Creating a raylib example seems a good alternative.

Many games certainly require networking capabilities, as they do maps. I doubt that networking is more popular among indie game devs than 2D maps.

Also there are good networking libraries already.

I can not see how adding TMX support is harder than creating a whole networking library.

Also the point about creating an example for tmx library I mentioned over one year ago ;)

This is probably too high-level to belong in ralylib, but it would be nice to have an example or perhaps an auxiliary repository. I'll take a crack at this, since I'm planning to use raylib API with tiled for a game idea.

Just linking to a TMX loading example.

Wow, supercool! Thanks!

Above example shows a TMX implementation for raylib. No plans to add it to the library. Closing the issue.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

yashrk picture yashrk  路  5Comments

Triangle345 picture Triangle345  路  8Comments

raysan5 picture raysan5  路  10Comments

siavashserver picture siavashserver  路  5Comments

raysan5 picture raysan5  路  12Comments