Skip to content

Commit

Permalink
0.7.2: mejorados un par de sonidos
Browse files Browse the repository at this point in the history
  • Loading branch information
martinlacorrona committed Nov 25, 2019
1 parent 083e039 commit 4c046c1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
18 changes: 15 additions & 3 deletions src/controladores/ControladorAudio.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ class ControladorAudio {
constructor() {
this.comerSemillaPlaying = false;
this.escapandoPlaying = false;
this.comerEnemigoPlaying = false;
this.perderPlaying = false;

this.audioEscapando = new Audio(sonidos.pacman_modoEscapando);
}
Expand All @@ -19,7 +21,7 @@ class ControladorAudio {
if(!this.escapandoPlaying) {
this.escapandoPlaying = true;
this.audioEscapando = new Audio(sonidos.pacman_modoEscapando);
this.audioEscapando.play();
await this.audioEscapando.play();
}
}

Expand All @@ -29,7 +31,12 @@ class ControladorAudio {
}

async playComerEnemigo() {
new Audio(sonidos.pacman_comeEnemigo).play();
if(!this.comerEnemigoPlaying) {
this.comerEnemigoPlaying = true;
let audio = new Audio(sonidos.pacman_comeEnemigo);
await audio.play();
audio.onended = () => {this.comerEnemigoPlaying = false;}
}
}

async playComerVida() {
Expand All @@ -53,6 +60,11 @@ class ControladorAudio {
}

async playPerder() {
new Audio(sonidos.perder).play();
if(!this.perderPlaying) {
this.perderPlaying = true;
let audio = new Audio(sonidos.perder);
await audio.play();
audio.onended = () => {this.perderPlaying = false;}
}
}
}
2 changes: 1 addition & 1 deletion src/layers/GameLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ class GameLayer extends Layer {
this.reiniciarNivel();
if(this.controladorJuego.vidas == 0)
this.perder();
this.controladorAudio.playPerder();
return;
}

Expand Down Expand Up @@ -157,6 +156,7 @@ class GameLayer extends Layer {
if (this.jugador.estado != estados.muerto && this.jugador.estado != estados.muriendo) {
this.controladorJuego.vidas--;
this.controladorJuego.reiniciarNivel();
this.controladorAudio.playPerder();
}
this.jugador.golpeado();
} else if(this.controladorJuego.estadoJuego === estadosJuego.enemigosEscapando) {
Expand Down

0 comments on commit 4c046c1

Please sign in to comment.