Skip to content

Instantly share code, notes, and snippets.

@rodolfoghi
Created July 13, 2018 00:43
Show Gist options
  • Save rodolfoghi/388e4075768f54d4370665c53315ab6f to your computer and use it in GitHub Desktop.
Save rodolfoghi/388e4075768f54d4370665c53315ab6f to your computer and use it in GitHub Desktop.
// Constante referente ao palco
const $palco = document.getElementById('palco');
// https://developer.mozilla.org/pt-BR/docs/Web/JavaScript/Reference/Global_Objects/Math/random
function getRandomInt(min, max) {
min = Math.ceil(min);
max = Math.floor(max);
return Math.floor(Math.random() * (max - min)) + min;
}
// Esconde a imagem fantasma1.
function esconda() {
$fantasma1.style.top = getRandomInt(0, $palco.clientHeight - $fantasma1.clientHeight) + "px";
$fantasma1.style.left = getRandomInt(0, $palco.clientWidth - $fantasma1.clientWidth) + "px";
$fantasma1.style.display = "none";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment