Code:
if(flag==1)
{
}
else
I'll assume you meant to do this for some vital reason.
Code:
switch(cm[xc][yc])
{
/* CONSTRUCTS */
case '#':
if(nocolor==0) textcolor(wall);
break;
case '.':
if(nocolor==0) textcolor(grass);
break;
case ',':
if(nocolor==0) textcolor(floor);
break;
case '~':
if(nocolor==0) textcolor(water);
break;
case '/':
if(nocolor==0) textcolor(door);
break;
case '+':
if(nocolor==0) textcolor(doorc);
nm[xc][yc]=2;
break;
case 'E':
if(nocolor==0) textcolor(enter);
break;
default:
textcolor(def);
break;
This would be much better using a lookup table:
Code:
enum { L_wall, L_grass, L_water, L_door, L_doorc, L_enter, L_max };
struct {
char c;
int color;
} lookup[] =
{
{ '#', wall },
{ '.', grass },
{ ',', floor},
{ '~', water },
{ '/', door },
{ '+', doorc },
{ 'e', enter },
{ 0, def },
}
Then you slightly modify how you store the data and use the lookup table to pull the correct character and color.
Quzah.