Change color of specific characters in colsole

i have a map for a game that is displayed in the console. now what i would want to do is be able to make the trees (T) colored green and the water (W) blue and so on.

what i would like past that is have trees that are green and trees that are brown for live trees and dead trees and have the character (@) interact with each one in a different way. but for now just getting single colors would be a nice start. I know how to color all of the text and all of the background but i dont know how to do individuals. especially in an array. is this even possible to do in an array?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
char Level[100][100] =
    {
     "###############################################",
     "#@                                          WW#",
     "#            WWW                            WW#",
     "#            WWWW           a              WW #",
     "#           WWW                   #        WW #",
     "#                                # #      WW  #",
     "#                     T         #   #    WW   #",
     "#   T            f              #  B#   WW    #",
     "#                               ## ##  WW     #",
     "#                                       WW    #",
     "#                                  T    WW    #",
     "#                   T            T       WW   #",
     "#     T                       T       T  WW   #",
     "#               T              T T T    WW    #",
     "#                                  T  TWW T   #",
     "#  p                             T     TWW    #",
     "#                              T    T T WWT   #",
     "#      T                     T     T WWWWWW   #",
     "# +                           T   WWWWWWWWWWWW#",
     "#                                WWWWWWWWWWWWW#",
     "###############################################"
     };
If you're using Windows, have a look at SetConsoleTextAttribute:
http://msdn.microsoft.com/en-us/library/ms686047
Last edited on
Thanks that is really helpful.
Topic archived. No new replies allowed.