I would like to say hello, first of all.
I have been attempting to change the color of a character on my program for some time now.
The characters in question will represent lava tiles with the letter "L" in my program.
I would like to know how I can change individual character color in a Console program without having the change affecting all the characters.
Any ideas?
(The platform in question is windows console.)
One more line
0
Newbie Poster
Recommended Answers
Jump to PostYou can switch the console text color at will quite easily. Just change it to the desired color before printing the character, then change it back after printing the character:
#include <iostream> #include <windows.h> class TextAttr { friend std::ostream& operator<<(std::ostream& out, TextAttr attr) { SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), attr.value); return …
All 3 Replies
Reply to this topic
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.