Changing Color in a text based RPG

Started by
10 comments, last by wasted_druid 18 years, 10 months ago
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
Computers are worlds of Exploration?
Advertisement
although I have never gone into conio I do believe it can do that.
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().
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?
Computers are worlds of Exploration?
Oh I also forgot to ask if there is a tutorial somewhere that I can learn how to do the color effect?
Computers are worlds of Exploration?
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
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.
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.
my siteGenius is 1% inspiration and 99% perspiration
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.






Computers are worlds of Exploration?
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
The above codes were snagged from this page.

[Edited by - wasted_druid on June 10, 2005 4:14:19 PM]
----------------------------------------------------------No matter how eloquently you state your argument, the fact remains that the toilet seat is a bistable device. Therefore it's natural position is no more down than it is up.[SDL Smooth Tile Scrolling]

This topic is closed to new replies.

Advertisement