Repository navigation
Expand file tree
/
Copy pathgui.html
More file actions
73 lines (72 loc) · 2.45 KB
/
Copy pathgui.html
File metadata and controls
73 lines (72 loc) · 2.45 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Matrix Editor</title>
<style>
.grid {
display: grid;
grid-template-columns: repeat(32, 20px);
gap: 2px;
}
.cell {
width: 20px;
height: 20px;
display: flex;
align-items: center;
justify-content: center;
font-size: 14px;
cursor: pointer;
border: 1px solid #000;
}
.block { background-color: gray; }
.lava { background-color: red; }
.spawn { background-color: blue; }
.goal { background-color: green; }
.matrix-output {
width: 100%;
height: 150px;
margin-top: 10px;
font-family: monospace;
white-space: pre;
}
</style>
</head>
<body>
<div class="grid" id="grid"></div>
<button onclick="printMatrix()">Print Matrix</button>
<textarea id="matrixOutput" class="matrix-output" readonly></textarea>
<script>
let level = new Array(576).fill(0);
for (let i = 0; i < 32; i++) level[i] = 1;
for (let i = 544; i < 576; i++) level[i] = 1;
for (let i = 0; i < 18; i++) level[i * 32] = 1, level[i * 32 + 31] = 1;
const grid = document.getElementById("grid");
function updateGrid() {
grid.innerHTML = "";
level.forEach((value, index) => {
const cell = document.createElement("div");
cell.classList.add("cell");
if (value === 1) cell.classList.add("block");
if (value === 2) cell.classList.add("lava");
if (value === 3) cell.classList.add("spawn");
if (value === 4) cell.classList.add("goal");
cell.onclick = () => {
level[index] = (level[index] + 1) % 5;
updateGrid();
};
grid.appendChild(cell);
});
}
function printMatrix() {
let output = "";
for (let i = 0; i < 18; i++) {
output += level.slice(i * 32, (i + 1) * 32).join(",") + "\n";
}
document.getElementById("matrixOutput").value = output;
}
updateGrid();
</script>
</body>
</html>