Skip to content
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

Support of other level designers #273

Open
UnbrandedTech opened this issue Dec 7, 2021 · 7 comments
Open

Support of other level designers #273

UnbrandedTech opened this issue Dec 7, 2021 · 7 comments
Labels
feature New feature or enhancement

Comments

@UnbrandedTech
Copy link

I've been sporadically working on a game and trying to keep it as lightweight as possible so I can learn how game systems work under the hood.

Started to design some levels using LDTK and noticed that the only level designer integration KontaJS has is Tiled.

I've spent some time making an LDTK engine using Kontra core. Is there an appetite for an Engine abstraction that can be used for Tiled, LDTK, Ogmo, and anything under the sun?

@straker
Copy link
Owner

straker commented Dec 7, 2021

I'm unfamiliar with LDTK, but an abstraction to load different level editor JSON files seems interesting. The main issue is that the TileEngine was built around Tiled data structure. If supporting different level editors can be modular, that would probably be the best solution.

@straker straker added the feature New feature or enhancement label Dec 7, 2021
@UnbrandedTech
Copy link
Author

UnbrandedTech commented Dec 7, 2021

Here's the doc for the LDTK JSON schema if you are curious. I'll see what I can do and throw a PR up for an engine abstraction (class TiledEngine extends Engine, class LDTKEngine extends Engine, etc...) when I get some free time.

@ghost
Copy link

ghost commented Mar 2, 2022

Hi there,
any progress on this? Asking because i would like to contribute for the Ogmo part i'm currently trying to use for my maps.
Its pretty easy for really simple maps, but it has some downsides to be used properly.

As i figured out, to get started you just need some hints/tips to get the TileEngine rendering your map. However, to get more out of it (using objects and the entities defined in the map), you have to extend the TileEngine, though.

Is there anything i can contribute to get this issue going?

Greetings

@straker
Copy link
Owner

straker commented Mar 2, 2022

I haven't work on this yet. If you'd like to help I think what we need is an abstract TileEngine class that can bridge the different level editor data, then individual TileEngines for each editor that extends the abstract class and fills in support the editor.

@ghost
Copy link

ghost commented Mar 4, 2022

OK, i had some time to look at the TileEngine.
I think it's simple enough and should stay with the functionality. I would only move some parts of the code into functions (dirty check, visible, opacity, tileset selection while _r()).

The only thing a have struggle with is the assets loading. With any used TilemapEditor you have different formats and maybe want to load the assets differently. I would use a TileEngine.TilesetLoader() or TileEngine.DataLoader() rather then secretly us a global from window. Maybe someone is using a custom assetsLoader, or they should explicitly use load, loadData, etc.

That is based only on what i could check with the Tiled, Ogmo and LDtk Editors.

Each of them has unique ways to do stuff, but all are needing the values you have defined in the TileEngine (sometimes named differently).
With just moving some of the parts in functions we can have a simple tilemap based rendering without the more complex stuff, but also be able to extends the class TileEngine for the heavy features of the named Editors and many other tools in the wild.

The 2 parts i've to think about:

  • initial loading of the tilesets
  • tileset selection in the _r() function (only needed for Tiled maps)

@straker
Copy link
Owner

straker commented Mar 4, 2022

Thanks for looking into it. Asset loading is tricky since I didn't want to create a dependency from TileEngine to the asset loader (no way to tree-shake that out). So I used the secret window object to avoid that problem. I think having a function load them directly would create a direct dependency even if you didn't need to load that stuff.

Other than that I think what you said sounds good.

@straker
Copy link
Owner

straker commented Jun 28, 2023

So I'm taking a look at this and there's some major differences between Tiled and LDtk formats / capabilities that I'm not sure if I could make the two work the exact same. Here's the list of differences that I noticed:

  • LDtk defines multiple maps (levels) per file while Tiled defines a single map
  • LDtk has the layer define the grid size while Tiled uses the map. This means a layer could change the grid size from the rest of the layers
  • LDtk allows multiple tiles to stack to a single grid location while Tiled only allows one tile per location

The multiple maps per file and layers defining grid size are both significant differences that I'm not sure how best to handle them. It'll probably mean that the LDtk Engine has more functionality than the Tiled Engine? But I'm not sure yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or enhancement
Projects
None yet
Development

No branches or pull requests

2 participants