Created
January 27, 2021 21:37
-
-
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
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
<!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