Spaces:
Running
Running
Update index.html
Browse files- index.html +72 -0
index.html
CHANGED
@@ -64,6 +64,33 @@
|
|
64 |
color: white;
|
65 |
font-size: 16px;
|
66 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
67 |
</style>
|
68 |
</head>
|
69 |
<body>
|
@@ -84,6 +111,14 @@
|
|
84 |
<button id="homeButton" onclick="goHome()">Home</button>
|
85 |
</div>
|
86 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
87 |
<script>
|
88 |
const canvas = document.getElementById('gameCanvas');
|
89 |
const ctx = canvas.getContext('2d');
|
@@ -369,6 +404,43 @@
|
|
369 |
event.preventDefault();
|
370 |
});
|
371 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
372 |
window.onload = () => {
|
373 |
document.getElementById('welcomeScreen').style.display = 'block';
|
374 |
// No need to play music on window load
|
|
|
64 |
color: white;
|
65 |
font-size: 16px;
|
66 |
}
|
67 |
+
|
68 |
+
/* Style for control buttons */
|
69 |
+
.control-buttons {
|
70 |
+
position: absolute;
|
71 |
+
bottom: 20px;
|
72 |
+
left: 50%;
|
73 |
+
transform: translateX(-50%);
|
74 |
+
display: flex;
|
75 |
+
justify-content: center;
|
76 |
+
gap: 10px;
|
77 |
+
}
|
78 |
+
.control-buttons button {
|
79 |
+
width: 50px;
|
80 |
+
height: 50px;
|
81 |
+
font-size: 24px;
|
82 |
+
background-color: #444;
|
83 |
+
color: white;
|
84 |
+
border: none;
|
85 |
+
border-radius: 5px;
|
86 |
+
cursor: pointer;
|
87 |
+
}
|
88 |
+
.control-buttons button:hover {
|
89 |
+
background-color: #666;
|
90 |
+
}
|
91 |
+
.control-buttons button:active {
|
92 |
+
background-color: #333;
|
93 |
+
}
|
94 |
</style>
|
95 |
</head>
|
96 |
<body>
|
|
|
111 |
<button id="homeButton" onclick="goHome()">Home</button>
|
112 |
</div>
|
113 |
|
114 |
+
<!-- On-screen control buttons -->
|
115 |
+
<div class="control-buttons">
|
116 |
+
<button id="rotateBtn">🔄</button>
|
117 |
+
<button id="leftBtn">⬅️</button>
|
118 |
+
<button id="downBtn">⬇️</button>
|
119 |
+
<button id="rightBtn">➡️</button>
|
120 |
+
</div>
|
121 |
+
|
122 |
<script>
|
123 |
const canvas = document.getElementById('gameCanvas');
|
124 |
const ctx = canvas.getContext('2d');
|
|
|
404 |
event.preventDefault();
|
405 |
});
|
406 |
|
407 |
+
// On-screen button event handlers
|
408 |
+
document.getElementById('rotateBtn').addEventListener('click', () => {
|
409 |
+
if (game && game.state === 'start') {
|
410 |
+
game.rotateFigure();
|
411 |
+
drawGrid();
|
412 |
+
drawFigure();
|
413 |
+
drawText();
|
414 |
+
}
|
415 |
+
});
|
416 |
+
|
417 |
+
document.getElementById('leftBtn').addEventListener('click', () => {
|
418 |
+
if (game && game.state === 'start') {
|
419 |
+
game.goSide(-1);
|
420 |
+
drawGrid();
|
421 |
+
drawFigure();
|
422 |
+
drawText();
|
423 |
+
}
|
424 |
+
});
|
425 |
+
|
426 |
+
document.getElementById('downBtn').addEventListener('click', () => {
|
427 |
+
if (game && game.state === 'start') {
|
428 |
+
game.goDown();
|
429 |
+
drawGrid();
|
430 |
+
drawFigure();
|
431 |
+
drawText();
|
432 |
+
}
|
433 |
+
});
|
434 |
+
|
435 |
+
document.getElementById('rightBtn').addEventListener('click', () => {
|
436 |
+
if (game && game.state === 'start') {
|
437 |
+
game.goSide(1);
|
438 |
+
drawGrid();
|
439 |
+
drawFigure();
|
440 |
+
drawText();
|
441 |
+
}
|
442 |
+
});
|
443 |
+
|
444 |
window.onload = () => {
|
445 |
document.getElementById('welcomeScreen').style.display = 'block';
|
446 |
// No need to play music on window load
|