Skip to content

Commit

Permalink
trabajando en el audio
Browse files Browse the repository at this point in the history
  • Loading branch information
martinlacorrona committed Nov 24, 2019
1 parent 1a91f2a commit 187286d
Show file tree
Hide file tree
Showing 11 changed files with 26 additions and 1 deletion.
3 changes: 2 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@

<script src="src/modelos/Espacio.js"></script>
<script src="src/Globales.js"></script>
<script src="src/modelos/ControladorJuego.js"></script>
<script src="src/controladores/ControladorJuego.js"></script>
<script src="src/controladores/ControladorAudio.js"></script>

<script src="src/modelos/Modelo.js"></script>
<script src="src/modelos/Bloque.js"></script>
Expand Down
Binary file added res/sounds/pacman_death.wav
Binary file not shown.
Binary file added res/sounds/pacman_eatenemy.wav
Binary file not shown.
Binary file added res/sounds/pacman_eatingRecolectable.wav
Binary file not shown.
Binary file added res/sounds/pacman_eatlife.wav
Binary file not shown.
Binary file added res/sounds/pacman_extrapac.wav
Binary file not shown.
Binary file added res/sounds/pacman_intermission.wav
Binary file not shown.
8 changes: 8 additions & 0 deletions src/Res.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,14 @@ var imagenes = {
fondo : "res/fondo.png",
};

var sonidos = {
pacman_muere: "res/sounds/pacman_death.wav",
pacman_comeEnemigo: "res/sounds/pacman_eatenemy.wav",
pacman_comeRecolectable: "res/sounds/pacman_eatingRecolectable.wav",
pacman_comeVida: "/res/sounds/pacman_eatlife.wav",
pacman_modoEscapando: "/res/sounds/pacman_intermission.wav",
};

var rutasImagenes = Object.values(imagenes);
cargarImagenes(0);

Expand Down
14 changes: 14 additions & 0 deletions src/controladores/ControladorAudio.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
class ControladorAudio {
constructor() {
this.comerSemillaPlaying = false;
}

async playComerSemilla() {
if(!this.comerSemillaPlaying) {
this.comerSemillaPlaying = true;
let audio = new Audio(sonidos.pacman_comeRecolectable);
await audio.play();
audio.onended = () => {this.comerSemillaPlaying = false;}
}
}
}
File renamed without changes.
2 changes: 2 additions & 0 deletions src/layers/GameLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class GameLayer extends Layer {
this.ultimoControl = orientaciones.derecha;

this.controladorJuego = new ControladorJuego();
this.controladorAudio = new ControladorAudio();

this.puntuacionFinal = undefined;

Expand Down Expand Up @@ -535,6 +536,7 @@ class GameLayer extends Layer {
}

comerSemillaBasica(x, y) {
this.controladorAudio.playComerSemilla();
this.puntosImagenes.push(
new PuntosImagen(x, y, imagenes.puntos_10, 100));
this.controladorJuego.puntosNivel += 10;
Expand Down

0 comments on commit 187286d

Please sign in to comment.