Question

I am creating an ASCII based c++ game using Windows XP Console. I am working on coloring the text and background for the game using SetConsoleTextAttribute. I have bee able to get most of the colors I want, but one color I can't get quite right is brown. The only suggestions I have been able to find have listed using 6 as the value for foreground (SetConsoleTextAttribute(hConsole, (6))) Is what I have been using. This, however, comes out as a Tan Brown, more of a dirty yellow than anything. Is there any way to get true brown using this function? If not, what other options do I have to get brown in Console Ascii? Like I said, I have found many pages saying to use 6 or FOREGROUND_RED | FOREGROUDN_GREEN, but that's not really brown. Thanks in advance!

Was it helpful?

Solution

This is the fault of the terminal settings. It gets to decide what color each ANSI value means. There's not much you can do from inside a basic console program unless you have a 256-color terminal.

There's probably a way to change the terminal's settings using various windows APIs (registry settings? ui automation or something?) but that's a whole other can of fish which I'll defer to windows programmers.

For your own purposes, you can just go into the terminal settings and change the puke yellow color to the brown you want.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top