Public Group

Changing Color in a text based RPG

This topic is 4973 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

Hello guys, I created a text based rpg and wanted to know if anyone can direct me on where to look on a preprocessor header that allows you to change the text color. I beleive it is conio.h in c++ but I am not sure. Trying to avoid windows.h if possible. Oh yeah I program in c++!!! =) -Thanks

Share on other sites
although I have never gone into conio I do believe it can do that.

Share on other sites
IIRC, text color is an OS specific thing. Unless you're doing mud programming, where a client can add colors, you'll have to dive into windows.h and SetConsoleTextAttribute().

Share on other sites
Dang I was afraid of that. Is that hard to learn and can I keep the windows.h to a minimum just for the purpose of using colored text?

Share on other sites
Oh I also forgot to ask if there is a tutorial somewhere that I can learn how to do the color effect?

Share on other sites
I assume you didn't want to use windows.h because you want the program portable but the fact is that conio.h is non standard. So gcc's version of conio.h is different to Borland's version and whatever other versions there are they are all quite different. So I suggest using windows.h

Share on other sites
I wouldnt waste time learning something like that, if you can make a text rpg you arent far from graphics. conio.h has nothing to do with graphics and windows.h is a bad idea if you want other OS's to be able to run your game.

Share on other sites
Unless you want to make a text-based RPG because they are fun and/or you want to make an RPG for the bragging rights :)

conio.h isn't supported by some IDEs/compilers, I believe. Use windows.h on Windows OS, and try ncurses.h on Linux. Check out my website, I have a simple class that you can include into your project (not too well done, but explained OK) that will do this for you on Windows. You could always just look at the source; I comment OK and indent! And use real, explanatory variable names. Good luck.

Share on other sites
What is your website by the way?

Oh and I used windows.h with conio.h to do what I wanted to do, but I will need to
get away form conio.h since it is not standard.

Share on other sites
Oh, and just FYI, last time I was playing around with the Windows XP console, it understood VT100 escape codes, letting me do color.

Can't get it to work again. Weird...

Set Display AttributesSet Attribute Mode	<ESC>[{attr1};...;{attrn}m    * Sets multiple display attribute settings. The following lists standard attributes:0	Reset all attributes1	Bright2	Dim4	Underscore	5	Blink7	Reverse8	Hidden	Foreground Colours30	Black31	Red32	Green33	Yellow34	Blue35	Magenta36	Cyan37	White	Background Colours40	Black41	Red42	Green43	Yellow44	Blue45	Magenta46	Cyan47	White

I thought it was nifty I wrote a function to parse my text from my custom color code to VT100. It was pretty sweet.

Don't know if any earlier windows have VT100 support, though.

***EDIT

[Edited by - wasted_druid on June 10, 2005 4:14:19 PM]

• What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 9
• 31
• 16
• 11
• 10
• Forum Statistics

• Total Topics
634118
• Total Posts
3015606
×