Spaces:
Running
Running
Add 2 files
Browse files- index.html +642 -38
- prompts.txt +2 -0
index.html
CHANGED
|
@@ -1,41 +1,645 @@
|
|
| 1 |
<!DOCTYPE html>
|
| 2 |
-
<html>
|
| 3 |
-
|
| 4 |
-
<
|
| 5 |
-
<meta name="viewport" content="width=device-width, initial-scale=1.0"
|
| 6 |
-
<
|
|
|
|
| 7 |
<style>
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
</style>
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
<h1>
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
<!DOCTYPE html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>Tons of Gold: Stacking Bricks</title>
|
| 7 |
+
<script src="https://cdn.tailwindcss.com"></script>
|
| 8 |
<style>
|
| 9 |
+
@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@700&family=Poppins:wght@400;600&display=swap');
|
| 10 |
+
|
| 11 |
+
body {
|
| 12 |
+
font-family: 'Poppins', sans-serif;
|
| 13 |
+
background: linear-gradient(135deg, #f5d742 0%, #d4af37 50%, #996515 100%);
|
| 14 |
+
min-height: 100vh;
|
| 15 |
+
}
|
| 16 |
+
|
| 17 |
+
.title {
|
| 18 |
+
font-family: 'Playfair Display', serif;
|
| 19 |
+
text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
|
| 20 |
+
}
|
| 21 |
+
|
| 22 |
+
.game-container {
|
| 23 |
+
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
|
| 24 |
+
border: 4px solid #d4af37;
|
| 25 |
+
background-color: rgba(0, 0, 0, 0.7);
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
.grid {
|
| 29 |
+
display: grid;
|
| 30 |
+
grid-template-rows: repeat(20, 1fr);
|
| 31 |
+
grid-template-columns: repeat(10, 1fr);
|
| 32 |
+
gap: 1px;
|
| 33 |
+
border: 2px solid #d4af37;
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
.cell {
|
| 37 |
+
aspect-ratio: 1;
|
| 38 |
+
background-color: rgba(0, 0, 0, 0.1);
|
| 39 |
+
}
|
| 40 |
+
|
| 41 |
+
.gold {
|
| 42 |
+
background: linear-gradient(135deg, #ffd700 0%, #daa520 50%, #b8860b 100%);
|
| 43 |
+
border: 1px solid #fff;
|
| 44 |
+
box-shadow: inset 0 0 10px rgba(255, 215, 0, 0.5);
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
.gold-light {
|
| 48 |
+
background: linear-gradient(135deg, #fff8c6 0%, #ffd700 50%, #daa520 100%);
|
| 49 |
+
border: 1px solid #fff;
|
| 50 |
+
box-shadow: inset 0 0 10px rgba(255, 215, 0, 0.8);
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
.next-piece-container {
|
| 54 |
+
border: 2px solid #d4af37;
|
| 55 |
+
background-color: rgba(0, 0, 0, 0.3);
|
| 56 |
+
}
|
| 57 |
+
|
| 58 |
+
.controls-btn {
|
| 59 |
+
background: linear-gradient(135deg, #d4af37 0%, #b8860b 100%);
|
| 60 |
+
border: none;
|
| 61 |
+
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
|
| 62 |
+
transition: all 0.2s;
|
| 63 |
+
}
|
| 64 |
+
|
| 65 |
+
.controls-btn:hover {
|
| 66 |
+
transform: translateY(-2px);
|
| 67 |
+
box-shadow: 0 6px 8px rgba(0, 0, 0, 0.2);
|
| 68 |
+
}
|
| 69 |
+
|
| 70 |
+
.controls-btn:active {
|
| 71 |
+
transform: translateY(0);
|
| 72 |
+
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
| 73 |
+
}
|
| 74 |
+
|
| 75 |
+
.game-over {
|
| 76 |
+
background-color: rgba(0, 0, 0, 0.8);
|
| 77 |
+
backdrop-filter: blur(5px);
|
| 78 |
+
}
|
| 79 |
+
|
| 80 |
+
.score-display {
|
| 81 |
+
background: linear-gradient(135deg, rgba(212, 175, 55, 0.2) 0%, rgba(184, 134, 11, 0.3) 100%);
|
| 82 |
+
border: 2px solid #d4af37;
|
| 83 |
+
}
|
| 84 |
+
|
| 85 |
+
/* Responsive adjustments */
|
| 86 |
+
@media (max-width: 768px) {
|
| 87 |
+
.game-grid-container {
|
| 88 |
+
flex-direction: column;
|
| 89 |
+
}
|
| 90 |
+
.game-container {
|
| 91 |
+
margin-bottom: 1rem;
|
| 92 |
+
}
|
| 93 |
+
.controls-container {
|
| 94 |
+
width: 100%;
|
| 95 |
+
}
|
| 96 |
+
}
|
| 97 |
</style>
|
| 98 |
+
</head>
|
| 99 |
+
<body class="flex flex-col items-center justify-start py-4 px-2 overflow-x-hidden">
|
| 100 |
+
<h1 class="title text-4xl sm:text-5xl md:text-6xl font-bold mb-2 sm:mb-4 text-yellow-200">Tons of Gold</h1>
|
| 101 |
+
<h2 class="text-xl sm:text-2xl font-semibold mb-4 sm:mb-6 text-yellow-300">Stacking Bricks</h2>
|
| 102 |
+
|
| 103 |
+
<div class="flex flex-col lg:flex-row items-center justify-center gap-4 sm:gap-6 md:gap-8 w-full max-w-6xl px-2">
|
| 104 |
+
<div class="game-container relative">
|
| 105 |
+
<div id="grid" class="grid w-[250px] h-[500px] sm:w-[300px] sm:h-[600px]"></div>
|
| 106 |
+
<div id="game-over" class="game-over absolute inset-0 hidden flex-col items-center justify-center text-white">
|
| 107 |
+
<h3 class="text-2xl sm:text-3xl font-bold mb-4 text-yellow-300">Game Over!</h3>
|
| 108 |
+
<p class="text-lg sm:text-xl mb-6">Your score: <span id="final-score" class="font-bold text-yellow-300">0</span></p>
|
| 109 |
+
<button id="restart-btn" class="controls-btn px-6 py-2 rounded-full text-white font-bold">
|
| 110 |
+
Play Again
|
| 111 |
+
</button>
|
| 112 |
+
</div>
|
| 113 |
+
</div>
|
| 114 |
+
|
| 115 |
+
<div class="flex flex-col gap-4 sm:gap-6 w-full max-w-xs">
|
| 116 |
+
<div class="score-display p-4 rounded-lg">
|
| 117 |
+
<div class="flex justify-between mb-2">
|
| 118 |
+
<span class="text-yellow-200 font-semibold">Score:</span>
|
| 119 |
+
<span id="score" class="text-white font-bold">0</span>
|
| 120 |
+
</div>
|
| 121 |
+
<div class="flex justify-between mb-2">
|
| 122 |
+
<span class="text-yellow-200 font-semibold">Level:</span>
|
| 123 |
+
<span id="level" class="text-white font-bold">1</span>
|
| 124 |
+
</div>
|
| 125 |
+
<div class="flex justify-between">
|
| 126 |
+
<span class="text-yellow-200 font-semibold">Lines:</span>
|
| 127 |
+
<span id="lines" class="text-white font-bold">0</span>
|
| 128 |
+
</div>
|
| 129 |
+
</div>
|
| 130 |
+
|
| 131 |
+
<div class="next-piece-container p-4 rounded-lg">
|
| 132 |
+
<h3 class="text-yellow-200 font-semibold mb-2 text-center">Next Piece</h3>
|
| 133 |
+
<div id="next-piece" class="grid grid-cols-4 grid-rows-4 w-24 h-24 gap-1 mx-auto"></div>
|
| 134 |
+
</div>
|
| 135 |
+
|
| 136 |
+
<div class="bg-black bg-opacity-30 p-4 rounded-lg">
|
| 137 |
+
<h3 class="text-yellow-200 font-semibold mb-3 text-center">Controls</h3>
|
| 138 |
+
<div class="grid grid-cols-3 gap-2 text-white text-sm">
|
| 139 |
+
<div class="text-center">
|
| 140 |
+
<div class="controls-btn w-10 h-10 mx-auto mb-1 flex items-center justify-center">↑</div>
|
| 141 |
+
<span>Rotate</span>
|
| 142 |
+
</div>
|
| 143 |
+
<div class="text-center">
|
| 144 |
+
<div class="controls-btn w-10 h-10 mx-auto mb-1 flex items-center justify-center">←</div>
|
| 145 |
+
<span>Left</span>
|
| 146 |
+
</div>
|
| 147 |
+
<div class="text-center">
|
| 148 |
+
<div class="controls-btn w-10 h-10 mx-auto mb-1 flex items-center justify-center">→</div>
|
| 149 |
+
<span>Right</span>
|
| 150 |
+
</div>
|
| 151 |
+
<div class="text-center col-span-3">
|
| 152 |
+
<div class="controls-btn w-full h-10 mx-auto mb-1 flex items-center justify-center">↓ (Drop Faster)</div>
|
| 153 |
+
</div>
|
| 154 |
+
<div class="text-center col-span-3">
|
| 155 |
+
<div class="controls-btn w-full h-10 mx-auto mb-1 flex items-center justify-center">Space (Instant Drop)</div>
|
| 156 |
+
</div>
|
| 157 |
+
<div class="text-center col-span-3">
|
| 158 |
+
<div class="controls-btn w-full h-10 mx-auto mb-1 flex items-center justify-center">P (Pause)</div>
|
| 159 |
+
</div>
|
| 160 |
+
</div>
|
| 161 |
+
</div>
|
| 162 |
+
</div>
|
| 163 |
+
</div>
|
| 164 |
+
|
| 165 |
+
<div class="mt-4 sm:mt-6 text-yellow-200 text-center px-2">
|
| 166 |
+
<p class="text-sm sm:text-base">Stack the gold bars to complete lines and earn points!</p>
|
| 167 |
+
<p class="text-xs sm:text-sm mt-1 text-yellow-300">Each line cleared increases your score and level.</p>
|
| 168 |
+
</div>
|
| 169 |
+
|
| 170 |
+
<script>
|
| 171 |
+
document.addEventListener('DOMContentLoaded', () => {
|
| 172 |
+
// Game constants
|
| 173 |
+
const COLS = 10;
|
| 174 |
+
const ROWS = 20;
|
| 175 |
+
const BLOCK_SIZE = 30;
|
| 176 |
+
const NEXT_PIECE_SIZE = 4;
|
| 177 |
+
|
| 178 |
+
// Game variables
|
| 179 |
+
let grid = Array(ROWS).fill().map(() => Array(COLS).fill(0));
|
| 180 |
+
let currentPiece = null;
|
| 181 |
+
let nextPiece = null;
|
| 182 |
+
let score = 0;
|
| 183 |
+
let level = 1;
|
| 184 |
+
let lines = 0;
|
| 185 |
+
let gameOver = false;
|
| 186 |
+
let isPaused = false;
|
| 187 |
+
let dropInterval;
|
| 188 |
+
let dropSpeed = 1000; // Initial speed in ms
|
| 189 |
+
|
| 190 |
+
// DOM elements
|
| 191 |
+
const gridElement = document.getElementById('grid');
|
| 192 |
+
const nextPieceElement = document.getElementById('next-piece');
|
| 193 |
+
const scoreElement = document.getElementById('score');
|
| 194 |
+
const levelElement = document.getElementById('level');
|
| 195 |
+
const linesElement = document.getElementById('lines');
|
| 196 |
+
const gameOverElement = document.getElementById('game-over');
|
| 197 |
+
const finalScoreElement = document.getElementById('final-score');
|
| 198 |
+
const restartBtn = document.getElementById('restart-btn');
|
| 199 |
+
|
| 200 |
+
// Piece shapes (gold bars)
|
| 201 |
+
const SHAPES = [
|
| 202 |
+
// I shape (long gold bar)
|
| 203 |
+
[
|
| 204 |
+
[0, 0, 0, 0],
|
| 205 |
+
[1, 1, 1, 1],
|
| 206 |
+
[0, 0, 0, 0],
|
| 207 |
+
[0, 0, 0, 0]
|
| 208 |
+
],
|
| 209 |
+
// J shape
|
| 210 |
+
[
|
| 211 |
+
[1, 0, 0],
|
| 212 |
+
[1, 1, 1],
|
| 213 |
+
[0, 0, 0]
|
| 214 |
+
],
|
| 215 |
+
// L shape
|
| 216 |
+
[
|
| 217 |
+
[0, 0, 1],
|
| 218 |
+
[1, 1, 1],
|
| 219 |
+
[0, 0, 0]
|
| 220 |
+
],
|
| 221 |
+
// O shape (gold cube)
|
| 222 |
+
[
|
| 223 |
+
[1, 1],
|
| 224 |
+
[1, 1]
|
| 225 |
+
],
|
| 226 |
+
// S shape
|
| 227 |
+
[
|
| 228 |
+
[0, 1, 1],
|
| 229 |
+
[1, 1, 0],
|
| 230 |
+
[0, 0, 0]
|
| 231 |
+
],
|
| 232 |
+
// T shape
|
| 233 |
+
[
|
| 234 |
+
[0, 1, 0],
|
| 235 |
+
[1, 1, 1],
|
| 236 |
+
[0, 0, 0]
|
| 237 |
+
],
|
| 238 |
+
// Z shape
|
| 239 |
+
[
|
| 240 |
+
[1, 1, 0],
|
| 241 |
+
[0, 1, 1],
|
| 242 |
+
[0, 0, 0]
|
| 243 |
+
]
|
| 244 |
+
];
|
| 245 |
+
|
| 246 |
+
// Colors for pieces (different shades of gold)
|
| 247 |
+
const COLORS = [
|
| 248 |
+
'#FFD700', // Gold
|
| 249 |
+
'#DAA520', // Goldenrod
|
| 250 |
+
'#F0E68C', // Khaki
|
| 251 |
+
'#EEE8AA', // Pale Goldenrod
|
| 252 |
+
'#B8860B', // Dark Goldenrod
|
| 253 |
+
'#FFDF00', // Golden Yellow
|
| 254 |
+
'#E6BE8A' // Gold (metallic)
|
| 255 |
+
];
|
| 256 |
+
|
| 257 |
+
// Initialize the game
|
| 258 |
+
function init() {
|
| 259 |
+
createGrid();
|
| 260 |
+
generateNewPiece();
|
| 261 |
+
generateNextPiece();
|
| 262 |
+
updateScore();
|
| 263 |
+
startGame();
|
| 264 |
+
addEventListeners();
|
| 265 |
+
}
|
| 266 |
+
|
| 267 |
+
// Create the game grid
|
| 268 |
+
function createGrid() {
|
| 269 |
+
gridElement.innerHTML = '';
|
| 270 |
+
|
| 271 |
+
for (let row = 0; row < ROWS; row++) {
|
| 272 |
+
for (let col = 0; col < COLS; col++) {
|
| 273 |
+
const cell = document.createElement('div');
|
| 274 |
+
cell.className = 'cell';
|
| 275 |
+
cell.id = `cell-${row}-${col}`;
|
| 276 |
+
gridElement.appendChild(cell);
|
| 277 |
+
}
|
| 278 |
+
}
|
| 279 |
+
}
|
| 280 |
+
|
| 281 |
+
// Generate a new random piece
|
| 282 |
+
function generateNewPiece() {
|
| 283 |
+
if (nextPiece) {
|
| 284 |
+
currentPiece = nextPiece;
|
| 285 |
+
} else {
|
| 286 |
+
const randomShapeIndex = Math.floor(Math.random() * SHAPES.length);
|
| 287 |
+
const randomColorIndex = Math.floor(Math.random() * COLORS.length);
|
| 288 |
+
|
| 289 |
+
currentPiece = {
|
| 290 |
+
shape: SHAPES[randomShapeIndex],
|
| 291 |
+
color: COLORS[randomColorIndex],
|
| 292 |
+
x: Math.floor(COLS / 2) - Math.floor(SHAPES[randomShapeIndex][0].length / 2),
|
| 293 |
+
y: 0
|
| 294 |
+
};
|
| 295 |
+
}
|
| 296 |
+
|
| 297 |
+
// Check if game over
|
| 298 |
+
if (collision()) {
|
| 299 |
+
endGame();
|
| 300 |
+
}
|
| 301 |
+
|
| 302 |
+
generateNextPiece();
|
| 303 |
+
}
|
| 304 |
+
|
| 305 |
+
// Generate the next piece to show in the preview
|
| 306 |
+
function generateNextPiece() {
|
| 307 |
+
const randomShapeIndex = Math.floor(Math.random() * SHAPES.length);
|
| 308 |
+
const randomColorIndex = Math.floor(Math.random() * COLORS.length);
|
| 309 |
+
|
| 310 |
+
nextPiece = {
|
| 311 |
+
shape: SHAPES[randomShapeIndex],
|
| 312 |
+
color: COLORS[randomColorIndex],
|
| 313 |
+
x: 0,
|
| 314 |
+
y: 0
|
| 315 |
+
};
|
| 316 |
+
|
| 317 |
+
renderNextPiece();
|
| 318 |
+
}
|
| 319 |
+
|
| 320 |
+
// Render the next piece preview
|
| 321 |
+
function renderNextPiece() {
|
| 322 |
+
nextPieceElement.innerHTML = '';
|
| 323 |
+
|
| 324 |
+
for (let row = 0; row < NEXT_PIECE_SIZE; row++) {
|
| 325 |
+
for (let col = 0; col < NEXT_PIECE_SIZE; col++) {
|
| 326 |
+
const cell = document.createElement('div');
|
| 327 |
+
cell.className = 'cell';
|
| 328 |
+
|
| 329 |
+
if (nextPiece.shape[row] && nextPiece.shape[row][col]) {
|
| 330 |
+
cell.style.backgroundColor = nextPiece.color;
|
| 331 |
+
cell.style.border = '1px solid #fff';
|
| 332 |
+
cell.style.boxShadow = 'inset 0 0 5px rgba(255, 255, 255, 0.5)';
|
| 333 |
+
} else {
|
| 334 |
+
cell.style.backgroundColor = 'transparent';
|
| 335 |
+
}
|
| 336 |
+
|
| 337 |
+
nextPieceElement.appendChild(cell);
|
| 338 |
+
}
|
| 339 |
+
}
|
| 340 |
+
}
|
| 341 |
+
|
| 342 |
+
// Draw the current piece on the grid
|
| 343 |
+
function drawPiece() {
|
| 344 |
+
clearPiece();
|
| 345 |
+
|
| 346 |
+
for (let row = 0; row < currentPiece.shape.length; row++) {
|
| 347 |
+
for (let col = 0; col < currentPiece.shape[row].length; col++) {
|
| 348 |
+
if (currentPiece.shape[row][col]) {
|
| 349 |
+
const gridRow = currentPiece.y + row;
|
| 350 |
+
const gridCol = currentPiece.x + col;
|
| 351 |
+
|
| 352 |
+
if (gridRow >= 0 && gridRow < ROWS && gridCol >= 0 && gridCol < COLS) {
|
| 353 |
+
const cell = document.getElementById(`cell-${gridRow}-${gridCol}`);
|
| 354 |
+
cell.classList.add('gold');
|
| 355 |
+
cell.style.backgroundColor = currentPiece.color;
|
| 356 |
+
}
|
| 357 |
+
}
|
| 358 |
+
}
|
| 359 |
+
}
|
| 360 |
+
}
|
| 361 |
+
|
| 362 |
+
// Clear the current piece from the grid
|
| 363 |
+
function clearPiece() {
|
| 364 |
+
for (let row = 0; row < ROWS; row++) {
|
| 365 |
+
for (let col = 0; col < COLS; col++) {
|
| 366 |
+
const cell = document.getElementById(`cell-${row}-${col}`);
|
| 367 |
+
if (cell.classList.contains('gold')) {
|
| 368 |
+
cell.classList.remove('gold');
|
| 369 |
+
cell.style.backgroundColor = '';
|
| 370 |
+
}
|
| 371 |
+
}
|
| 372 |
+
}
|
| 373 |
+
}
|
| 374 |
+
|
| 375 |
+
// Check for collisions
|
| 376 |
+
function collision() {
|
| 377 |
+
for (let row = 0; row < currentPiece.shape.length; row++) {
|
| 378 |
+
for (let col = 0; col < currentPiece.shape[row].length; col++) {
|
| 379 |
+
if (currentPiece.shape[row][col]) {
|
| 380 |
+
const gridRow = currentPiece.y + row;
|
| 381 |
+
const gridCol = currentPiece.x + col;
|
| 382 |
+
|
| 383 |
+
// Check boundaries and other pieces
|
| 384 |
+
if (
|
| 385 |
+
gridRow >= ROWS ||
|
| 386 |
+
gridCol < 0 ||
|
| 387 |
+
gridCol >= COLS ||
|
| 388 |
+
(gridRow >= 0 && grid[gridRow][gridCol])
|
| 389 |
+
) {
|
| 390 |
+
return true;
|
| 391 |
+
}
|
| 392 |
+
}
|
| 393 |
+
}
|
| 394 |
+
}
|
| 395 |
+
return false;
|
| 396 |
+
}
|
| 397 |
+
|
| 398 |
+
// Rotate the current piece
|
| 399 |
+
function rotate() {
|
| 400 |
+
if (isPaused || gameOver) return;
|
| 401 |
+
|
| 402 |
+
const originalShape = currentPiece.shape;
|
| 403 |
+
const originalX = currentPiece.x;
|
| 404 |
+
const originalY = currentPiece.y;
|
| 405 |
+
|
| 406 |
+
// Transpose and reverse rows to rotate
|
| 407 |
+
const rotated = currentPiece.shape[0].map((_, i) =>
|
| 408 |
+
currentPiece.shape.map(row => row[i]).reverse()
|
| 409 |
+
);
|
| 410 |
+
|
| 411 |
+
currentPiece.shape = rotated;
|
| 412 |
+
|
| 413 |
+
// If rotation causes collision, try wall kicks
|
| 414 |
+
if (collision()) {
|
| 415 |
+
// Try moving left
|
| 416 |
+
currentPiece.x -= 1;
|
| 417 |
+
if (collision()) {
|
| 418 |
+
// Try moving right
|
| 419 |
+
currentPiece.x += 2;
|
| 420 |
+
if (collision()) {
|
| 421 |
+
// Revert to original position if all kicks fail
|
| 422 |
+
currentPiece.x = originalX;
|
| 423 |
+
currentPiece.shape = originalShape;
|
| 424 |
+
return;
|
| 425 |
+
}
|
| 426 |
+
}
|
| 427 |
+
}
|
| 428 |
+
|
| 429 |
+
drawPiece();
|
| 430 |
+
}
|
| 431 |
+
|
| 432 |
+
// Move the piece left
|
| 433 |
+
function moveLeft() {
|
| 434 |
+
if (isPaused || gameOver) return;
|
| 435 |
+
|
| 436 |
+
currentPiece.x -= 1;
|
| 437 |
+
if (collision()) {
|
| 438 |
+
currentPiece.x += 1;
|
| 439 |
+
}
|
| 440 |
+
drawPiece();
|
| 441 |
+
}
|
| 442 |
+
|
| 443 |
+
// Move the piece right
|
| 444 |
+
function moveRight() {
|
| 445 |
+
if (isPaused || gameOver) return;
|
| 446 |
+
|
| 447 |
+
currentPiece.x += 1;
|
| 448 |
+
if (collision()) {
|
| 449 |
+
currentPiece.x -= 1;
|
| 450 |
+
}
|
| 451 |
+
drawPiece();
|
| 452 |
+
}
|
| 453 |
+
|
| 454 |
+
// Move the piece down
|
| 455 |
+
function moveDown() {
|
| 456 |
+
if (isPaused || gameOver) return;
|
| 457 |
+
|
| 458 |
+
currentPiece.y += 1;
|
| 459 |
+
|
| 460 |
+
if (collision()) {
|
| 461 |
+
currentPiece.y -= 1;
|
| 462 |
+
lockPiece();
|
| 463 |
+
}
|
| 464 |
+
|
| 465 |
+
drawPiece();
|
| 466 |
+
}
|
| 467 |
+
|
| 468 |
+
// Hard drop - instantly drop the piece
|
| 469 |
+
function hardDrop() {
|
| 470 |
+
if (isPaused || gameOver) return;
|
| 471 |
+
|
| 472 |
+
while (!collision()) {
|
| 473 |
+
currentPiece.y += 1;
|
| 474 |
+
}
|
| 475 |
+
|
| 476 |
+
currentPiece.y -= 1;
|
| 477 |
+
lockPiece();
|
| 478 |
+
drawPiece();
|
| 479 |
+
}
|
| 480 |
+
|
| 481 |
+
// Lock the piece in place and check for completed lines
|
| 482 |
+
function lockPiece() {
|
| 483 |
+
// Add piece to the grid
|
| 484 |
+
for (let row = 0; row < currentPiece.shape.length; row++) {
|
| 485 |
+
for (let col = 0; col < currentPiece.shape[row].length; col++) {
|
| 486 |
+
if (currentPiece.shape[row][col]) {
|
| 487 |
+
const gridRow = currentPiece.y + row;
|
| 488 |
+
const gridCol = currentPiece.x + col;
|
| 489 |
+
|
| 490 |
+
if (gridRow >= 0) {
|
| 491 |
+
grid[gridRow][gridCol] = 1;
|
| 492 |
+
const cell = document.getElementById(`cell-${gridRow}-${gridCol}`);
|
| 493 |
+
cell.classList.remove('gold');
|
| 494 |
+
cell.classList.add('gold-light');
|
| 495 |
+
cell.style.backgroundColor = currentPiece.color;
|
| 496 |
+
}
|
| 497 |
+
}
|
| 498 |
+
}
|
| 499 |
+
}
|
| 500 |
+
|
| 501 |
+
// Check for completed lines
|
| 502 |
+
checkLines();
|
| 503 |
+
|
| 504 |
+
// Generate new piece
|
| 505 |
+
generateNewPiece();
|
| 506 |
+
}
|
| 507 |
+
|
| 508 |
+
// Check for completed lines and clear them
|
| 509 |
+
function checkLines() {
|
| 510 |
+
let linesCleared = 0;
|
| 511 |
+
|
| 512 |
+
for (let row = ROWS - 1; row >= 0; row--) {
|
| 513 |
+
if (grid[row].every(cell => cell === 1)) {
|
| 514 |
+
// Remove the line
|
| 515 |
+
grid.splice(row, 1);
|
| 516 |
+
// Add new empty line at the top
|
| 517 |
+
grid.unshift(Array(COLS).fill(0));
|
| 518 |
+
linesCleared++;
|
| 519 |
+
row++; // Check the same row again after shifting
|
| 520 |
+
}
|
| 521 |
+
}
|
| 522 |
+
|
| 523 |
+
if (linesCleared > 0) {
|
| 524 |
+
// Update score based on lines cleared
|
| 525 |
+
const points = [0, 40, 100, 300, 1200][linesCleared] * level;
|
| 526 |
+
score += points;
|
| 527 |
+
lines += linesCleared;
|
| 528 |
+
|
| 529 |
+
// Level up every 10 lines
|
| 530 |
+
level = Math.floor(lines / 10) + 1;
|
| 531 |
+
|
| 532 |
+
// Increase speed
|
| 533 |
+
dropSpeed = Math.max(100, 1000 - (level - 1) * 100);
|
| 534 |
+
resetDropInterval();
|
| 535 |
+
|
| 536 |
+
updateScore();
|
| 537 |
+
renderGrid();
|
| 538 |
+
}
|
| 539 |
+
}
|
| 540 |
+
|
| 541 |
+
// Render the entire grid
|
| 542 |
+
function renderGrid() {
|
| 543 |
+
for (let row = 0; row < ROWS; row++) {
|
| 544 |
+
for (let col = 0; col < COLS; col++) {
|
| 545 |
+
const cell = document.getElementById(`cell-${row}-${col}`);
|
| 546 |
+
|
| 547 |
+
if (grid[row][col]) {
|
| 548 |
+
cell.classList.add('gold-light');
|
| 549 |
+
} else {
|
| 550 |
+
cell.classList.remove('gold-light');
|
| 551 |
+
cell.style.backgroundColor = '';
|
| 552 |
+
}
|
| 553 |
+
}
|
| 554 |
+
}
|
| 555 |
+
}
|
| 556 |
+
|
| 557 |
+
// Update the score display
|
| 558 |
+
function updateScore() {
|
| 559 |
+
scoreElement.textContent = score;
|
| 560 |
+
levelElement.textContent = level;
|
| 561 |
+
linesElement.textContent = lines;
|
| 562 |
+
}
|
| 563 |
+
|
| 564 |
+
// Start the game
|
| 565 |
+
function startGame() {
|
| 566 |
+
gameOver = false;
|
| 567 |
+
score = 0;
|
| 568 |
+
level = 1;
|
| 569 |
+
lines = 0;
|
| 570 |
+
grid = Array(ROWS).fill().map(() => Array(COLS).fill(0));
|
| 571 |
+
updateScore();
|
| 572 |
+
renderGrid();
|
| 573 |
+
resetDropInterval();
|
| 574 |
+
gameOverElement.classList.add('hidden');
|
| 575 |
+
}
|
| 576 |
+
|
| 577 |
+
// End the game
|
| 578 |
+
function endGame() {
|
| 579 |
+
gameOver = true;
|
| 580 |
+
clearInterval(dropInterval);
|
| 581 |
+
finalScoreElement.textContent = score;
|
| 582 |
+
gameOverElement.classList.remove('hidden');
|
| 583 |
+
}
|
| 584 |
+
|
| 585 |
+
// Reset the drop interval with current speed
|
| 586 |
+
function resetDropInterval() {
|
| 587 |
+
if (dropInterval) {
|
| 588 |
+
clearInterval(dropInterval);
|
| 589 |
+
}
|
| 590 |
+
dropInterval = setInterval(moveDown, dropSpeed);
|
| 591 |
+
}
|
| 592 |
+
|
| 593 |
+
// Toggle pause
|
| 594 |
+
function togglePause() {
|
| 595 |
+
if (gameOver) return;
|
| 596 |
+
|
| 597 |
+
isPaused = !isPaused;
|
| 598 |
+
|
| 599 |
+
if (isPaused) {
|
| 600 |
+
clearInterval(dropInterval);
|
| 601 |
+
} else {
|
| 602 |
+
resetDropInterval();
|
| 603 |
+
}
|
| 604 |
+
}
|
| 605 |
+
|
| 606 |
+
// Add event listeners
|
| 607 |
+
function addEventListeners() {
|
| 608 |
+
document.addEventListener('keydown', (e) => {
|
| 609 |
+
if (gameOver && e.key === 'Enter') {
|
| 610 |
+
startGame();
|
| 611 |
+
return;
|
| 612 |
+
}
|
| 613 |
+
|
| 614 |
+
switch (e.key) {
|
| 615 |
+
case 'ArrowLeft':
|
| 616 |
+
moveLeft();
|
| 617 |
+
break;
|
| 618 |
+
case 'ArrowRight':
|
| 619 |
+
moveRight();
|
| 620 |
+
break;
|
| 621 |
+
case 'ArrowDown':
|
| 622 |
+
moveDown();
|
| 623 |
+
break;
|
| 624 |
+
case 'ArrowUp':
|
| 625 |
+
rotate();
|
| 626 |
+
break;
|
| 627 |
+
case ' ':
|
| 628 |
+
hardDrop();
|
| 629 |
+
break;
|
| 630 |
+
case 'p':
|
| 631 |
+
case 'P':
|
| 632 |
+
togglePause();
|
| 633 |
+
break;
|
| 634 |
+
}
|
| 635 |
+
});
|
| 636 |
+
|
| 637 |
+
restartBtn.addEventListener('click', startGame);
|
| 638 |
+
}
|
| 639 |
+
|
| 640 |
+
// Start the game
|
| 641 |
+
init();
|
| 642 |
+
});
|
| 643 |
+
</script>
|
| 644 |
+
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=Darrellthedesigner/test" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
|
| 645 |
+
</html>
|
prompts.txt
CHANGED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 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
|