Browse Source

Update src/main/c/Template/Battleship_game.c

remotes/origin/Battleship_game
fdai7729 11 months ago
parent
commit
ba3794673b
  1. 87
      src/main/c/Template/Battleship_game.c

87
src/main/c/Template/Battleship_game.c

@ -143,7 +143,94 @@ int multiplayer() {
!feld(ships1);
}
printf("Player 1, platziere deinen Kreuzer (4).\nKoordinate: ");
scanf(" %c%d", &letco, &numco);
coor1 = convertcoor(letco, numco);
ships1[coor1] = 'X';
for (int i = 0; i < 3; i++) {
!feld(ships1);
printf("\n");
scanf(" %c%d", &letco, &numco);
coor2 = convertcoor(letco, numco);
if (coor2 == coor1 + 1 || coor2 == coor1 - 1) {
ships1[coor2] = 'X';
coor1 = coor2;
}
else if (coor2 == coor1 + 10 || coor2 == coor1 - 10) {
ships1[coor2] = 'X';
coor1 = coor2;
}
else {
printf("Ungueltige Eingabe.\n");
i--;
}
!feld(ships1);
}
for (int i = 0; i < 2; i++) {
printf("Player 1, platziere deine Zerstoerer 2x(3).\nKoordinate: ");
scanf(" %c%d", &letco, &numco);
coor1 = convertcoor(letco, numco);
ships1[coor1] = 'X';
for (int i = 0; i < 2; i++) {
!feld(ships1);
printf("\n");
scanf(" %c%d", &letco, &numco);
coor2 = convertcoor(letco, numco);
if (coor2 == coor1 + 1 || coor2 == coor1 - 1) {
ships1[coor2] = 'X';
coor1 = coor2;
}
else if (coor2 == coor1 + 10 || coor2 == coor1 - 10) {
ships1[coor2] = 'X';
coor1 = coor2;
}
else {
printf("Ungueltige Eingabe.\n");
i--;
}
!feld(ships1);
}
}
printf("Player 1, platziere dein U-Boot (2).\nKoordinate: ");
scanf(" %c%d", &letco, &numco);
coor1 = convertcoor(letco, numco);
ships1[coor1] = 'X';
!feld(ships1);
printf("\n");
scanf(" %c%d", &letco, &numco);
coor2 = convertcoor(letco, numco);
if (coor2 == coor1 + 1 || coor2 == coor1 - 1) {
ships1[coor2] = 'X';
coor1 = coor2;
}
else if (coor2 == coor1 + 10 || coor2 == coor1 - 10) {
ships1[coor2] = 'X';
coor1 = coor2;
}
else {
printf("Ungueltige Eingabe.\n");
}
!feld(ships1);
int k2 = 1;

Loading…
Cancel
Save