Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
const encenderYApagarBoton = async (boton, duracion) => {
puedeJugar = false;
const colorActual = boton.attr("fill");
let sonidoQueSeReproduce;
if (compararBotones(boton, superiorIzquierda)) {
sonidoQueSeReproduce = sonidoSuperiorIzquierda;
} else if (compararBotones(boton, superiorDerecha)) {
sonidoQueSeReproduce = sonidoSuperiorDerecha;
} else if (compararBotones(boton, inferiorIzquierda)) {
sonidoQueSeReproduce = sonidoInferiorIzquierda
} else {
sonidoQueSeReproduce = sonidoInferiorDerecha;
}
sonidoQueSeReproduce.currentTime = 0;
await sonidoQueSeReproduce.play();
boton.attr("fill", d3.color(colorActual).brighter(gamma))
await sleep(duracion);
boton.attr("fill", d3.color(colorActual));
await sleep(duracion);
await sonidoQueSeReproduce.pause();
puedeJugar = true;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment