Changes to tetrisscroll.scroll.pub

root
root
24 days ago
Initial commit
body.html
Changed around line 1
+
+

Tetris Scroll

+
+
+
+
+

Next Piece

+
+
+
+

Score

+

0

+
+
+
+
+
+

Game Over!

+
+
+
index.scroll
Changed around line 1
+ buildHtml
+ baseUrl https://tetrisscroll.scroll.pub
+ metaTags
+ editButton /edit.html
+ title Tetris Scroll - Classic Tetris Game
+ style.css
+ body.html
+ script.js
prompt.json
Changed around line 1
+ {
+ "id": "27654b5c-e5cd-4199-bf52-b2d5e7803577",
+ "object": "chat.completion",
+ "created": 1735387908,
+ "model": "deepseek-chat",
+ "choices": [
+ {
+ "index": 0,
+ "message": {
+ "role": "assistant",
+ "content": "---domain---\ntetrisscroll.scroll.pub\n---index.scroll---\nbuildHtml\nbaseUrl https://tetrisscroll.scroll.pub\nmetaTags\neditButton /edit.html\ntitle Tetris Scroll - Classic Tetris Game\nstyle.css\nbody.html\nscript.js\n---body.html---\n
\n

Tetris Scroll

\n
\n
\n
\n
\n

Next Piece

\n
\n
\n
\n

Score

\n

0

\n
\n \n
\n
\n
\n

Game Over!

\n \n
\n
\n---style.css---\n:root {\n --primary-color: #2c3e50;\n --secondary-color: #34495e;\n --accent-color: #e74c3c;\n --text-color: #ecf0f1;\n --grid-color: #7f8c8d;\n}\n\n* {\n margin: 0;\n padding: 0;\n box-sizing: border-box;\n}\n\nbody {\n font-family: 'Arial', sans-serif;\n background-color: var(--primary-color);\n color: var(--text-color);\n min-height: 100vh;\n display: flex;\n justify-content: center;\n align-items: center;\n padding: 1rem;\n}\n\nh1 {\n text-align: center;\n margin-bottom: 2rem;\n font-size: 2.5rem;\n color: var(--accent-color);\n}\n\n.game-container {\n display: flex;\n gap: 2rem;\n background-color: var(--secondary-color);\n padding: 2rem;\n border-radius: 1rem;\n box-shadow: 0 0 20px rgba(0, 0, 0, 0.3);\n}\n\n.grid, .mini-grid {\n display: grid;\n grid-template-columns: repeat(10, 1fr);\n grid-template-rows: repeat(20, 1fr);\n gap: 2px;\n background-color: var(--grid-color);\n}\n\n.grid {\n width: 300px;\n height: 600px;\n}\n\n.mini-grid {\n width: 100px;\n height: 100px;\n margin-top: 1rem;\n}\n\n.sidebar {\n display: flex;\n flex-direction: column;\n gap: 2rem;\n}\n\n.score-display {\n text-align: center;\n}\n\n.score {\n font-size: 2rem;\n font-weight: bold;\n}\n\nbutton {\n padding: 0.75rem 1.5rem;\n font-size: 1rem;\n background-color: var(--accent-color);\n color: var(--text-color);\n border: none;\n border-radius: 0.5rem;\n cursor: pointer;\n transition: background-color 0.3s ease;\n}\n\nbutton:hover {\n background-color: #c0392b;\n}\n\n.game-over {\n display: none;\n position: fixed;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n background-color: var(--secondary-color);\n padding: 2rem;\n border-radius: 1rem;\n text-align: center;\n box-shadow: 0 0 20px rgba(0, 0, 0, 0.3);\n}\n\n.game-over h2 {\n margin-bottom: 1rem;\n}\n\n@media (max-width: 768px) {\n .game-container {\n flex-direction: column;\n align-items: center;\n }\n\n .sidebar {\n width: 100%;\n align-items: center;\n }\n}\n---script.js---\nconst grid = document.querySelector('.grid');\nconst miniGrid = document.querySelector('.mini-grid');\nconst scoreDisplay = document.querySelector('.score');\nconst startButton = document.querySelector('.start-button');\nconst restartButton = document.querySelector('.restart-button');\nconst gameOver = document.querySelector('.game-over');\n\nconst width = 10;\nlet squares = Array.from(grid.querySelectorAll('div'));\nlet miniSquares = Array.from(miniGrid.querySelectorAll('div'));\nlet currentPosition = 4;\nlet currentRotation = 0;\nlet score = 0;\nlet timerId;\nlet nextRandom = 0;\n\nconst colors = ['#e74c3c', '#3498db', '#2ecc71', '#f1c40f', '#9b59b6', '#e67e22'];\n\nconst lTetromino = [\n [1, width+1, width*2+1, 2],\n [width, width+1, width+2, width*2+2],\n [1, width+1, width*2+1, width*2],\n [width, width*2, width*2+1, width*2+2]\n];\n\nconst zTetromino = [\n [0, width, width+1, width*2+1],\n [width+1, width+2, width*2, width*2+1],\n [0, width, width+1, width*2+1],\n [width+1, width+2, width*2, width*2+1]\n];\n\nconst tTetromino = [\n [1, width, width+1, width+2],\n [1, width+1, width+2, width*2+1],\n [width, width+1, width+2, width*2+1],\n [1, width, width+1, width*2+1]\n];\n\nconst oTetromino = [\n [0, 1, width, width+1],\n [0, 1, width, width+1],\n [0, 1, width, width+1],\n [0, 1, width, width+1]\n];\n\nconst iTetromino = [\n [1, width+1, width*2+1, width*3+1],\n [width, width+1, width+2, width+3],\n [1, width+1, width*2+1, width*3+1],\n [width, width+1, width+2, width+3]\n];\n\nconst theTetrominoes = [lTetromino, zTetromino, tTetromino, oTetromino, iTetromino];\n\nlet random = Math.floor(Math.random() * theTetrominoes.length);\nlet current = theTetrominoes[random][currentRotation];\n\nfunction draw() {\n current.forEach(index => {\n squares[currentPosition + index].classList.add('tetromino');\n squares[currentPosition + index].style.backgroundColor = colors[random];\n });\n}\n\nfunction undraw() {\n current.forEach(index => {\n squares[currentPosition + index].classList.remove('tetromino');\n squares[currentPosition + index].style.backgroundColor = '';\n });\n}\n\nfunction control(e) {\n if (e.keyCode === 37) {\n moveLeft();\n } else if (e.keyCode === 38) {\n rotate();\n } else if (e.keyCode === 39) {\n moveRight();\n } else if (e.keyCode === 40) {\n moveDown();\n }\n}\ndocument.addEventListener('keydown', control);\n\nfunction moveDown() {\n undraw();\n currentPosition += width;\n draw();\n freeze();\n}\n\nfunction freeze() {\n if (current.some(index => squares[currentPosition + index + width].classList.contains('taken'))) {\n current.forEach(index => squares[currentPosition + index].classList.add('taken'));\n random = nextRandom;\n nextRandom = Math.floor(Math.random() * theTetrominoes.length);\n current = theTetrominoes[random][currentRotation];\n currentPosition = 4;\n draw();\n displayShape();\n addScore();\n gameOverCheck();\n }\n}\n\nfunction moveLeft() {\n undraw();\n const isAtLeftEdge = current.some(index => (currentPosition + index) % width === 0);\n if (!isAtLeftEdge) currentPosition -= 1;\n if (current.some(index => squares[currentPosition + index].classList.contains('taken'))) {\n currentPosition += 1;\n }\n draw();\n}\n\nfunction moveRight() {\n undraw();\n const isAtRightEdge = current.some(index => (currentPosition + index) % width === width - 1);\n if (!isAtRightEdge) currentPosition += 1;\n if (current.some(index => squares[currentPosition + index].classList.contains('taken'))) {\n currentPosition -= 1;\n }\n draw();\n}\n\nfunction rotate() {\n undraw();\n currentRotation++;\n if (currentRotation === current.length) {\n currentRotation = 0;\n }\n current = theTetrominoes[random][currentRotation];\n draw();\n}\n\nfunction displayShape() {\n miniSquares.forEach(square => {\n square.classList.remove('tetromino');\n square.style.backgroundColor = '';\n });\n theTetrominoes[nextRandom][0].forEach(index => {\n miniSquares[index].classList.add('tetromino');\n miniSquares[index].style.backgroundColor = colors[nextRandom];\n });\n}\n\nfunction addScore() {\n for (let i = 0; i < 199; i += width) {\n const row = [i, i+1, i+2, i+3, i+4, i+5, i+6, i+7, i+8, i+9];\n if (row.every(index => squares[index].classList.contains('taken'))) {\n score += 10;\n scoreDisplay.innerHTML = score;\n row.forEach(index => {\n squares[index].classList.remove('taken');\n squares[index].classList.remove('tetromino');\n squares[index].style.backgroundColor = '';\n });\n const squaresRemoved = squares.splice(i, width);\n squares = squaresRemoved.concat(squares);\n squares.forEach(cell => grid.appendChild(cell));\n }\n }\n}\n\nfunction gameOverCheck() {\n if (current.some(index => squares[currentPosition + index].classList.contains('taken'))) {\n gameOver.style.display = 'flex';\n clearInterval(timerId);\n }\n}\n\nfunction startGame() {\n squares.forEach(square => {\n square.classList.remove('tetromino');\n square.style.backgroundColor = '';\n });\n score = 0;\n scoreDisplay.innerHTML = score;\n gameOver.style.display = 'none';\n timerId = setInterval(moveDown, 1000);\n nextRandom = Math.floor(Math.random() * theTetrominoes.length);\n current = theTetrominoes[random][currentRotation];\n currentPosition = 4;\n draw();\n displayShape();\n}\n\nstartButton.addEventListener('click', startGame);\nrestartButton.addEventListener('click', startGame);\n---end---"
+ },
+ "logprobs": null,
+ "finish_reason": "stop"
+ }
+ ],
+ "usage": {
+ "prompt_tokens": 240,
+ "completion_tokens": 2437,
+ "total_tokens": 2677,
+ "prompt_cache_hit_tokens": 0,
+ "prompt_cache_miss_tokens": 240
+ },
+ "system_fingerprint": "fp_f1afce2943"
+ }
readme.scroll
Changed around line 1
+ # tetrisscroll.scroll.pub
+ Website generated by DeepSeek from prompt: creat a tetris game
script.js
Changed around line 1
+ const grid = document.querySelector('.grid');
+ const miniGrid = document.querySelector('.mini-grid');
+ const scoreDisplay = document.querySelector('.score');
+ const startButton = document.querySelector('.start-button');
+ const restartButton = document.querySelector('.restart-button');
+ const gameOver = document.querySelector('.game-over');
+
+ const width = 10;
+ let squares = Array.from(grid.querySelectorAll('div'));
+ let miniSquares = Array.from(miniGrid.querySelectorAll('div'));
+ let currentPosition = 4;
+ let currentRotation = 0;
+ let score = 0;
+ let timerId;
+ let nextRandom = 0;
+
+ const colors = ['#e74c3c', '#3498db', '#2ecc71', '#f1c40f', '#9b59b6', '#e67e22'];
+
+ const lTetromino = [
+ [1, width+1, width*2+1, 2],
+ [width, width+1, width+2, width*2+2],
+ [1, width+1, width*2+1, width*2],
+ [width, width*2, width*2+1, width*2+2]
+ ];
+
+ const zTetromino = [
+ [0, width, width+1, width*2+1],
+ [width+1, width+2, width*2, width*2+1],
+ [0, width, width+1, width*2+1],
+ [width+1, width+2, width*2, width*2+1]
+ ];
+
+ const tTetromino = [
+ [1, width, width+1, width+2],
+ [1, width+1, width+2, width*2+1],
+ [width, width+1, width+2, width*2+1],
+ [1, width, width+1, width*2+1]
+ ];
+
+ const oTetromino = [
+ [0, 1, width, width+1],
+ [0, 1, width, width+1],
+ [0, 1, width, width+1],
+ [0, 1, width, width+1]
+ ];
+
+ const iTetromino = [
+ [1, width+1, width*2+1, width*3+1],
+ [width, width+1, width+2, width+3],
+ [1, width+1, width*2+1, width*3+1],
+ [width, width+1, width+2, width+3]
+ ];
+
+ const theTetrominoes = [lTetromino, zTetromino, tTetromino, oTetromino, iTetromino];
+
+ let random = Math.floor(Math.random() * theTetrominoes.length);
+ let current = theTetrominoes[random][currentRotation];
+
+ function draw() {
+ current.forEach(index => {
+ squares[currentPosition + index].classList.add('tetromino');
+ squares[currentPosition + index].style.backgroundColor = colors[random];
+ });
+ }
+
+ function undraw() {
+ current.forEach(index => {
+ squares[currentPosition + index].classList.remove('tetromino');
+ squares[currentPosition + index].style.backgroundColor = '';
+ });
+ }
+
+ function control(e) {
+ if (e.keyCode === 37) {
+ moveLeft();
+ } else if (e.keyCode === 38) {
+ rotate();
+ } else if (e.keyCode === 39) {
+ moveRight();
+ } else if (e.keyCode === 40) {
+ moveDown();
+ }
+ }
+ document.addEventListener('keydown', control);
+
+ function moveDown() {
+ undraw();
+ currentPosition += width;
+ draw();
+ freeze();
+ }
+
+ function freeze() {
+ if (current.some(index => squares[currentPosition + index + width].classList.contains('taken'))) {
+ current.forEach(index => squares[currentPosition + index].classList.add('taken'));
+ random = nextRandom;
+ nextRandom = Math.floor(Math.random() * theTetrominoes.length);
+ current = theTetrominoes[random][currentRotation];
+ currentPosition = 4;
+ draw();
+ displayShape();
+ addScore();
+ gameOverCheck();
+ }
+ }
+
+ function moveLeft() {
+ undraw();
+ const isAtLeftEdge = current.some(index => (currentPosition + index) % width === 0);
+ if (!isAtLeftEdge) currentPosition -= 1;
+ if (current.some(index => squares[currentPosition + index].classList.contains('taken'))) {
+ currentPosition += 1;
+ }
+ draw();
+ }
+
+ function moveRight() {
+ undraw();
+ const isAtRightEdge = current.some(index => (currentPosition + index) % width === width - 1);
+ if (!isAtRightEdge) currentPosition += 1;
+ if (current.some(index => squares[currentPosition + index].classList.contains('taken'))) {
+ currentPosition -= 1;
+ }
+ draw();
+ }
+
+ function rotate() {
+ undraw();
+ currentRotation++;
+ if (currentRotation === current.length) {
+ currentRotation = 0;
+ }
+ current = theTetrominoes[random][currentRotation];
+ draw();
+ }
+
+ function displayShape() {
+ miniSquares.forEach(square => {
+ square.classList.remove('tetromino');
+ square.style.backgroundColor = '';
+ });
+ theTetrominoes[nextRandom][0].forEach(index => {
+ miniSquares[index].classList.add('tetromino');
+ miniSquares[index].style.backgroundColor = colors[nextRandom];
+ });
+ }
+
+ function addScore() {
+ for (let i = 0; i < 199; i += width) {
+ const row = [i, i+1, i+2, i+3, i+4, i+5, i+6, i+7, i+8, i+9];
+ if (row.every(index => squares[index].classList.contains('taken'))) {
+ score += 10;
+ scoreDisplay.innerHTML = score;
+ row.forEach(index => {
+ squares[index].classList.remove('taken');
+ squares[index].classList.remove('tetromino');
+ squares[index].style.backgroundColor = '';
+ });
+ const squaresRemoved = squares.splice(i, width);
+ squares = squaresRemoved.concat(squares);
+ squares.forEach(cell => grid.appendChild(cell));
+ }
+ }
+ }
+
+ function gameOverCheck() {
+ if (current.some(index => squares[currentPosition + index].classList.contains('taken'))) {
+ gameOver.style.display = 'flex';
+ clearInterval(timerId);
+ }
+ }
+
+ function startGame() {
+ squares.forEach(square => {
+ square.classList.remove('tetromino');
+ square.style.backgroundColor = '';
+ });
+ score = 0;
+ scoreDisplay.innerHTML = score;
+ gameOver.style.display = 'none';
+ timerId = setInterval(moveDown, 1000);
+ nextRandom = Math.floor(Math.random() * theTetrominoes.length);
+ current = theTetrominoes[random][currentRotation];
+ currentPosition = 4;
+ draw();
+ displayShape();
+ }
+
+ startButton.addEventListener('click', startGame);
+ restartButton.addEventListener('click', startGame);
style.css
Changed around line 1
+ :root {
+ --primary-color: #2c3e50;
+ --secondary-color: #34495e;
+ --accent-color: #e74c3c;
+ --text-color: #ecf0f1;
+ --grid-color: #7f8c8d;
+ }
+
+ * {
+ margin: 0;
+ padding: 0;
+ box-sizing: border-box;
+ }
+
+ body {
+ font-family: 'Arial', sans-serif;
+ background-color: var(--primary-color);
+ color: var(--text-color);
+ min-height: 100vh;
+ display: flex;
+ justify-content: center;
+ align-items: center;
+ padding: 1rem;
+ }
+
+ h1 {
+ text-align: center;
+ margin-bottom: 2rem;
+ font-size: 2.5rem;
+ color: var(--accent-color);
+ }
+
+ .game-container {
+ display: flex;
+ gap: 2rem;
+ background-color: var(--secondary-color);
+ padding: 2rem;
+ border-radius: 1rem;
+ box-shadow: 0 0 20px rgba(0, 0, 0, 0.3);
+ }
+
+ .grid, .mini-grid {
+ display: grid;
+ grid-template-columns: repeat(10, 1fr);
+ grid-template-rows: repeat(20, 1fr);
+ gap: 2px;
+ background-color: var(--grid-color);
+ }
+
+ .grid {
+ width: 300px;
+ height: 600px;
+ }
+
+ .mini-grid {
+ width: 100px;
+ height: 100px;
+ margin-top: 1rem;
+ }
+
+ .sidebar {
+ display: flex;
+ flex-direction: column;
+ gap: 2rem;
+ }
+
+ .score-display {
+ text-align: center;
+ }
+
+ .score {
+ font-size: 2rem;
+ font-weight: bold;
+ }
+
+ button {
+ padding: 0.75rem 1.5rem;
+ font-size: 1rem;
+ background-color: var(--accent-color);
+ color: var(--text-color);
+ border: none;
+ border-radius: 0.5rem;
+ cursor: pointer;
+ transition: background-color 0.3s ease;
+ }
+
+ button:hover {
+ background-color: #c0392b;
+ }
+
+ .game-over {
+ display: none;
+ position: fixed;
+ top: 50%;
+ left: 50%;
+ transform: translate(-50%, -50%);
+ background-color: var(--secondary-color);
+ padding: 2rem;
+ border-radius: 1rem;
+ text-align: center;
+ box-shadow: 0 0 20px rgba(0, 0, 0, 0.3);
+ }
+
+ .game-over h2 {
+ margin-bottom: 1rem;
+ }
+
+ @media (max-width: 768px) {
+ .game-container {
+ flex-direction: column;
+ align-items: center;
+ }
+
+ .sidebar {
+ width: 100%;
+ align-items: center;
+ }
+ }