Browse Source

Dame bewegung erweiterung, Emman Mensdorf

remotes/origin/Läufer-fertig,-Hendrik-Voß
Emman Mensdorf 11 months ago
parent
commit
1ae5132e05
  1. 23
      src/Dame.c

23
src/Dame.c

@ -12,5 +12,28 @@ bool istzugerlaubt_Dame(char** Brett, int startX, int startY, int endX, int endY
if (endX < 0 || endX >= 8 || endY < 0 || endY >= 8)
return false;
int dx = abs(endX - startX);
int dy = abs(endY - startY);
if (dx != 0 && dy != 0 && dx != dy)
return false;
if (dx > 0) {
int dirX = (endX - startX) / dx;
for (int i = 1; i < dx; i++) {
if (Brett[startY + i * dirX][startX + i * dirX] != ' ')
return false;
}
}
if (dy > 0) {
int dirY = (endY - startY) / dy;
for (int i = 1; i < dy; i++) {
if (Brett[startY + i * dirY][startX + i * dirY] != ' ')
return false;
}
}
}
Loading…
Cancel
Save