gurkenlabs / litiengine

LITIENGINE 🕹 The pure 2D java game engine.
https://litiengine.com/
MIT License
733 stars 93 forks source link

Support Tilesets Type: Collection of Images #269

Open TheRamenChef opened 5 years ago

TheRamenChef commented 5 years ago

Now that tilesets can have a null image (such as if the tileset is sourced via a collection of images rather than one image), code should be prepared to handle it. This means that the spritesheet returned by getSpritesheet could potentially be null. I've (hopefully) fixed this in the main engine, but I think it will still happen in UtiLITI. Can a collaborator more versed with the tool fix it?

steffen-wilke commented 5 years ago

@TheRamenChef Could you please point me towards the commits that changed this or maybe provide sample data to test this? I'm not 100% sure what I should look for.

TheRamenChef commented 5 years ago

One of the changes in #243 (specifically, 0f5c09b) was adding support for tilesets with individual images for each tile. I recently found NullPointerExceptions it was causing, and fixed them, but they could still happen with UtiLITI, and I'm not very familiar with the tool.

I've attached some demo tilesets to this comment. Both Tiled and the rest of the engine can open it just fine, but if there's actually an issue here, UtiLITI will spit out errors.

demo.zip

steffen-wilke commented 5 years ago

Also reported in this forum discussion

per-tile-image-issue.zip

steffen-wilke commented 5 years ago

I think this requires some bigger changes in the engine and the editor. Tilesets with multiple images were not a thing for the engine before these changes. For now I would say: Tilests with Collection of Images are still not really supported by the engine. The engine's understanding of Spritesheets, Tilesets and Image resources doesn't really match the concept of tilesets that are "just a collection of images". In Tiled these images can vary both in size and dimension so these collections are not like the "normal" tilesets at all. They need to be treated differently and the resulting tiles are used differently as in: they just have a "starting-tile" and are rendered from that position instead of the map having the tile information on each actual tile on the grid.

Of course, there is the simple case where each individual image just matches the tile dimensions of the map and everything works like in a "normal" tileset.

I think we need to get back on the drawing board with this and think about a proper concept to support this functionality with each facade it brings. And of course, the editor and its resource management play a big role in this, too. I like the concepts of the engine to be consistent but right now the support for Tilesets based on a collection of images doesn't match other concepts of the engine, so we need to rethink stuff.

steffen-wilke commented 4 years ago

Also reported in this forum post