I currently have the basic function to change the colour
void setColour(short colour){
HANDLE hcon = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(hcon, colour);
}
setColour(10);
//Previous text to be highlighted?
setColour(7); //Sets colour to default console colour
Using this is for printing new text in different colour I understand, but I'm currently creating a game that requires text to be highlighted that's already been printed. I know this can be done, but I don't know how..
One way is to delete the current text and reprint the same text, anyhow systems today are lighting fast so you wont make out difference.
To do this we use \r
cout << "something" << '\r' << flush.
The '\r' means "carriage return", It will go to beginning of line.
And the 'flush' means "make sure what I've just printed reaches the output now.
After this reprint the same text with color of your choice.
NOTE: This happens so fast you will feel as if the text changed the colour.