Advertisement Jump to content
Sign in to follow this  

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.

If you intended to correct an error in the post then please contact us.

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 this post

Link to post
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 this post

Link to post
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 this post

Link to post
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 this post

Link to post
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 this post

Link to post
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 this post

Link to post
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 Attributes

Set Attribute Mode <ESC>[{attr1};...;{attrn}m

* Sets multiple display attribute settings. The following lists standard attributes:

0 Reset all attributes
1 Bright
2 Dim
4 Underscore
5 Blink
7 Reverse
8 Hidden

Foreground Colours
30 Black
31 Red
32 Green
33 Yellow
34 Blue
35 Magenta
36 Cyan
37 White

Background Colours
40 Black
41 Red
42 Green
43 Yellow
44 Blue
45 Magenta
46 Cyan
47 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.

The above codes were snagged from this page.

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

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!