File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments