/encenderYApagarBoton.js Secret
Created
September 29, 2020 16:52
Star
You must be signed in to star a gist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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