Rebase of feature/mirror + merge with the grid program

This commit is contained in:
2026-03-30 15:05:57 +02:00
parent 577357b090
commit a791415bd3
3 changed files with 21 additions and 14 deletions

View File

@@ -24,7 +24,7 @@ let grid = [
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
]
@@ -53,6 +53,12 @@ function loadGrid () {
cell.classList.add("colored-laser");
break;
case legend.mirror:
const btnMirror = document.createElement("button");
btnMirror.classList.add("btn-mirror");
btnMirror.addEventListener("click", () => rotateMirror(btnMirror));
btnMirror.style.transform = "rotate(0deg)";
btnMirror.style.width = "100%";
cell.appendChild(btnMirror);
cell.classList.add("mirror");
break;
case legend.door:
@@ -82,4 +88,15 @@ function loadGrid () {
}
}
loadGrid();
loadGrid();
function rotateMirror(mirror) {
let angle = 0;
if (mirror.style.transform == "") {
angle = 0;
} else {
angle = parseInt(mirror.style.transform.split("(")[1].split("deg")[0])%360;
}
mirror.style.transform = `rotate(${angle+45}deg)`;
}