Skip to content

Instantly share code, notes, and snippets.

@rogerblanton
Created January 27, 2021 21:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rogerblanton/3a181cf64006996026d10b5a375834e2 to your computer and use it in GitHub Desktop.
Save rogerblanton/3a181cf64006996026d10b5a375834e2 to your computer and use it in GitHub Desktop.
A simple HTML file I made to randomly pick Floor is Lava colors because the board spinner that comes with the game is cheap and warps
<!doctype html>
<html>
<head>
<style>
body {
cursor: pointer;
height: 100vh;
}
</style>
</head>
<body>
<script type="text/javascript">
const colors = ["yellow", "blue", "green", "gray", "red"];
let initGame = (colors, maxRoundTime) => {
console.log("init game function fired");
let loopCount = 0;
let randomBackground = setInterval(randomizeBackground, 100);
let randomizeBackground = () => {
loopCount++
if (loopCount <= getRandomInt(20,0) + 5) {
let currentColor = getRandomInt(colors.length, 2);
document.body.style.backgroundColor = colors[currentColor];
} else {
clearInterval(randomBackground);
loopCount = 0;
}
}
}
let getRandomInt = (max, currentRandomNum) {
let returnVal;
do {
returnVal = Math.floor(Math.random() * Math.floor(max));
} while (returnVal === getRandomInt.last);
getRandomInt.last = returnVal;
return returnVal;
}
window.addEventListener('click', function() {initGame(colors, 5) });
window.addEventListener('load', function() {initGame(colors, 5) });
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment