Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created November 2, 2020 17:31
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 parzibyte/55e8fd4da60b0f0c845b54504dcf438d to your computer and use it in GitHub Desktop.
Save parzibyte/55e8fd4da60b0f0c845b54504dcf438d to your computer and use it in GitHub Desktop.
class Utils {
static getRandomNumberInRange = (min, max) => {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
static getRandomColor() {
return Game.COLORS[Utils.getRandomNumberInRange(0, Game.COLORS.length - 1)];
}
static loadSound(src, loop) {
const sound = document.createElement("audio");
sound.src = src;
sound.setAttribute("preload", "auto");
sound.setAttribute("controls", "none");
sound.loop = loop || false;
sound.style.display = "none";
document.body.appendChild(sound);
return sound;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment