Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created June 8, 2020 19:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parzibyte/c19cb94f4415a4739a4713e6607548be to your computer and use it in GitHub Desktop.
Save parzibyte/c19cb94f4415a4739a4713e6607548be to your computer and use it in GitHub Desktop.
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