forked from JohnnyBC2022/ZombiesDevGame
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript13.js
More file actions
42 lines (35 loc) · 1.16 KB
/
script13.js
File metadata and controls
42 lines (35 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
document.addEventListener("keydown", function (event) {
if (event.key === "ArrowLeft") {
redireccionar("../wrong-cards/outdoor-wrong.html");
} else if (event.key === "ArrowRight") {
redireccionar("../right-cards/outdoor-right.html");
}
});
function redireccionar(ruta) {
if (ruta === "../right-cards/outdoor-right.html") {
const puntosActuales = obtenerPuntos();
guardarPuntos(puntosActuales);
} else if (ruta === "../wrong-cards/outdoor-wrong.html") {
const puntosActuales = obtenerPuntos() - 1000;
guardarPuntos(puntosActuales);
}
window.location.href = ruta;
}
function obtenerPuntos() {
return parseInt(localStorage.getItem("puntos"));
}
function guardarPuntos(puntos) {
localStorage.setItem("puntos", puntos);
}
const puntosActuales = obtenerPuntos();
const puntosElement = document.getElementById("points");
puntosElement.textContent = puntosActuales;
document.addEventListener("DOMContentLoaded", function () {
const resetButton = document.querySelector(".reset");
resetButton.addEventListener("click", function () {
reiniciarJuego();
});
});
function reiniciarJuego() {
window.location.href = "../../index.html";
}