deepnight / ldtk-haxe-api

LDtk level editor Haxe API (available on HaxeLib)
MIT License
93 stars 32 forks source link

Support for procedural generation of a layer #30

Open mufty opened 1 year ago

mufty commented 1 year ago

Would like the option to be able to generate an intGrid layer while still using auto tiles and the setup from LDtk.

The way it works currently (at least from what I can see) is that the render function ignores whatever is currently stored in intGrid at the time of rendering and only renders the auto tiles.

It's missing a way to go through intGrid and create new auto tiles based on the rules set (kinda like it does when drawing by hand in LDtk). This doesn't have to happen on each render call but whenever intGrid changes if there would be an option to generate auto tiles out of it that would solve it. That way render function itself can still just render auto tiles like it is. And the user is able to create and remove tiles at runtime just by modifying the intGrid.

mufty commented 1 year ago

Got a very hacked up working version of this in my fork https://github.com/deepnight/ldtk-haxe-api/compare/master...mufty:ldtk-haxe-api:master

I just copied stuff from LDtk sources into the API. Everything is in Layer which isn't good but It's cuz stuff like rules is just plain types as parsed from JSON so in order to clean it up I'd have to do instances for more objects than just Layer. I just wanted to see if it would work.

mufty commented 1 year ago

image

just for illustration I generated a new intgrid on runtime and then just call layer.applyAllAutoLayerRules() to get this sort of thing

deepnight commented 1 year ago

Related: https://github.com/deepnight/ldtk/issues/970