bcvery1 / tilepix

Library for combining tiled maps with pixel
MIT License
46 stars 14 forks source link

Investigate multiple tilesets #54

Open bcvery1 opened 5 years ago

bcvery1 commented 5 years ago

TilePix has not been tested using multiple tilesets. This should be something which is tested (manually and with test assets!) to ensure at the very least a sensible error is returned, but ideally that it is handled correctly.

If any sort of code change is required, should be created in a separate issue first, this issue is for investigation only.

bcvery1 commented 5 years ago

Looks like this will be relatively easy. Each tileset has a firstgid attribute which indicates the first ID relating to this tileset. So the first tileset may start with 1, and the second with 216, for example.

Need to alter the sprite setting to use the other tilesets if the GID is high enough.

LordEidi commented 4 years ago

Have you worked on this yet? While debugging a division by zero exception in tilelayer.go > Draw() I stumbled over the underlying problem. That's at least what I think.

So I have that map containing a few Layers and some Layers contain sprites from different TileSets. When loading the map somewhen code runs through tileset.go > getTileset() where the function returns useMultipleTilesets = true. That results in tilepix.go > Read() to not set the TileLayer's Tileset on line 132 because execution jumps out of the for loop before doing so.

I have to admit, I only played around with tilepix for a few hours and am a bit lost how to solve this.

From what I understand, we would have to have links to multiple TileSets on every TileLayer. But there is a link between TileSets and Batches. Which means that we also would need to have multiple Batches per TileLayer.

I get the impression that TileSets and Batches should be stored globally and only be referenced in TileLayers to not have the same sprites in memory multiple times. This would also make two things simpler: Using sprites "outside" of tilepix and managing animated sprites.

Looking forward to your comment.