I'm creating a 'bullet hell' style game, and have multiple setIntervals functions used to spawn enemies, one-ups, bullets, timers as well as setIntervals to measure collision between the different objects so it knows what to do (e.g. take damage, increase life etc). While the code works fine and all, after a while (I've tried running this multiple times, usually around 40-60s, though sometimes up to 5mins later), it essentially 'crashes' - my collisions don't work anymore, and the spawn intervals work like once every second. I've tried messing around with the setInterval timers but nothing seems to work, the entire code is fairly long so I've pasted it in a pastebin here, any help is appreciated!
Otherwise, the intervals that are running are here:
let startGame = function(ev){
bulletHellPopup.style.display = "none"
if (isMouseUp === false && isEndlessOn === false){ //puting this in a conditional stops the spawnEnemy function from running multiple times
isMouseUp = true;
spawn = setInterval(spawnEnemy, 100); //manipulate this value to adjust spawn rate
time = setInterval(startTimer, 100)
loadTime = Date.now();
};
if (isMouseUp === false && isEndlessOn === true){
isMouseUp = true;
spawn = setInterval(endlessSpawn, 150); //manipulate this value to adjust spawn rate
time = setInterval(startTimer, 100)
loadTime = Date.now();
spawnLivesVariable = setInterval(spawnLives, 10000);
shootFunction = setInterval(spawnBullets, 75);
};
};
let damage = function(ev){
collision(playerCircle, bulletArray);
//console.log(bulletArray.length)
};
let oneUp = function(ev){
collisionLife(playerCircle, lifeArray);
};
let shooting = function(ev){
collisionShoot(shootArray, bulletArray);
};
setInterval(damage, 50);
setInterval(oneUp, 50);
setInterval(shooting, 50);