Jump to content
Sign in to follow this  
  • entries
  • comments
  • views

Textmode madness

Sign in to follow this  


i've been doing alot of textmode junk lately and i figured i'd go and see if i could get a reasonable way to add color to stuff. i got this cool little Color class made up that you can use in a cout line and i couldn't help throwing a program together to show it off!

here's a code snippet:

cout	<< Green
<< "You stand in a field, nearby " << LightGreen << "Tantegel" << Green << " castle. Outside the" << endl
<< "castle is a bustling town, " << LightGreen << "Brecconary" << Green << ". A foreboding fortress" << endl
<< "looms on cliffs in the middle of a bay to the south. " << endl
<< endl
<< "Enter [" << White << "T" << Green << "]" << LightGreen << "antegel" << Green << endl
<< "Enter [" << White << "B" << Green << "]" << LightGreen << "recconary" << Green << endl
<< "Head toward [" << White << "G" << Green << "]" << LightGreen << "arinham" << Green << " (3 turns)" << endl
<< "Head toward [" << White << "K" << Green << "]" << LightGreen << "ol" << Green << " (4 turns)" << endl
<< "E[" << White << "x" << Green << "]plore the field" << endl

i could probably do the option selection a little cleaner, but i was just throwing together something quick to see how awful it'd look. if you start with a line and don't bother with color until you've got it written out, its not too terrible. i'm even gonna keep working on this game and see where it goes ^_^ it feels like such a waste of time, but screw it.
Sign in to follow this  

1 Comment

Recommended Comments

A reccommendation for making life even easier:

Make a function (or class) that takes an output string to display, but use colour codes to indicate colour changes. That way something like

cout << "Enter [" << White << "T" << Green << "]" << LightGreen << "antegel" << Green << endl;

can become:

MyOutput << "{g}Enter [{W}T{g}]{G}antegel{g}\n";

Interpreting {g} as a colour change to green, {W} to white, {G} to light green, etc. This method is very common in MUDs, and works oodles easier than having to manually cut your string up with <<'s every time you want to insert a colour.

Share this comment

Link to comment

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
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!