11-03-2022, 10:22 PM
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:
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"
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"