Created
June 8, 2020 19:07
-
-
Save parzibyte/c19cb94f4415a4739a4713e6607548be to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
printf("** BUSCAMINAS **\nBy Parzibyte\n"); | |
char tablero[FILAS][COLUMNAS]; | |
int deberiaMostrarMinas = 0; | |
// Alimentar rand | |
srand(getpid()); | |
iniciarTablero(tablero); | |
colocarMinasAleatoriamente(tablero); | |
// Ciclo infinito. Se rompe si gana o pierde, y eso se define con | |
// "deberiaMostrarMinas" | |
while (1) { | |
imprimirTablero(tablero, deberiaMostrarMinas); | |
if (deberiaMostrarMinas) { | |
break; | |
} | |
int columna; | |
char fila; | |
printf("Ingresa la fila: "); | |
scanf(" %c", &fila); | |
printf("Ingresa la columna: "); | |
scanf("%d", &columna); | |
int status = abrirCasilla(fila, columna, tablero); | |
if (noHayCasillasSinAbrir(tablero)) { | |
printf("Has ganado\n"); | |
deberiaMostrarMinas = 1; | |
} else if (status == ERROR_ESPACIO_YA_DESCUBIERTO) { | |
printf("Ya has abierto esta casilla\n"); | |
} else if (status == ERROR_MINA_ENCONTRADA) { | |
printf("Has perdido\n"); | |
deberiaMostrarMinas = 1; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment