Spaces:
Running
Running
Update index.html
Browse files- index.html +25 -9
index.html
CHANGED
@@ -4,6 +4,9 @@
|
|
4 |
<meta charset="UTF-8">
|
5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6 |
<title>Tetris Game by MOUSE(VIDraft-mouse1.hf.space)</title>
|
|
|
|
|
|
|
7 |
<style>
|
8 |
* { margin: 0; padding: 0; box-sizing: border-box; }
|
9 |
body {
|
@@ -35,7 +38,6 @@
|
|
35 |
text-align: center;
|
36 |
margin-bottom: 2rem;
|
37 |
}
|
38 |
-
|
39 |
.game-container {
|
40 |
display: flex;
|
41 |
gap: 20px;
|
@@ -112,6 +114,8 @@
|
|
112 |
}
|
113 |
</style>
|
114 |
</head>
|
|
|
|
|
115 |
<body>
|
116 |
<h1 class="title">MOUSE Autonomous Tetris</h1>
|
117 |
<p class="subtitle">"One-minute creation by AI Coding Autonomous Agent MOUSE"</p>
|
@@ -311,13 +315,11 @@
|
|
311 |
document.getElementById('level').textContent = level;
|
312 |
}
|
313 |
}
|
314 |
-
|
315 |
// Leaderboard functions
|
316 |
function getLeaderboard() {
|
317 |
const leaderboard = JSON.parse(localStorage.getItem('tetrisLeaderboard') || '[]');
|
318 |
return leaderboard;
|
319 |
}
|
320 |
-
|
321 |
function updateLeaderboardDisplay() {
|
322 |
const leaderboardElement = document.getElementById('leaderboard');
|
323 |
const leaderboard = getLeaderboard();
|
@@ -332,7 +334,6 @@
|
|
332 |
`)
|
333 |
.join('');
|
334 |
}
|
335 |
-
|
336 |
function addScore(name, score) {
|
337 |
const leaderboard = getLeaderboard();
|
338 |
leaderboard.push({ name, score });
|
@@ -340,7 +341,6 @@
|
|
340 |
localStorage.setItem('tetrisLeaderboard', JSON.stringify(leaderboard));
|
341 |
updateLeaderboardDisplay();
|
342 |
}
|
343 |
-
|
344 |
function submitScore() {
|
345 |
const playerName = document.getElementById('player-name').value.trim();
|
346 |
if (playerName) {
|
@@ -422,7 +422,7 @@
|
|
422 |
case 40: // Down
|
423 |
if(isValidMove(currentPiece, 0, 1)) {
|
424 |
currentPiece.y++;
|
425 |
-
score += 1;
|
426 |
document.getElementById('score').textContent = score;
|
427 |
drawBoard();
|
428 |
}
|
@@ -436,17 +436,33 @@
|
|
436 |
case 32: // Space (Hard Drop)
|
437 |
while(isValidMove(currentPiece, 0, 1)) {
|
438 |
currentPiece.y++;
|
439 |
-
score += 2;
|
440 |
}
|
441 |
document.getElementById('score').textContent = score;
|
442 |
update();
|
443 |
break;
|
444 |
}
|
445 |
});
|
446 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
447 |
// Initialize game
|
448 |
updateLeaderboardDisplay();
|
449 |
startGame();
|
450 |
</script>
|
451 |
</body>
|
452 |
-
</html>
|
|
|
4 |
<meta charset="UTF-8">
|
5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6 |
<title>Tetris Game by MOUSE(VIDraft-mouse1.hf.space)</title>
|
7 |
+
<audio id="bgMusic" loop>
|
8 |
+
<source src="sound.wav" type="audio/wav">
|
9 |
+
</audio>
|
10 |
<style>
|
11 |
* { margin: 0; padding: 0; box-sizing: border-box; }
|
12 |
body {
|
|
|
38 |
text-align: center;
|
39 |
margin-bottom: 2rem;
|
40 |
}
|
|
|
41 |
.game-container {
|
42 |
display: flex;
|
43 |
gap: 20px;
|
|
|
114 |
}
|
115 |
</style>
|
116 |
</head>
|
117 |
+
|
118 |
+
|
119 |
<body>
|
120 |
<h1 class="title">MOUSE Autonomous Tetris</h1>
|
121 |
<p class="subtitle">"One-minute creation by AI Coding Autonomous Agent MOUSE"</p>
|
|
|
315 |
document.getElementById('level').textContent = level;
|
316 |
}
|
317 |
}
|
|
|
318 |
// Leaderboard functions
|
319 |
function getLeaderboard() {
|
320 |
const leaderboard = JSON.parse(localStorage.getItem('tetrisLeaderboard') || '[]');
|
321 |
return leaderboard;
|
322 |
}
|
|
|
323 |
function updateLeaderboardDisplay() {
|
324 |
const leaderboardElement = document.getElementById('leaderboard');
|
325 |
const leaderboard = getLeaderboard();
|
|
|
334 |
`)
|
335 |
.join('');
|
336 |
}
|
|
|
337 |
function addScore(name, score) {
|
338 |
const leaderboard = getLeaderboard();
|
339 |
leaderboard.push({ name, score });
|
|
|
341 |
localStorage.setItem('tetrisLeaderboard', JSON.stringify(leaderboard));
|
342 |
updateLeaderboardDisplay();
|
343 |
}
|
|
|
344 |
function submitScore() {
|
345 |
const playerName = document.getElementById('player-name').value.trim();
|
346 |
if (playerName) {
|
|
|
422 |
case 40: // Down
|
423 |
if(isValidMove(currentPiece, 0, 1)) {
|
424 |
currentPiece.y++;
|
425 |
+
score += 1;
|
426 |
document.getElementById('score').textContent = score;
|
427 |
drawBoard();
|
428 |
}
|
|
|
436 |
case 32: // Space (Hard Drop)
|
437 |
while(isValidMove(currentPiece, 0, 1)) {
|
438 |
currentPiece.y++;
|
439 |
+
score += 2;
|
440 |
}
|
441 |
document.getElementById('score').textContent = score;
|
442 |
update();
|
443 |
break;
|
444 |
}
|
445 |
});
|
446 |
+
// Initialize audio
|
447 |
+
const bgMusic = document.getElementById('bgMusic');
|
448 |
+
bgMusic.volume = 0.5; // λ³Όλ₯¨μ 50%λ‘ μ€μ
|
449 |
+
// μμ
μλ μ¬μ
|
450 |
+
function playBGM() {
|
451 |
+
bgMusic.play().catch(function(error) {
|
452 |
+
console.log("Audio play failed:", error);
|
453 |
+
});
|
454 |
+
}
|
455 |
+
// νμ΄μ§ λ‘λ μ μμ
μ¬μ μλ
|
456 |
+
document.addEventListener('DOMContentLoaded', function() {
|
457 |
+
playBGM();
|
458 |
+
});
|
459 |
+
// μ¬μ©μ μνΈμμ© μ μμ
μ¬μ (λΈλΌμ°μ μ μ±
μΌλ‘ μΈν λλΉμ±
)
|
460 |
+
document.addEventListener('click', function() {
|
461 |
+
playBGM();
|
462 |
+
}, { once: true });
|
463 |
// Initialize game
|
464 |
updateLeaderboardDisplay();
|
465 |
startGame();
|
466 |
</script>
|
467 |
</body>
|
468 |
+
</html>
|