Skip to content

Commit

Permalink
Añadir sonidos
Browse files Browse the repository at this point in the history
  • Loading branch information
sergio-visma committed Oct 16, 2023
1 parent a915e87 commit 7d1eb8a
Show file tree
Hide file tree
Showing 18 changed files with 17 additions and 1,036 deletions.
9 changes: 8 additions & 1 deletion math.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,16 @@ var Homework = /** @class */ (function () {
this.puntos++;
this.actualizarPuntos();
this.animar(this.puntosNumero);
this.sonar('acierto');
this.crearOperacion();
};
Homework.prototype.fallar = function () {
var _a;
(_a = document.getElementById("respuesta")) === null || _a === void 0 ? void 0 : _a.classList.add('error');
this.vidas--;
this.animar(this.vidasNumero);
this.actualizarVidas();
this.animar(this.vidasNumero);
this.sonar('error');
};
Homework.prototype.gameOver = function () {
var _a;
Expand All @@ -121,6 +123,11 @@ var Homework = /** @class */ (function () {
Homework.prototype.mostrar = function (paraMostrar) {
document.getElementById(paraMostrar).style.display = 'inline-block';
};
Homework.prototype.sonar = function (evento) {
var random = this.randomNumber(6);
var audio = new Audio("sound/".concat(evento, "/0").concat(random, ".mp3"));
audio.play();
};
return Homework;
}());
;
Expand Down
10 changes: 9 additions & 1 deletion math.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,14 +115,16 @@ class Homework {
this.puntos++;
this.actualizarPuntos();
this.animar(this.puntosNumero);
this.sonar('acierto');
this.crearOperacion();
}

fallar() {
document.getElementById(`respuesta`)?.classList.add('error');
this.vidas--;
this.animar(this.vidasNumero);
this.actualizarVidas();
this.animar(this.vidasNumero);
this.sonar('error');
}

gameOver() {
Expand Down Expand Up @@ -160,6 +162,12 @@ class Homework {
mostrar(paraMostrar) {
document.getElementById(paraMostrar)!.style.display = 'inline-block';
}

sonar(evento) {
let random = this.randomNumber(6);
let audio = new Audio(`sound/${evento}/0${random}.mp3`);
audio.play();
}
};

const homeWork = new Homework();
Loading

0 comments on commit 7d1eb8a

Please sign in to comment.