Const int not const in function
For some unfathomable(to me) reason the 'w' var member in the SDL_Rect object 'Box' below is being set to '0' after the first complete row is drawn, despite it being initialised to Boxsize. i just cant see why it should change?
Code:
//header files
const int dwnMax = 60;
const int acrMax = 60;
const int Boxsize = 14;
const int Boxgap = 1;
const int Mapsize = 3600;
// other functions
// other functions
void DrawMap(SDL_Surface *screen, SearchArea mapnode[dwnMax][acrMax])
{
int dwn = 0;
int acr = 0;
Uint32 color = 0;
SDL_Rect Box;
Box.w = Boxsize; //this keeps going back to 0 after each complete loop of 'acr'
Box.h = Boxsize;
Box.x = 0;
Box.y = 0;
Slock(screen);
for(dwn = 0; dwn < dwnMax; dwn++)
{
for(acr = 0; acr < acrMax; acr++)
{
if(mapnode[dwn][acr].Walkstate)
{
color = SDL_MapRGB (screen->format, 128, 128, 255);
}
else color = SDL_MapRGB (screen->format, 0, 0, 255);
if(mapnode[dwn][acr].STnode)
{
color = SDL_MapRGB (screen->format, 255, 128, 0);
}
if(mapnode[dwn][acr].TGnode)
{
color = SDL_MapRGB (screen->format, 0, 255, 128);
}
Box.x += (Boxsize + Boxgap);
SDL_FillRect (screen, &Box, color);
}
Box.x = 0;
// Box.w = 14; adding this line is the only way i can get it working at moment
Box.y += (Boxsize + Boxgap);
}
Sulock(screen);
SDL_Flip (screen);
}