Last active
July 12, 2018 23:15
-
-
Save rodolfoghi/c86bcebb2e8680b77f1b9f253ea28101 to your computer and use it in GitHub Desktop.
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
<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