Sign in to follow this  
C_Programmer0101

Changing Color in a text based RPG

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
Binomine    611
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
sand_man    100
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
game mercenary    102
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
silverphyre673    454
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
wasted_druid    692
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.

***EDIT
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
Guest Anonymous Poster   
Guest Anonymous Poster
http://dictionary.reference.com/search?q=parse

3b: I simply couldn't parse what you just said.

what the hell does parse mean

Share this post


Link to post
Share on other sites
wasted_druid    692
http://dictionary.reference.com/search?q=parse

4. Computer Science. To analyze or separate (input, for example) into more easily processed components.

I started by parsing the text I had into more easily processed components, then I rebuilt them into a string that is VT100 compatible.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this