Skip to content

Instantly share code, notes, and snippets.

@rodolfoghi
Last active July 12, 2018 23:15
Show Gist options
  • Save rodolfoghi/c86bcebb2e8680b77f1b9f253ea28101 to your computer and use it in GitHub Desktop.
Save rodolfoghi/c86bcebb2e8680b77f1b9f253ea28101 to your computer and use it in GitHub Desktop.
<script>
/**
* Pega a imagem com id fantasma1 e salva em uma variável
* para que seja possível manipularmos com JavaScript.
*/
const $fantasma1 = document.getElementById("fantasma1");
// Esconde a imagem fantasma1.
function esconda() {
$fantasma1.style.display = "none";
}
// Mostra a imagem fantasma1.
function mostre() {
$fantasma1.style.display = "";
}
// Função principal do jogo.
function jogo() {
if ($fantasma1.style.display == "none") {
mostre();
} else {
esconda();
}
}
// Define o intervalo de repetição em milissegundos.
setInterval(jogo, 1000);
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment