-
Notifications
You must be signed in to change notification settings - Fork 886
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[$525 Bounty] Add support for tilemaps made in LDtk (build a parser for .ldtk files) #2434
Comments
This is indeed the proper solution that should be implemented. I would add:
|
Thank you for opening a separate issue. I can pick it up if nobody else
wants to give it a try. :)
This time we have a good starting point with the helper class. As Florian
says it would be a good opportunity to update pixi tilemap
…On Mon, 15 Mar 2021, 09:19 Florian Rival, ***@***.***> wrote:
Solution suggested
This is indeed the proper solution that should be implemented. I would add:
- Optionally might be a good idea to upgrade to latest version of
pixi-tilemap first (verify it works with the tilemap examples).
- Then implement support for parsing .LDtk (json) files in the Tilemap
object (pixi-tilemap-helper.js, so that it works both in the IDE and at
runtime). This is the important part where good quality code is required to
parse both Tiled and LDtk without dirty hacks.
- Finally add a new ".ldtk" resource to the IDE (I can help if needed).
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#2434 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABRRWVM7XSGYRENWOYGQUU3TDXGLBANCNFSM4ZF7OIMA>
.
|
No concerns from me, although I'm not an approver for work on this, so we'll wait on @4ian to chime in. |
Feel free to go ahead! |
Note though as this will create more maintenance in the future, I expect properly organized and clear code so that it's easy to update in the future. We could also integrate unit test (with .spec.js files) |
So on the topic of file types, I want my extension to take in both a json and an ldtk file as tilemap resource. Option 1 Option 2: So for option 2 - do I need to recompile the c++ GD to work? I notice that the 'json' kind is in the source code. I can go with Option 1 for now and we can sort it out later if its more complicated than it seems - since it seems like a polish thing to do anyways. If I can at least get to properly open ldtk and json files from one field in my extension, I can then focus on the actual parsing. |
@Bouh added a "bitmapFont" in the upcoming BitmapText PR so yeah that's the way to go here too: create a "tilemap" resource (that can be a .json or .ldtk). But you can go for option 1 and I can rework the core to have a "tilemap" resource. Then we'll update the extension to have a "tilemap" resource property instead of a resource of type "json". We should do this btw for yarn json files too. We should rework the actions so that they don't use a "jsonResource" but a "yarnResource" :) |
I really want to go with option 2, but have no idea how to recompile and use the c++part of GD. The bitmapFont commit could inform me how to do the code part, but not the update gd.js part. I am now developing it on linux, so in theory at least compiling c++ should be easier, right? is that the pr? in my case it should be easier since they are all technically a jsonResource |
Yes. It's a massive one but you can search for "bitmapFont" everywhere to see. Anyway, maybe you can concentrate on coming up with a clean and nice parser that adapts well in what we have now, and we can solve this "json" => "tilemap" resource latter :)
Yes, follow the README in the GDevelop.js folder and let me know :) |
Yes. |
no worries, I got it to compile now :) I copy and pasted some boilerplate c++ code to create a TilemapResource, but am yet to see if that did the trick |
Some progress report today:
|
Nice! :) |
Some progress today - I got the conditional splitting to two different methods to create the generic tilemapData- based on the file header's key telling GD what application was used to create it. There is still a lot to do before it can get a basic render, but its interesting how the automatically generated tiles are just generated in each tilemap level's layer. A tilemap layer in it can have a different atlas from the other layers and stores a relative path to that atlas - so I will for sure need to get it to automatically add these image resources in the extension's helper module somehow and not the IDE - that is if we want to be able to render all layers of a tilemap at once- which we most definitely do. For now I am just trying to get it to work with a single one, but will try to tackle that later on. |
Some progress today: I came up with a way to automatically load atlas image resources on a per layer basis - if they are not identified by GD as an existing image resource - they will get added via the resource manager. Started figuring out how to slice up the tileset for ldtk's tilemap, managed to cache some tileset textures, but I am yet to find out if they are the right rects |
Some progress today, I got it to render LDTK layer! Yay :) Still lots to do before this can be a pr - there are different types, flipped tiles, etc etc. Thankfully the data structure is kind of nice when compared to tiled's.I had to jump through less hoops to identify the position of tiles because led spells out their position in px - unlike tiled which makes us manually do the math. Same for the slicing of the tileset. Why in the name of crazy bats doesn't tiled do that too? @bjorn ? |
Yes, looking at the LDtk json format made a ton of sense to me, and I haven't dealt with JSON/Javascript for work in like 4 years. Deepknight did really good work designing it. Excited to see the continued progress. |
I must say removing all this complexity also results in less fragile code - less things can break. Its just those two values that make a huge difference. If @bjorn adds them to the output of tiled data - I will be able to remove the nested for loops and all the math expressions to compute where the tile is on the atlas and on the tilemap. That stuff is what makes it fragile |
I think the clear redundancy of the information was the main reason not to include it, especially 17 years ago when the TMX format was introduced. I could certainly consider adding this information, and had actually opened issue mapeditor/tiled#2863 about this last year, which is about including the tile rectangle on the tileset image in the tileset definition. The same applies to the information storing the location of each tile on a tile layer, which can be almost trivially derived from its index and the grid size. It wasn't "crazy bats" to not include that information, it made perfect sense because including that would have made the files that much bigger and we could no longer just use an array of numbers to store a tile layer (nor compress it). Actually, when exported like this a tile layer would look exactly like an object layer, so maybe we could add an option to export tile layers as object layers? |
@bjorn please consider adding it even if optionally - I dont think it will make it that much bigger. The tiled parser on gdevelop is more prone to break because of all these manual expressions just to evaluate the tile's x,y on the tilemap and on the tileset. Having it will allow me to remove these nested for loops and expressions - ultimately resulting in much cleaner code and less computation needed for gdevelop to do when parsing the data. I didn't realise what a huge difference this makes until writing a parser for ldtk. You are sort of adding tons of complexity to the engine's parser by omitting that data from the export just to save a few bites. |
@blurymind Please be careful about your wording and the way you address people on what is technical considerations. It is poor form to tag multiple times someone that has been making what is a great product for years just to hit on a way some data is formatted. As with every product, technical decisions and choices, there are advantages and disadvantages. Not only 17 years ago it was a right decision, it was also a very clever one and probably helped a lot of games perform correctly and save memory. But it's our decision and responsibility to own this parsing in GDevelop:
But remember that you may not have the full picture behind a choice, the legacy/technical considerations at the time or now, or missed an actual advantage of a specific format. So let's refrain from tagging and being too harsh at people especially at contributors from other projects :) Again I know the intent was not bad, but still, these things are important :) We're the one choosing to support Tiled format, so we must own it. |
ah sorry, there was no bad feelings,I was trying to say it jokingly but it came out bad. I shouldn't have tagged Bjorn here, just wanted to bring it up because some bugs cropping out can be fixed in theory in a better way if we can get the coordinates directly. Yes indeed tiled is a fantastic editor and it is still the most popular out there, just bringing this up with hope to put some light into how this data can improve its adoption even more. I love the both tiled and ldtk and supporting both is important to me |
Just to be more specific,this PR here Its not fixing the problem completely and the tilemap still has corner cases where rendering has issues. If we can get the x,y values - this will let me fix it in a much better way with no corner case issues. Just out of the box Ldtk will not have these problems with pixi-tilemap because of that. Complicated code leads to higher chance of corner case bugs and having these x,y values will lead to much cleaner and bug free parsing for pixi-tilemap. Tiled parsing can also benefit from this when x,y values are included in the json file |
If LDtk doesn't have the issue OOTB, and your PR fixes most use cases, along with the eventual goal of integrating LDtk as a native editor, I think the edge cases could be reasonable, to the point where we can just document it and treat it as a minor compatibility issue rather than having it continue to take more and more of your available hours trying to fix. Obviously, I have no say in any of the above, it just seems like the best path forward as an outside observer. |
Some progress today - I got it to render all ldtk layers,apart of entities, which I am not sure if we will support. One limitation of pixi-tilemap atm is the inability to render semi-transparent tiles. I might do a PR to pixi-tilemap to add that some time in the week, as the shadow layer of the ldtk example project looks really ugly without it. There was a pr before, but it was abandoned before it could be merged I will try to redo it and get it in before we upgrade pixi tilemap.Might as well address more of its limitations while at it. I believe tiled also has opacity on layers, so we do need it for both formats |
Ok so there is a huge refactor between pixi-tilemap for pixi v5 and v6 and in order to add opacity to tiles, gdevelop will need to be on pixi v6. In essence, I cannot upgrade pixi-tilemap in gdevelop until gdevelop is not upgraded to pixi v6. The commits to pixi-tilemap-v5 seem to have stopped for since almost half a year ago. I need this to get in before I can work on improving pixi-tilemap to support opacity for opacity on layers in gdevelop I guess I can still work on it for v6,it just wont be in GD until we are on v6 |
Ah nice, is the rotate something built recently in pixi tilemap?
Yes, entities should be indeed a separate concern. An action to get entities variables translated into an object is probably a good idea though, but that's for another day. |
Discussion on handling entities created: #2836 |
I believe @ivanpopelyshev added it in the end of 2019 Will it be ok if I also add support for varied animation speed in tiles for tiled format in the same pr? I recently added it to pixi-tilemap, so I am a bit eager to get that in the extension. When ldtk gets that at some point, it will also be easy to add. I want to take advantage of all of pixi-tilemap's options
Yes absolutely. Its a design task that has lots of caveats which need to be discussed in advance. I see some overlap of dealing with entities and collisions from both apps, but they are very different in my head |
Some progress today, added ability to render tilemap backgrounds with that all rendering features from Test_File_For_Api_showing_all_features.ldtk from ldtk's samples now work in the runtime and the IDE. The ide still doesnt render entities - but I think that should be done in the entities task. The example file has these bits that dont contain any actual textures: Btw this is how easy it is to set up switching between levels contained in a single ldtk file |
still open? |
Yep! #2828 You can see active/linked pull requests at the bottom of any open issue. |
Upon looking I noticed that another dev is currently writing a fix. |
This has neared another birthday, and people are asking about this again on discord and the forums. I've bumped up the bounty on this and the ldtk integration/bundling to hopefully renew drive/interest. |
Hello, is the bounty still active? |
It is. The original person working on it has unfortunately gone silent. You can review their incomplete PR here, but you'd likely want to start from scratch as they were running into rodeblocks with the method they were working on. I'd recommend reviewing and writing up a proposal on how you'd want to proceed, and one of the mainline devs can review and give you a green light. That way you don't waste to much time building something out if it'll just run into the same roadblocks. |
I've made some progress. Here are my 3 main issues:
|
I'd wait for one of the main contributors/devs to chime in, but I don't think Tiled supports floating positions either, so I don't know that there's a hard requirement to have the ldtk file support non-integers even if the base app does. This is just my opinion on it, though. |
@Silver-Streak I've just tested. When exported from LDtk to Tiled, the shelves are shifted. I can do that. |
@daiyam That looks like great progress :)
That's the hard bit. The current resource system is basically one file = one resource (there are no "meta resources" linking to more than one file). How do you work currently? Do you ask for all resources manually by the user? Did you hardcode their loading? Depending on what it looks like currently (or if we can look at the code directly), we can think of how to make this user friendly.
I guess so, we can add support for this later?
@D8H created a "Tilemap collision mask" object - I think ideally we should use it: This is because this allows to have different objects, one for platforms, one for jump thrus, etc... |
For I've changed the
I will look into that LDtk has floating tiles. Now, they are rounded to the lower integer (like LDtk does when exporting for Tiled). |
Just to clarify, LDTK doesn't currently natively have a collision layer of any kind. I suppose you could have it pick up x/y point entities (or enums) named in a certain way to have them mapped to collision polygons? (Deepmind has collision and geometry handling on the roadmap, but I don't think there is any design around it done yet) |
@Silver-Streak true, I was misled by their example (a layer is called |
Yeah, with no current native collision support, I'd be interested in @D8H 's feelings on whether to map collisions to LDTK files at all before official support. Even with an x,y (point) entities layer, the layer would have to be a different grid size (likely 1x1) to be used for collisions accurately, which would require supporting different grid sizes. |
LDtk does support that. That was one of my question. I will wait for @D8H's inputs. I was finally able to compile |
If you mean layer grid offsets, the extension doesn't handle it for Tiled. I don't think it's mandatory. It can be done in another PR. |
To be clear, layer grid offsets and collisions both could be handled in another PR, correct? |
Correct |
I'm having an issue with adding a new What to do? New object type? |
I've pushed my PR. I made some substantial changes so you might have some concerns... |
Description
Currently the Tilemap object in GD5 only supports Tilemap/Tileset JSON files made by Tiled Map Editor.
As discussed elsewhere, The Level Designer's Toolkit (LDtk) is a newer tilemap editor that has a much more user friendly interface, and allows for much faster iteration than what is available in Tiled Map Editor. LDtk is completely free and available at https://ldtk.io. It is developed by deepnight who is a dev at the studio Motion Twin, who have made a ton of retail games. (Dead Cells being a personal favorite of mine)
While LDtk does support exporting to Tiled TMX, this file cannot be consumed by GDevelop's tilemap objects, so it requires opening it in Tiled then exporting it as a JSON. This also strips some of the more advanced features in LDtk that are greatly beneficial for game development.
Solution suggested
Short-term solution :
Long-term solution (outside of the scope of this feature request):
Alternatives considered
I thought about asking to support TMX Format files since LDtk can export to that format, but those are in XML and would require a completely different interpreter. It also wipes out a lot of the more advanced features LDtk provides.
Bounty
Learn more about the bounty here: https://www.bountysource.com/issues/97132654-feature-request-add-support-for-tilemaps-made-in-ldtk-build-a-parser-for-ldtk-files
The text was updated successfully, but these errors were encountered: