Skip to content

Commit 9d4a92e

Browse files
committed
Fix rate limit issue
Arkanoid was triggering multiple location.reload() calls on game over, which caused a Cloudflare rate limit. Added gameOver boolean to prevent frames from being drawn once the game is over.
1 parent 9276fcc commit 9d4a92e

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

02-arkanoid-game/index.html

+5
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@
186186
} else if ( // la pelota toca el suelo
187187
y + dy > canvas.height - ballRadius || y + dy > paddleY + paddleHeight
188188
) {
189+
gameOver = true
189190
console.log('Game Over')
190191
document.location.reload()
191192
}
@@ -239,7 +240,11 @@
239240
let frames = 0
240241
let framesPerSec = fps;
241242

243+
let gameOver = false;
244+
242245
function draw() {
246+
if (gameOver) return
247+
243248
window.requestAnimationFrame(draw)
244249

245250
const msNow = window.performance.now()

0 commit comments

Comments
 (0)