Skip to content

Instantly share code, notes, and snippets.

@SandyGifford
Last active April 3, 2020 00:31
Show Gist options
  • Save SandyGifford/209eaad0c2735ce76201869604e77c8b to your computer and use it in GitHub Desktop.
Save SandyGifford/209eaad0c2735ce76201869604e77c8b to your computer and use it in GitHub Desktop.
paste this into your browser's console to start a game - click, or press any key to end the game
/**********************************/
/* */
/* DO NOT PUT ANY CODE YOU DO NOT */
/* UNDERSTAND INTO YOUR BROWSER'S */
/* CONSOLE. */
/* */
/**********************************/
(() => {
const INITIAL_DELAY = 5000;
const PAUSE_TIME = 5000;
const COLORS = ["red", "green", "blue", "yellow"];
const LIMBS = ["foot", "hand"];
const SIDE = ["right", "left"];
setTimeout(() => {
function rArray(array) {
return array[Math.floor(Math.random() * array.length)];
}
function say(str) {
speechSynthesis.speak(new SpeechSynthesisUtterance(str));
}
function stopGame() {
say("stopping game");
clearInterval(n);
document.removeEventListener("keydown", stopGame);
document.removeEventListener("mousedown", stopGame);
}
const n = setInterval(() => {
say(`${rArray(SIDE)} ${rArray(LIMBS)} ${rArray(COLORS)}`);
}, PAUSE_TIME);
document.addEventListener("keydown", stopGame);
document.addEventListener("mousedown", stopGame);
}, INITIAL_DELAY);
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment