Spaces:
Running
Running
Add 2 files
Browse files- index.html +86 -27
- prompts.txt +2 -1
index.html
CHANGED
|
@@ -39,6 +39,7 @@
|
|
| 39 |
.cell {
|
| 40 |
aspect-ratio: 1;
|
| 41 |
background-color: rgba(0, 0, 0, 0.1);
|
|
|
|
| 42 |
}
|
| 43 |
|
| 44 |
.gold {
|
|
@@ -52,6 +53,19 @@
|
|
| 52 |
}
|
| 53 |
|
| 54 |
.gold::after {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
content: '';
|
| 56 |
position: absolute;
|
| 57 |
top: 0;
|
|
@@ -73,6 +87,19 @@
|
|
| 73 |
}
|
| 74 |
|
| 75 |
.gold-light::after {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 76 |
content: '';
|
| 77 |
position: absolute;
|
| 78 |
top: 0;
|
|
@@ -115,12 +142,15 @@
|
|
| 115 |
border: 2px solid #d4af37;
|
| 116 |
}
|
| 117 |
|
| 118 |
-
/* Dark golden text */
|
| 119 |
.text-gold-dark {
|
| 120 |
color: #6a4a0a;
|
| 121 |
}
|
| 122 |
|
| 123 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 124 |
@media (max-width: 768px) {
|
| 125 |
.game-grid-container {
|
| 126 |
flex-direction: column;
|
|
@@ -133,14 +163,12 @@
|
|
| 133 |
}
|
| 134 |
}
|
| 135 |
|
| 136 |
-
/* Control panel container */
|
| 137 |
.control-panel {
|
| 138 |
max-height: calc(100vh - 60px);
|
| 139 |
padding-bottom: 60px;
|
| 140 |
overflow: hidden;
|
| 141 |
}
|
| 142 |
|
| 143 |
-
/* Ensure game area fits on screen */
|
| 144 |
.game-area {
|
| 145 |
max-height: 100vh;
|
| 146 |
padding-top: 20px;
|
|
@@ -163,6 +191,12 @@
|
|
| 163 |
Play Again
|
| 164 |
</button>
|
| 165 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 166 |
</div>
|
| 167 |
|
| 168 |
<div class="flex flex-col gap-2 sm:gap-4 w-full control-panel" style="max-width: 200px;">
|
|
@@ -238,6 +272,7 @@
|
|
| 238 |
let isPaused = false;
|
| 239 |
let dropInterval;
|
| 240 |
let dropSpeed = 1000; // Initial speed in ms
|
|
|
|
| 241 |
|
| 242 |
// DOM elements
|
| 243 |
const gridElement = document.getElementById('grid');
|
|
@@ -248,6 +283,8 @@
|
|
| 248 |
const gameOverElement = document.getElementById('game-over');
|
| 249 |
const finalScoreElement = document.getElementById('final-score');
|
| 250 |
const restartBtn = document.getElementById('restart-btn');
|
|
|
|
|
|
|
| 251 |
|
| 252 |
// Piece shapes (gold bars)
|
| 253 |
const SHAPES = [
|
|
@@ -309,13 +346,28 @@
|
|
| 309 |
// Initialize the game
|
| 310 |
function init() {
|
| 311 |
createGrid();
|
| 312 |
-
|
| 313 |
-
generateNextPiece();
|
| 314 |
updateScore();
|
| 315 |
-
startGame();
|
| 316 |
addEventListeners();
|
| 317 |
}
|
| 318 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 319 |
// Create the game grid
|
| 320 |
function createGrid() {
|
| 321 |
gridElement.innerHTML = '';
|
|
@@ -382,6 +434,19 @@
|
|
| 382 |
cell.style.backgroundColor = nextPiece.color;
|
| 383 |
cell.style.border = '1px solid #fff';
|
| 384 |
cell.style.boxShadow = 'inset 0 0 5px rgba(255, 255, 255, 0.5)';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 385 |
} else {
|
| 386 |
cell.style.backgroundColor = 'transparent';
|
| 387 |
}
|
|
@@ -449,7 +514,7 @@
|
|
| 449 |
|
| 450 |
// Rotate the current piece
|
| 451 |
function rotate() {
|
| 452 |
-
if (isPaused || gameOver) return;
|
| 453 |
|
| 454 |
const originalShape = currentPiece.shape;
|
| 455 |
const originalX = currentPiece.x;
|
|
@@ -483,7 +548,7 @@
|
|
| 483 |
|
| 484 |
// Move the piece left
|
| 485 |
function moveLeft() {
|
| 486 |
-
if (isPaused || gameOver) return;
|
| 487 |
|
| 488 |
currentPiece.x -= 1;
|
| 489 |
if (collision()) {
|
|
@@ -494,7 +559,7 @@
|
|
| 494 |
|
| 495 |
// Move the piece right
|
| 496 |
function moveRight() {
|
| 497 |
-
if (isPaused || gameOver) return;
|
| 498 |
|
| 499 |
currentPiece.x += 1;
|
| 500 |
if (collision()) {
|
|
@@ -505,7 +570,7 @@
|
|
| 505 |
|
| 506 |
// Move the piece down
|
| 507 |
function moveDown() {
|
| 508 |
-
if (isPaused || gameOver) return;
|
| 509 |
|
| 510 |
currentPiece.y += 1;
|
| 511 |
|
|
@@ -519,7 +584,7 @@
|
|
| 519 |
|
| 520 |
// Hard drop - instantly drop the piece
|
| 521 |
function hardDrop() {
|
| 522 |
-
if (isPaused || gameOver) return;
|
| 523 |
|
| 524 |
while (!collision()) {
|
| 525 |
currentPiece.y += 1;
|
|
@@ -613,22 +678,10 @@
|
|
| 613 |
linesElement.textContent = lines;
|
| 614 |
}
|
| 615 |
|
| 616 |
-
// Start the game
|
| 617 |
-
function startGame() {
|
| 618 |
-
gameOver = false;
|
| 619 |
-
score = 0;
|
| 620 |
-
level = 1;
|
| 621 |
-
lines = 0;
|
| 622 |
-
grid = Array(ROWS).fill().map(() => Array(COLS).fill(0));
|
| 623 |
-
updateScore();
|
| 624 |
-
renderGrid();
|
| 625 |
-
resetDropInterval();
|
| 626 |
-
gameOverElement.classList.add('hidden');
|
| 627 |
-
}
|
| 628 |
-
|
| 629 |
// End the game
|
| 630 |
function endGame() {
|
| 631 |
gameOver = true;
|
|
|
|
| 632 |
clearInterval(dropInterval);
|
| 633 |
finalScoreElement.textContent = score;
|
| 634 |
gameOverElement.classList.remove('hidden');
|
|
@@ -644,7 +697,7 @@
|
|
| 644 |
|
| 645 |
// Toggle pause
|
| 646 |
function togglePause() {
|
| 647 |
-
if (gameOver) return;
|
| 648 |
|
| 649 |
isPaused = !isPaused;
|
| 650 |
|
|
@@ -658,6 +711,11 @@
|
|
| 658 |
// Add event listeners
|
| 659 |
function addEventListeners() {
|
| 660 |
document.addEventListener('keydown', (e) => {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 661 |
if (gameOver && e.key === 'Enter') {
|
| 662 |
startGame();
|
| 663 |
return;
|
|
@@ -687,9 +745,10 @@
|
|
| 687 |
});
|
| 688 |
|
| 689 |
restartBtn.addEventListener('click', startGame);
|
|
|
|
| 690 |
}
|
| 691 |
|
| 692 |
-
//
|
| 693 |
init();
|
| 694 |
});
|
| 695 |
</script>
|
|
|
|
| 39 |
.cell {
|
| 40 |
aspect-ratio: 1;
|
| 41 |
background-color: rgba(0, 0, 0, 0.1);
|
| 42 |
+
position: relative;
|
| 43 |
}
|
| 44 |
|
| 45 |
.gold {
|
|
|
|
| 53 |
}
|
| 54 |
|
| 55 |
.gold::after {
|
| 56 |
+
content: '$';
|
| 57 |
+
position: absolute;
|
| 58 |
+
top: 50%;
|
| 59 |
+
left: 50%;
|
| 60 |
+
transform: translate(-50%, -50%);
|
| 61 |
+
font-size: 1.2em;
|
| 62 |
+
font-weight: bold;
|
| 63 |
+
color: #6a4a0a;
|
| 64 |
+
opacity: 0.7;
|
| 65 |
+
text-shadow: 1px 1px 1px rgba(0,0,0,0.3);
|
| 66 |
+
}
|
| 67 |
+
|
| 68 |
+
.gold::before {
|
| 69 |
content: '';
|
| 70 |
position: absolute;
|
| 71 |
top: 0;
|
|
|
|
| 87 |
}
|
| 88 |
|
| 89 |
.gold-light::after {
|
| 90 |
+
content: '$';
|
| 91 |
+
position: absolute;
|
| 92 |
+
top: 50%;
|
| 93 |
+
left: 50%;
|
| 94 |
+
transform: translate(-50%, -50%);
|
| 95 |
+
font-size: 1.2em;
|
| 96 |
+
font-weight: bold;
|
| 97 |
+
color: #6a4a0a;
|
| 98 |
+
opacity: 0.7;
|
| 99 |
+
text-shadow: 1px 1px 1px rgba(0,0,0,0.3);
|
| 100 |
+
}
|
| 101 |
+
|
| 102 |
+
.gold-light::before {
|
| 103 |
content: '';
|
| 104 |
position: absolute;
|
| 105 |
top: 0;
|
|
|
|
| 142 |
border: 2px solid #d4af37;
|
| 143 |
}
|
| 144 |
|
|
|
|
| 145 |
.text-gold-dark {
|
| 146 |
color: #6a4a0a;
|
| 147 |
}
|
| 148 |
|
| 149 |
+
.start-screen {
|
| 150 |
+
background-color: rgba(0, 0, 0, 0.8);
|
| 151 |
+
backdrop-filter: blur(5px);
|
| 152 |
+
}
|
| 153 |
+
|
| 154 |
@media (max-width: 768px) {
|
| 155 |
.game-grid-container {
|
| 156 |
flex-direction: column;
|
|
|
|
| 163 |
}
|
| 164 |
}
|
| 165 |
|
|
|
|
| 166 |
.control-panel {
|
| 167 |
max-height: calc(100vh - 60px);
|
| 168 |
padding-bottom: 60px;
|
| 169 |
overflow: hidden;
|
| 170 |
}
|
| 171 |
|
|
|
|
| 172 |
.game-area {
|
| 173 |
max-height: 100vh;
|
| 174 |
padding-top: 20px;
|
|
|
|
| 191 |
Play Again
|
| 192 |
</button>
|
| 193 |
</div>
|
| 194 |
+
<div id="start-screen" class="start-screen absolute inset-0 flex flex-col items-center justify-center text-gold-dark">
|
| 195 |
+
<h3 class="text-2xl sm:text-3xl font-bold mb-6">TONS OF GOLD</h3>
|
| 196 |
+
<button id="start-btn" class="controls-btn px-8 py-3 rounded-full text-white font-bold text-lg">
|
| 197 |
+
START GAME
|
| 198 |
+
</button>
|
| 199 |
+
</div>
|
| 200 |
</div>
|
| 201 |
|
| 202 |
<div class="flex flex-col gap-2 sm:gap-4 w-full control-panel" style="max-width: 200px;">
|
|
|
|
| 272 |
let isPaused = false;
|
| 273 |
let dropInterval;
|
| 274 |
let dropSpeed = 1000; // Initial speed in ms
|
| 275 |
+
let gameStarted = false;
|
| 276 |
|
| 277 |
// DOM elements
|
| 278 |
const gridElement = document.getElementById('grid');
|
|
|
|
| 283 |
const gameOverElement = document.getElementById('game-over');
|
| 284 |
const finalScoreElement = document.getElementById('final-score');
|
| 285 |
const restartBtn = document.getElementById('restart-btn');
|
| 286 |
+
const startBtn = document.getElementById('start-btn');
|
| 287 |
+
const startScreen = document.getElementById('start-screen');
|
| 288 |
|
| 289 |
// Piece shapes (gold bars)
|
| 290 |
const SHAPES = [
|
|
|
|
| 346 |
// Initialize the game
|
| 347 |
function init() {
|
| 348 |
createGrid();
|
| 349 |
+
renderGrid();
|
|
|
|
| 350 |
updateScore();
|
|
|
|
| 351 |
addEventListeners();
|
| 352 |
}
|
| 353 |
|
| 354 |
+
// Start the game
|
| 355 |
+
function startGame() {
|
| 356 |
+
gameStarted = true;
|
| 357 |
+
gameOver = false;
|
| 358 |
+
score = 0;
|
| 359 |
+
level = 1;
|
| 360 |
+
lines = 0;
|
| 361 |
+
grid = Array(ROWS).fill().map(() => Array(COLS).fill(0));
|
| 362 |
+
updateScore();
|
| 363 |
+
renderGrid();
|
| 364 |
+
generateNewPiece();
|
| 365 |
+
generateNextPiece();
|
| 366 |
+
resetDropInterval();
|
| 367 |
+
startScreen.classList.add('hidden');
|
| 368 |
+
gameOverElement.classList.add('hidden');
|
| 369 |
+
}
|
| 370 |
+
|
| 371 |
// Create the game grid
|
| 372 |
function createGrid() {
|
| 373 |
gridElement.innerHTML = '';
|
|
|
|
| 434 |
cell.style.backgroundColor = nextPiece.color;
|
| 435 |
cell.style.border = '1px solid #fff';
|
| 436 |
cell.style.boxShadow = 'inset 0 0 5px rgba(255, 255, 255, 0.5)';
|
| 437 |
+
|
| 438 |
+
// Add dollar sign to preview pieces
|
| 439 |
+
const dollarSign = document.createElement('div');
|
| 440 |
+
dollarSign.textContent = '$';
|
| 441 |
+
dollarSign.style.position = 'absolute';
|
| 442 |
+
dollarSign.style.top = '50%';
|
| 443 |
+
dollarSign.style.left = '50%';
|
| 444 |
+
dollarSign.style.transform = 'translate(-50%, -50%)';
|
| 445 |
+
dollarSign.style.color = '#6a4a0a';
|
| 446 |
+
dollarSign.style.opacity = '0.7';
|
| 447 |
+
dollarSign.style.fontWeight = 'bold';
|
| 448 |
+
dollarSign.style.textShadow = '1px 1px 1px rgba(0,0,0,0.3)';
|
| 449 |
+
cell.appendChild(dollarSign);
|
| 450 |
} else {
|
| 451 |
cell.style.backgroundColor = 'transparent';
|
| 452 |
}
|
|
|
|
| 514 |
|
| 515 |
// Rotate the current piece
|
| 516 |
function rotate() {
|
| 517 |
+
if (isPaused || gameOver || !gameStarted) return;
|
| 518 |
|
| 519 |
const originalShape = currentPiece.shape;
|
| 520 |
const originalX = currentPiece.x;
|
|
|
|
| 548 |
|
| 549 |
// Move the piece left
|
| 550 |
function moveLeft() {
|
| 551 |
+
if (isPaused || gameOver || !gameStarted) return;
|
| 552 |
|
| 553 |
currentPiece.x -= 1;
|
| 554 |
if (collision()) {
|
|
|
|
| 559 |
|
| 560 |
// Move the piece right
|
| 561 |
function moveRight() {
|
| 562 |
+
if (isPaused || gameOver || !gameStarted) return;
|
| 563 |
|
| 564 |
currentPiece.x += 1;
|
| 565 |
if (collision()) {
|
|
|
|
| 570 |
|
| 571 |
// Move the piece down
|
| 572 |
function moveDown() {
|
| 573 |
+
if (isPaused || gameOver || !gameStarted) return;
|
| 574 |
|
| 575 |
currentPiece.y += 1;
|
| 576 |
|
|
|
|
| 584 |
|
| 585 |
// Hard drop - instantly drop the piece
|
| 586 |
function hardDrop() {
|
| 587 |
+
if (isPaused || gameOver || !gameStarted) return;
|
| 588 |
|
| 589 |
while (!collision()) {
|
| 590 |
currentPiece.y += 1;
|
|
|
|
| 678 |
linesElement.textContent = lines;
|
| 679 |
}
|
| 680 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 681 |
// End the game
|
| 682 |
function endGame() {
|
| 683 |
gameOver = true;
|
| 684 |
+
gameStarted = false;
|
| 685 |
clearInterval(dropInterval);
|
| 686 |
finalScoreElement.textContent = score;
|
| 687 |
gameOverElement.classList.remove('hidden');
|
|
|
|
| 697 |
|
| 698 |
// Toggle pause
|
| 699 |
function togglePause() {
|
| 700 |
+
if (gameOver || !gameStarted) return;
|
| 701 |
|
| 702 |
isPaused = !isPaused;
|
| 703 |
|
|
|
|
| 711 |
// Add event listeners
|
| 712 |
function addEventListeners() {
|
| 713 |
document.addEventListener('keydown', (e) => {
|
| 714 |
+
if (!gameStarted && e.key === 'Enter') {
|
| 715 |
+
startGame();
|
| 716 |
+
return;
|
| 717 |
+
}
|
| 718 |
+
|
| 719 |
if (gameOver && e.key === 'Enter') {
|
| 720 |
startGame();
|
| 721 |
return;
|
|
|
|
| 745 |
});
|
| 746 |
|
| 747 |
restartBtn.addEventListener('click', startGame);
|
| 748 |
+
startBtn.addEventListener('click', startGame);
|
| 749 |
}
|
| 750 |
|
| 751 |
+
// Initialize the game
|
| 752 |
init();
|
| 753 |
});
|
| 754 |
</script>
|
prompts.txt
CHANGED
|
@@ -1,4 +1,5 @@
|
|
| 1 |
make a Tetris-like game, where the blocks are gold bars. allow keyboard controls, and use a golden color scheme throughout. The game is called Tons of Gold: Stacking Bricks
|
| 2 |
the main game screen is cutoff at the bottom, I can only see half the area, please fix
|
| 3 |
make the game's dimensions responsive, so that no matter the device or screen size that all of the elements are visible without scrolling. also make sure the blocks look like gold bars. make the text dark golden instead of white so its more readable.
|
| 4 |
-
the right column with the controls and stuff is still not aligned properly, it starts above the top of the screen, please fix, also use a condensed font for the title in all caps. make the dark golden text darker. there seems to be an issue with the sizing on the control area, it extends to the bottom of the page, it should only have padding of 60px after the pause button.
|
|
|
|
|
|
| 1 |
make a Tetris-like game, where the blocks are gold bars. allow keyboard controls, and use a golden color scheme throughout. The game is called Tons of Gold: Stacking Bricks
|
| 2 |
the main game screen is cutoff at the bottom, I can only see half the area, please fix
|
| 3 |
make the game's dimensions responsive, so that no matter the device or screen size that all of the elements are visible without scrolling. also make sure the blocks look like gold bars. make the text dark golden instead of white so its more readable.
|
| 4 |
+
the right column with the controls and stuff is still not aligned properly, it starts above the top of the screen, please fix, also use a condensed font for the title in all caps. make the dark golden text darker. there seems to be an issue with the sizing on the control area, it extends to the bottom of the page, it should only have padding of 60px after the pause button.
|
| 5 |
+
make the gold bricks have little dark gold dollar signs on them, also make a start button so it doesn't start automatically upon load
|