Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created September 29, 2020 17:18
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/92c4514fb1571394c30235a900f92541 to your computer and use it in GitHub Desktop.
Save parzibyte/92c4514fb1571394c30235a900f92541 to your computer and use it in GitHub Desktop.
const botones = [superiorIzquierda, superiorDerecha, inferiorIzquierda, inferiorDerecha];
botones.forEach(boton => {
boton.on("click", async () => {
if (!puedeJugar) {
console.log("No puedes jugar ._.");
return;
}
puedeJugar = false;
const ok = compararSecuenciaDeUsuarioConOriginal(secuencia, boton, contador);
if (ok) {
await encenderYApagarBoton(boton, milisegundosUsuario);
if (contador >= secuencia.length - 1) {
puntaje++;
refrescarPuntaje(puntaje);
await sleep(500);
await turnoDelCpu();
} else {
contador++;
}
puedeJugar = true;
} else {
$btnComenzar.disabled = false;
Swal.fire("Perdiste", `Has perdido. Tu puntuación fue de ${puntaje}. Puedes jugar de nuevo cuando quieras`);
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment