Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Issue?] Two tilesets, one palette?
#23
(11-03-2022, 10:22 PM)megamarc Wrote: Hi,

This kind of proposed functionality should be implemented in the application -game- domain, not inside the engine. It's not a bad idea, but it's kind of a "hack" too, to overcome a limitation of the editor.

However implementing this is easy, this function does the trick. It requires that both layers -the palette indexes and the target layer- have the same size:


Code:
void apply_palette(TLN_Tilemap palette_layer, TLN_Tilemap target_layer)
{
    const int numtiles = TLN_GetTilemapCols(palette_layer) * TLN_GetTilemapRows(palette_layer);
    TLN_Tile srctile = TLN_GetTilemapTiles(palette_layer, 0, 0);
    TLN_Tile dsttile = TLN_GetTilemapTiles(target_layer, 0, 0);
    int c;
    for (c = 0; c < numtiles; c += 1)
    {
        if (srctile->index != 0)
            dsttile->palette = srctile->index - 1;
        srctile += 1;
        dsttile += 1;
    }
}


Take a look at this Sega Megadrive/Genesis editor:

https://allone-works.itch.io/16tile

This one allows to easily set priority and palette to selected tilemap cells. This is what Tiled lacks. It may be cool to load its maps into Tilengine to take advantage of its "console features"

Oh, 16Tile is a pretty nice tool, I already gave it a try in the past! Sadly, it seems this tool isn't open source, but I have good news : the format used by this tool is plain text (it looks like JSON), so you can easily implement a loader into Tilengine since JSON is a standard format.
About your code, wouldn't it hurt the performances with big tilemaps? The loader already does a first loop to load tiles, and you are doing a second loop to set the palettes. But maybe I got something wrong. But in any case, you set up palette data during map loading.

Edit : You also should take a look to LDtk https://ldtk.io/
It is less easy to use than 16Tile, but it's open source, and is also free and also uses JSON. It is also very powerful.
Reply


Messages In This Thread
[Issue?] Two tilesets, one palette? - by System64 - 10-28-2022, 04:07 AM
RE: [Issue?] Two tilesets, one palette? - by System64 - 11-03-2022, 11:12 PM

Forum Jump:


Users browsing this thread: 8 Guest(s)