app/scripts/core/gameCoordinator.js
/**
   * Animates Pacman's death, subtracts a life, and resets character positions if
   * the player has remaining lives.
   */
Animates Pacman's death, subtracts a life, and resets character positions if
the player has remaining lives.
Animates Pacman ' s death subtracts a life and resets character positions if the player has remaining lives .
deathSequence() {
    this.allowPause = false;
    this.cutscene = true;
    this.soundManager.setCutscene(this.cutscene);
    this.soundManager.stopAmbience();
    this.removeTimer({ detail: { timer: this.fruitTimer } });
    this.removeTimer({ detail: { timer: this.ghostCycleTimer } });
    this.removeTimer({ detail: { timer: this.endIdleTimer } });
    this.removeTimer({ detail: { timer: this.ghostFlashTimer } });
    this.allowKeyPresses = false;
    this.pacman.moving = false;
    this.ghosts.forEach((ghost) => {
      const ghostRef = ghost;
      ghostRef.moving = false;
    });
    new Timer(() => {
      this.ghosts.forEach((ghost) => {
        const ghostRef = ghost;
        ghostRef.display = false;
      });
      this.pacman.prepDeathAnimation();
      this.soundManager.play(deathSound);
      if (this.lives > 0) {
        this.gameBackend
          .updateSession({id: this.gameSession.id, points: this.points})
          .then(() => {
              this.lives -= 1;
              new Timer(() => {
                this.mazeCover.style.visibility = 'visible';
                new Timer(() => {
                  this.allowKeyPresses = true;
                  this.mazeCover.style.visibility = 'hidden';
                  this.pacman.reset();
                  this.ghosts.forEach((ghost) => {
                    ghost.reset();
                  });
                  this.fruit.hideFruit();
                  this.startGameplay();
                }, 500);
              }, 2250);
          })
      } else {
        this.gameBackend
          .deleteSession({id: this.gameSession.id, points: this.points})
          .then(response => this.gameOver())
          .then(() => this.updateHighscore());
      }
    }, 750);
  }
deathSequence ( ) { this . allowPause = false ; this . cutscene = true ; this . soundManager . setCutscene ( this . cutscene ) ; this . soundManager . stopAmbience ( ) ; this . removeTimer ( { detail : { timer : this . fruitTimer } } ) ; this . removeTimer ( { detail : { timer : this . ghostCycleTimer } } ) ; this . removeTimer ( { detail : { timer : this . endIdleTimer } } ) ; this . removeTimer ( { detail : { timer : this . ghostFlashTimer } } ) ; this . allowKeyPresses = false ; this . pacman . moving = false ; this . ghosts . forEach ( ( ghost ) => { const ghostRef = ghost ; ghostRef . moving = false ; } ) ; new Timer ( ( ) => { this . ghosts . forEach ( ( ghost ) => { const ghostRef = ghost ; ghostRef . display = false ; } ) ; this . pacman . prepDeathAnimation ( ) ; this . soundManager . play ( deathSound ) ; if ( this . lives > 0 ) { this . gameBackend . updateSession ( { id : this . gameSession . id , points : this . points } ) . then ( ( ) => { this . lives -= 1 ; new Timer ( ( ) => { this . mazeCover . style . visibility = 'visible' ; new Timer ( ( ) => { this . allowKeyPresses = true ; this . mazeCover . style . visibility = 'hidden' ; this . pacman . reset ( ) ; this . ghosts . forEach ( ( ghost ) => { ghost . reset ( ) ; } ) ; this . fruit . hideFruit ( ) ; this . startGameplay ( ) ; } , 500 ) ; } , 2250 ) ; } ) } else { this . gameBackend . deleteSession ( { id : this . gameSession . id , points : this . points } ) . then ( response => this . gameOver ( ) ) . then ( ( ) => this . updateHighscore ( ) ) ; } } , 750 ) ; }
Animates Pacman's death, subtracts a life, and resets character positions if
 the player has remaining lives.
Animates Pacman ' s death subtracts a life and resets character positions if the player has remaining lives .