|
Post by hyperfighting on Aug 15, 2022 16:56:47 GMT
Hi Guys,
I am trying to control the color of fonts at points in time. Hoping someone might be able to point me toward the correct method of doing this.
I'm working on a "How To Play" style screen where I want to light up the active text instructions then reset the text to the inactive color.
Say in this case inactive but displayed text is "BLUE" and active displayed text is "RED"
The only way I can figure is by constantly loading the default font to a unique locations in both cases and setting the palettes and color.
EX: In the example below I know I could Pair "Blue" with "Blue Again" and eliminate a step. Assuming "Blue Again" is not in the same function I need a way to set the appropriate palette again after loading the RED font data.
//DRAW "BLUE" FONT set_font_pal(2); set_font_color(1, 0); load_default_font( 0, 0x2B00);
put_string("BLUE", 29, 21);
//DRAW "RED" FONT set_font_pal(2); set_font_color(3, 0); load_default_font( 0, 0x3200);
put_string("2.RED", 29, 22);
//DRAW "BLUE AGAIN" assume this number updates on every frame "load_default_font (...) makes the program slow. set_font_pal(2); set_font_color(1, 0); load_default_font( 0, 0x2B00);
put_number(A_NUMBER_THAT_UPDATES, 5, 7, 5);
|
|
|
Post by audreyhepburn on Aug 16, 2022 12:36:28 GMT
I'm not entirely sure I understand what you're trying to do, so I may be off base here. In my game whenever I want to show that text is being "highlighted" or selected, I just use this.
set_font_pal(HIGHLIGHT_FONT); print_item_data(item_table[select_cursor_pos].....); //basically a wrapper around put_string(); set_font_pal(STANDARD_FONT);
Which requires 2 palettes being dedicated to font but I use a custom font so it makes sense for me. It maybe a little overkill for you since you just one one color changed but it would be a heck of a lot faster. You could just create a red font, and a blue font palette, clear you "old" active red text to blue and write your new active text int red.
load_palette(2, bluefont, 1); load_palette(3, redfont, 1); set_font_pal(2); ......
put_string("BLUE", 29, 21); set_font_pal(3); put_string("2.RED", 29, 22); set_font_pal(2); put_number......
That way your font pal stays blue for the next line of text your need to "deactivate". Let me know if that was helpful or I got your question wrong. I've spent a lot of time fiddling with background tiles in vram...
|
|
|
Post by hyperfighting on Aug 16, 2022 14:41:58 GMT
audreyhepburn - Thanks very much for responding to me! I like your style it seems you only load the font to vram once and change the palette as needed. In my case I am being a bit wasteful in that I am loading the font 3 times. It gets the job done. Big apologies to the rest of the community - sometimes I am exhausted and I think I have fully explored the documentation when in reality the solution is in plain sight! I usually post at a point of exhaustion and in my haste I made premature post. This is what I am using to get the job done. Seems to work and only requires the "LoadFonts()" to be initialized once. void LoadFonts() { //BLACK_WHITE_FONT set_font_pal(2); set_font_color(6, 13); load_default_font( 0, 0x2600); //BLUE FONT set_font_pal(2); set_font_color(1, 0); load_default_font( 1, 0x2B00); //RED FONT set_font_pal(2); set_font_color(3, 0); load_default_font( 2, 0x3000); }
void BLACK_WHITE_FONT() {
set_font_pal(2); set_font_color(6, 13); set_font_addr(0x2600);
}
void BLUE_FONT()
{ set_font_pal(2); set_font_color(1, 0); set_font_addr(0x2B00); }
void RED_FONT() { set_font_pal(2); set_font_color(3, 0); set_font_addr(0x3000); }
.... BLACK_WHITE_FONT(); put_string("BLACK WHITE:", 1, 5);
BLUE_FONT(); put_string("BLUE:", 1, 6);
RED_FONT() put_string("RED:", 1, 7);
|
|
|
Post by audreyhepburn on Aug 16, 2022 23:14:34 GMT
You're welcome, glad you figured it out!
|
|