Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created September 29, 2020 16:52
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
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