In the past few days, I've been working on a library to use levels made with the level editor LDtk
This is the level editor created by Sebastien Benard which was the main game designer behind Dead Cells. https://ldtk.io/
This is really a convenient Level editor that let you create interconnected levels, place entities, and build level really fast especially if you use auto tiling.
I tried to support as many feature as possible:
- create playdate tilemap
- get a list of entities in a level
- custom entities properties
- create collisions
- tile flipping
- levels saved in separate files
A small platform sample is also included in the project to see how it is used in practice.
The SDK doesn't support flipped tiles for tilemaps and it is a very convenient feature in LDtk so to emulate the feature I had to find an alternative.
If your tilemap uses flipped tiles, you need to create an additional tileset with flipped tiles. The original tileset will still be used by LDtk but at runtime if a tilemap use flipped tiles I will load the other one instead.
This is not ideal if you keep editing your tileset but I made it relatively easy to make the flipped version. This is just the whole tileset flipped vertically and horizontally.
One of the challenge was that parsing the file was relatively slow on the console so I implemented a solution where you can export the levels as lua files when you run the game.
So you can decide to enable fast loading, you will simply have to copy the lua files in you project folder. The level handling functions will stay the same.
In theory there is different ways to define collisions in LDtk, I support only a specific one. You have to flag the tiles in your tileset with an enum to give properties to the tiles. In the game you simply request the tileIDs for the level. Easy Peasy.
playdate.graphics.sprite.addWallSprites( game.tilemap, LDtk.get_empty_tileIDs( level_name, "Solid") )
I hope that would be useful!