Set text palette

SGDK only sub forum

Moderator: Stef

Post Reply
orlanrod
Very interested
Posts: 99
Joined: Fri Sep 25, 2015 7:46 pm

Set text palette

Post by orlanrod » Sat Oct 03, 2015 2:59 am

How would i set an index of a player's palette, for the color of text?
The player's palette is stored in the palette[16] array.

Thanks.

Stef
Very interested
Posts: 3131
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Re: Set text palette

Post by Stef » Sat Oct 03, 2015 10:03 am

You define which palette to use for each sprite. By default it uses the first palette (on the four availables) but you can change attributes of a sprite by using :

Code: Select all

SPR_setAttribut(&sprites[1], TILE_ATTR(PAL1, FALSE, FALSE, FALSE))
where TILE_ATTR is defined as :

Code: Select all

/**
 *  \brief
 *      Encode tile attributes for tilemap data.
 *
 *  \param pal
 *      Palette index
 *  \param prio
 *      Tile priority
 *  \param flipV
 *      Vertical flip
 *  \param flipH
 *      Horizontal flip
 */
#define TILE_ATTR(pal, prio, flipV, flipH)
Edit:
I did not read correctly, do you mean you want different text color ? with one color per player ?
In this case you need to use different palettes, but text only use the last color (index 15) from the palette so you can build your different player palette so color 15 is the one to display text for this player.

orlanrod
Very interested
Posts: 99
Joined: Fri Sep 25, 2015 7:46 pm

Re: Set text palette

Post by orlanrod » Sat Oct 03, 2015 6:31 pm

Stef wrote:You define which palette to use for each sprite. By default it uses the first palette (on the four availables) but you can change attributes of a sprite by using :

Code: Select all

SPR_setAttribut(&sprites[1], TILE_ATTR(PAL1, FALSE, FALSE, FALSE))
where TILE_ATTR is defined as :

Code: Select all

/**
 *  \brief
 *      Encode tile attributes for tilemap data.
 *
 *  \param pal
 *      Palette index
 *  \param prio
 *      Tile priority
 *  \param flipV
 *      Vertical flip
 *  \param flipH
 *      Horizontal flip
 */
#define TILE_ATTR(pal, prio, flipV, flipH)
Edit:
I did not read correctly, do you mean you want different text color ? with one color per player ?
In this case you need to use different palettes, but text only use the last color (index 15) from the palette so you can build your different player palette so color 15 is the one to display text for this player.
Yeah, i meant that i want to choose the color index the text is using, from the palettes i placed into the palette array. Say the player's palette is set to PAL1, and i want to get the index where the bright peal color is, to set the text color (example)

Stef
Very interested
Posts: 3131
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Re: Set text palette

Post by Stef » Sat Oct 03, 2015 8:44 pm

You can't really do that. The default SGDK font use color index 15 and then you can select which palette to use (0, 1, 2 or 3). If you want to use another internal color index to display text you need another font. It's why i told you to always put your wanted text color in last index entry of the palette (15) but that mean you can have at max only 4 different text color at once (one per palette).

orlanrod
Very interested
Posts: 99
Joined: Fri Sep 25, 2015 7:46 pm

Re: Set text palette

Post by orlanrod » Sat Oct 03, 2015 9:18 pm

Stef wrote:You can't really do that. The default SGDK font use color index 15 and then you can select which palette to use (0, 1, 2 or 3). If you want to use another internal color index to display text you need another font. It's why i told you to always put your wanted text color in last index entry of the palette (15) but that mean you can have at max only 4 different text color at once (one per palette).
Oh okay, i understand now. Thanks.

Stef
Very interested
Posts: 3131
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Re: Set text palette

Post by Stef » Sun Oct 04, 2015 8:47 am

By the way you can have a look on this topic which is related to your question :
viewtopic.php?f=19&t=2134

Post Reply