Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Issue?] Two tilesets, one palette?
#11
Strange... can you do git pull and rebuild the engine again? Your output corresponds to when multi palette issue was still not fixed. Output should be like in my post Undecided I'm on Windows too
Reply
#12
(10-30-2022, 09:34 PM)megamarc Wrote: Strange... can you do git pull and rebuild the engine again? Your output corresponds to when multi palette issue was still not fixed. Output should be like in my post Undecided I'm on Windows too

Oh that works now! Thanks a lot! Sorry if I annoyed you with that.
What happened is I saw the version number wasn't bumped, and I still saw Tilengine 2.11.3, and then I thought I was on the latest version.
Thanks a lot for your help!
Reply
#13
Don't worry!
Thanks for your interest in this project and for providing useful tests cases that help finding bugs.
Hope you continue enjoying it and discovering new features
Reply
#14
(10-31-2022, 03:16 AM)megamarc Wrote: Don't worry!
Thanks for your interest in this project and for providing useful tests cases that help finding bugs.
Hope you continue enjoying it and discovering new features

You're welcome! But now I have another problem : How can I put a tile that is in another tileset on the tilemap please? The tilemap has 2 tilesets, and I want to put a tile somewhere in this tilemap, but this tile is in the second tileset.
Reply
#15
Hi!
You have to use the TLN_SetTilemapTile() function and set the corresponding tileset bits in Tile structure.
I assume that tilemap here has already been loaded and contains two tilesets, and that now you want to set tile at row 5, column 3 to index 100 of the second tileset. You'll do this:

Code:
Tile tile = {0};
tile.tileset = 1; /* use second tileset, first tileset has index 0 */
tile.index = 100; /* tile index 100 */
TLN_SetTilemapTile(tilemap, 5, 3, &tile);

Let me know!
Reply
#16
(10-31-2022, 04:35 AM)megamarc Wrote: Hi!
You have to use the TLN_SetTilemapTile() function and set the corresponding tileset bits in Tile structure.
I assume that tilemap here has already been loaded and contains two tilesets, and that now you want to set tile at row 5, column 3 to index 100 of the second tileset. You'll do this:

Code:
Tile tile = {0};
tile.tileset = 1; /* use second tileset, first tileset has index 0 */
tile.index = 100; /* tile index 100 */
TLN_SetTilemapTile(tilemap, 5, 3, &tile);

Let me know!

This is pretty straightforward!
Also, with the multiple tilesets per tilemap support, I can emulate a slotted palette behavior. What I did is I made multiple copies of the TSX file, all TSXes uses the same and unique picture.
Then, on the Tilemap, I put tiles from tilesets depending on the palette I want to use. Finally, on the Tilengine side, I can modify the colors of each tileset's palette to get some kind of slotted palettes! Here is a demonstration as an attachment. It uses the same tileset picture.


Attached Files Thumbnail(s)
   
Reply
#17
Good to know!
The screenshot looks cool :-)
Don't put much effort on simulating per-tile palette, now that release 2.12 with tile & sprite support is out, I'm working on release 2.13 that will add optional per-tile palette, using 8 global palettes and a specific property in Tiled edior. This feature will allow to emulate with more fidelity the inner workings of classic chipsets, but won't break compatibility with current one.
Stay tuned...
Reply
#18
Hi,

I've just pushed release 2.13 o GitHub that implements per-tile palette like in classic 2D chipsets. Up to 8 global palettes can be set with TLN_SetGlobalPalette(). Tile palette index is set in Tile.palette property.

By default global palettes are unset (NULL) and all tiles use palette 0. Having corresponding global palette set to NULL makes the renderer pick the tileset's own palette like before, so it doesn't break compatibility. Only when palette selector bits in Tile struct point to a not-NULL global palette, is picked over tileset's default palette.

https://github.com/megamarc/Tilengine/co...0cd570f381
Reply
#19
(11-03-2022, 03:35 AM)megamarc Wrote: Hi,

I've just pushed release 2.13 o GitHub that implements per-tile palette like in classic 2D chipsets. Up to 8 global palettes can be set with TLN_SetGlobalPalette(). Tile palette index is set in Tile.palette property.

By default global palettes are unset (NULL) and all tiles use palette 0. Having corresponding global palette set to NULL makes the renderer pick the tileset's own palette like before, so it doesn't break compatibility. Only when palette selector bits in Tile struct point to a not-NULL global palette, is picked over tileset's default palette.

https://github.com/megamarc/Tilengine/co...0cd570f381

Hi, thanks a lot for implementing this feature! It was one of the features that Tilengine missed, but now it's even closer to how consoles works!
But how can I define which palette is used by which tile on the TMX Tilemap please? Thanks a lot for your answer!
Reply
#20
Hi!

Glad you like this new feature :-)

Unfortunately Tiled editor doesn't allow setting custom properties on individual tilemap cells, only on tileset tiles. The only way to set palette bits on a tilemap cell at runtime is using combination of TLN_GetTilemapTile() / TLN_SetTilemapTile(), or the new TLN_GetTilemapTiles() that is more efficient but more dangerous too.
Only specific tilemap editors for consoles allow setting attribute flags directly on tilemap cells, but they're tightly tied to the features and limitations of each console. Tiled is more versatile and open-ended, but lacks this feature.

There is a workaround in Tilengine that is already implemented for "priority" attribute, and could be done for palette index too. The idea is to set the property to specific tiles in the .tsx (tileset) editor. When you set up a tilemap layer with TLN_SetLayerTilemap(), the engine "transfers" priority attribute of tiles on the tileset to tilemap cells. Same could be done with a "palette" attribute. However, this is a hack: priority and palette flags should be applied individually to selected tilemap cells, but with this method they're mass-applied to all tilemap cells with the same graphic (tile id). So you can't have the same graphic used on different parts of the map with different priority or palette on each place.

What do you think about implementing a "palette"property in tileset?

Just for curiosity I'll research a bit about file formats of specific console editors, peraphs I may write loaders for Tilengine in the future
Reply


Forum Jump:


Users browsing this thread: 9 Guest(s)