Code:
void win(Map*initialMap , Map* currentMap , int x , int y){
int i;
int j;
for(i=0; i < currentMap->height ; i++){
// all boxes are pushed into all targets
for(j=0; j < currentMap->width ; j++){
if (currentMap->map2D[y+j][x+i]=='@' && initialMap->map2D[y-j][x-i]=='!' ) <-- error
return ;
}
}
}
You need a simpler and more transparent one, imo.
Code:
int isWon(int currentMap, int offsetR, int offsetC, int maxRowGoal, int maxColGoal) {
int r, c;
int won = 1; //assume game is won
for(r = 0; r < maxRowGoal; r++) {
for(c = 0; c < maxColGoal; c++) {
if(currentMap[r+offsetR][c+offsetC] != answerMap[r][c]) {
won = 0;
break;
}
}
}
return won;
}
The offsetR/C gives the starting row and column, and maxRow/ColGoal, gives the ending coordinates. imo a function to check if the game is won, should return SOMETHING to signify if the game is won or not.
I have this game (at least the first 50 levels of one version of it by "Thinking Rabbit"), and there are some levels of it that the solution just makes me laugh.