Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created September 29, 2020 16:52
Show Gist options
  • Save parzibyte/69068e6292d3d3bc4456d82c9403ce6c to your computer and use it in GitHub Desktop.
Save parzibyte/69068e6292d3d3bc4456d82c9403ce6c to your computer and use it in GitHub Desktop.
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