fix bug lose

This commit is contained in:
2024-12-30 10:02:29 +01:00
parent 551144b30d
commit a6065b1aff

View File

@@ -522,6 +522,7 @@ bool blockBox (char **tab2d, vect box_coor)
indice_card[nbr_touch - 1] = i; indice_card[nbr_touch - 1] = i;
} }
} }
if (nbr_touch == 0) if (nbr_touch == 0)
return false; return false;
@@ -572,7 +573,7 @@ bool blockBox (char **tab2d, vect box_coor)
vect normal = card[indice_card[0]]; vect normal = card[indice_card[0]];
vect director1 = card[(indice_card[0] + 1) % 4]; vect director1 = card[(indice_card[0] + 1) % 4];
vect director2 = card[(indice_card[0] + 1) % 4]; vect director2 = card[(indice_card[0] + 3) % 4];
vect dir_test[2] = { director1, director2 }; vect dir_test[2] = { director1, director2 };
bool wall = false; bool wall = false;
@@ -583,22 +584,19 @@ bool blockBox (char **tab2d, vect box_coor)
while (!wall) while (!wall)
{ {
char val = tab2d[current.x][current.y]; char val = tab2d[current.x][current.y];
vect cur_nor = plusVect (current, normal);
char val_nor = tab2d[cur_nor.x][cur_nor.y];
if (val == WALL) if (val == WALL)
wall = true; wall = true;
if (val == TARGET) else if (val == TARGET)
return false; return false;
else if (val_nor != WALL || val_nor != BOX || val_nor != BOX_ON_TARGET)
vect cur_nor = plusVect (current, normal);
val = tab2d[cur_nor.x][cur_nor.y];
if (val != WALL || val != BOX || val != BOX_ON_TARGET)
{ {
return false; return false;
} }
} }
} }
return true; return true;
perror ("error in blockBox");
exit (0);
} }
/** /**