Skip to content

Commit 5762774

Browse files
committed
Revert "Auto lose fix"
This reverts commit 5d5a257.
1 parent 5d5a257 commit 5762774

1 file changed

Lines changed: 1 addition & 10 deletions

File tree

Games/Pac_Man_Game/script.js

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -468,8 +468,6 @@ document.addEventListener('DOMContentLoaded', () => {
468468
};
469469

470470
const checkCollision = () => {
471-
if (invincible) return; // Ignore collisions if Pac-Man is invincible
472-
473471
ghosts.forEach(ghost => {
474472
if (ghost.currentIndex === pacmanCurrentIndex) {
475473
if (powerPelletActive) {
@@ -486,22 +484,15 @@ document.addEventListener('DOMContentLoaded', () => {
486484
gameOver = true;
487485
endGame();
488486
} else {
489-
invincible = true; // Set Pac-Man to be invincible
490487
grid[pacmanCurrentIndex].classList.remove('pacman');
491488
pacmanCurrentIndex = 21;
492489
grid[pacmanCurrentIndex].classList.add('pacman');
493-
494-
// Add a brief delay before checking for collisions again
495-
clearTimeout(invincibilityTimeout); // Make sure to clear the previous timeout
496-
invincibilityTimeout = setTimeout(() => {
497-
invincible = false; // Remove invincibility after 3 seconds
498-
}, 3000);
499490
}
500491
}
501492
}
502493
});
503494
};
504-
495+
505496
// Check for collision on Pac-Man movement
506497
setInterval(checkCollision, 100); // Check collision every 100ms
507498

0 commit comments

Comments
 (0)