Closed DG-98 closed 3 years ago
When you dont get hit for a while you instantly love all lives and lose the game.
const bombHit = () => { for (i = 0; i < bombSpawned.length; i++) { if ( bombSpawned[i].y < bob.y + bob.width && bombSpawned[i].y + bombSpawned[i].height > bob.y && bombSpawned[i].x < bob.x + bob.width && bombSpawned[i].x + bombSpawned[i].width > bob.x ) { gotHitSound.play() lives -- bombSpawned.shift([i]) if (lives === 0) { bombSpawned.alive = false clearInterval(interval) ctx.font= '40px Arial' ctx.fillText("Game over!", 290, 400) ctx.fillStyle = "white" ctx.fillText("Press W to play again!", 210, 450) ctx.fillStyle = "white" } } } }
I'm honestly not sure at all.
I've tried messing around with the if statement after losing all lives but the issue may be somewhere else
What's the problem you're trying to solve?
When you dont get hit for a while you instantly love all lives and lose the game.
Post any code you think might be relevant (one fenced block per file)
If you see an error message, post it here. If you don't, what unexpected behavior are you seeing?
What is your best guess as to the source of the problem?
I'm honestly not sure at all.
What things have you already tried to solve the problem?
I've tried messing around with the if statement after losing all lives but the issue may be somewhere else