Changing Color in a text based RPG
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
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?
Oh I also forgot to ask if there is a tutorial somewhere that I can learn how to do the color effect?
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.
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.
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.
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.
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...
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]
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]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement