Changes to snakescroll.scroll.pub

ffff:82.167.4.246
ffff:82.167.4.246
24 days ago
updated script.js
script.js
Changed around line 92: function placeFood() {
- direction = { x: 0, y: 0 }; // Initial direction: no movement
+ direction = { x: 1, y: 0 }; // Start moving right
ffff:82.167.4.246
ffff:82.167.4.246
25 days ago
updated script.js
script.js
Changed around line 110: function resetGame() {
-
+ console.log(e.key);
ffff:82.167.4.246
ffff:82.167.4.246
25 days ago
updated script.js
script.js
Changed around line 12: let food = { x: 5, y: 5 };
+ let gameInterval;
Changed around line 36: function drawGame() {
+ // Update score display
+ scoreDisplay.textContent = score;
+ }
+
+ function updateSnake() {
+ if (!gameRunning) return;
+
Changed around line 55: function drawGame() {
+ clearInterval(gameInterval); // Stop the game loop
Changed around line 64: function drawGame() {
- scoreDisplay.textContent = score;
- requestAnimationFrame(drawGame);
+ drawGame();
Changed around line 92: function placeFood() {
- direction = { x: 1, y: 0 }; // Start moving to the right
+ direction = { x: 0, y: 0 }; // Initial direction: no movement
- scoreDisplay.textContent = score;
+
+ // Start the game loop to update snake position every 500ms
+ gameInterval = setInterval(updateSnake, 500);
+ clearInterval(gameInterval); // Stop the game loop
ffff:82.167.4.246
ffff:82.167.4.246
25 days ago
updated script.js
script.js
Changed around line 1
- const canvas = document.getElementById('gameCanvas');
- const ctx = canvas.getContext('2d');
- const startButton = document.getElementById('startButton');
- const resetButton = document.getElementById('resetButton');
- const scoreDisplay = document.getElementById('score');
+ const canvas = document.getElementById("gameCanvas");
+ const ctx = canvas.getContext("2d");
+ const startButton = document.getElementById("startButton");
+ const resetButton = document.getElementById("resetButton");
+ const scoreDisplay = document.getElementById("score");
- let snake = [{x: 10, y: 10}];
- let food = {x: 5, y: 5};
- let direction = {x: 0, y: 0};
+ let snake = [{ x: 10, y: 10 }];
+ let food = { x: 5, y: 5 };
+ let direction = { x: 0, y: 0 };
-
+
- ctx.fillStyle = '#222';
+ ctx.fillStyle = "#222";
- ctx.fillStyle = '#4CAF50';
- snake.forEach(segment => {
- ctx.fillRect(segment.x * gridSize, segment.y * gridSize, gridSize, gridSize);
+ ctx.fillStyle = "#4CAF50";
+ snake.forEach((segment) => {
+ ctx.fillRect(
+ segment.x * gridSize,
+ segment.y * gridSize,
+ gridSize,
+ gridSize,
+ );
- ctx.fillStyle = '#FF5252';
+ ctx.fillStyle = "#FF5252";
- const head = {x: snake[0].x + direction.x, y: snake[0].y + direction.y};
+ const head = { x: snake[0].x + direction.x, y: snake[0].y + direction.y };
- if (head.x < 0 || head.x >= tileCount || head.y < 0 || head.y >= tileCount ||
- snake.some(segment => segment.x === head.x && segment.y === head.y)) {
+ if (
+ head.x < 0 ||
+ head.x >= tileCount ||
+ head.y < 0 ||
+ head.y >= tileCount ||
+ snake.some((segment) => segment.x === head.x && segment.y === head.y)
+ ) {
Changed around line 67: function drawGame() {
- y: Math.floor(Math.random() * tileCount)
+ y: Math.floor(Math.random() * tileCount),
-
+
- while (snake.some(segment => segment.x === food.x && segment.y === food.y)) {
+ while (
+ snake.some((segment) => segment.x === food.x && segment.y === food.y)
+ ) {
- y: Math.floor(Math.random() * tileCount)
+ y: Math.floor(Math.random() * tileCount),
- snake = [{x: 10, y: 10}];
- direction = {x: 0, y: 0};
+ snake = [{ x: 10, y: 10 }];
+ direction = { x: 1, y: 0 }; // Start moving to the right
Changed around line 97: function resetGame() {
- window.addEventListener('keydown', e => {
+ window.addEventListener("keydown", (e) => {
-
- switch(e.key) {
- case 'ArrowUp':
- if (direction.y === 0) direction = {x: 0, y: -1};
+
+ switch (e.key) {
+ case "ArrowUp":
+ if (direction.y === 0) direction = { x: 0, y: -1 };
- case 'ArrowDown':
- if (direction.y === 0) direction = {x: 0, y: 1};
+ case "ArrowDown":
+ if (direction.y === 0) direction = { x: 0, y: 1 };
- case 'ArrowLeft':
- if (direction.x === 0) direction = {x: -1, y: 0};
+ case "ArrowLeft":
+ if (direction.x === 0) direction = { x: -1, y: 0 };
- case 'ArrowRight':
- if (direction.x === 0) direction = {x: 1, y: 0};
+ case "ArrowRight":
+ if (direction.x === 0) direction = { x: 1, y: 0 };
- startButton.addEventListener('click', startGame);
- resetButton.addEventListener('click', resetGame);
+ startButton.addEventListener("click", startGame);
+ resetButton.addEventListener("click", resetGame);
root
root
25 days ago
Initial commit
body.html
Changed around line 1
+
+

Snake Game

+

Classic fun, modern design

+
+
+
+
+
+
+ Score:
+ 0
+
+
+
+
+
+
+
+

Enjoy the classic snake game experience!

+
index.scroll
Changed around line 1
+ buildHtml
+ baseUrl https://snakescroll.scroll.pub
+ metaTags
+ editButton /edit.html
+ title Snake Game - Classic Fun in Your Browser
+ style.css
+ body.html
+ script.js
prompt.json
Changed around line 1
+ {
+ "id": "1a03b8a0-296d-4ed0-b95b-0a1a5024666d",
+ "object": "chat.completion",
+ "created": 1735383237,
+ "model": "deepseek-chat",
+ "choices": [
+ {
+ "index": 0,
+ "message": {
+ "role": "assistant",
+ "content": "---domain---\nsnakescroll.scroll.pub\n---index.scroll---\nbuildHtml\nbaseUrl https://snakescroll.scroll.pub\nmetaTags\neditButton /edit.html\ntitle Snake Game - Classic Fun in Your Browser\nstyle.css\nbody.html\nscript.js\n---body.html---\n
\n

Snake Game

\n

Classic fun, modern design

\n
\n\n
\n
\n \n
\n Score: \n 0\n
\n \n \n
\n
\n\n
\n

Enjoy the classic snake game experience!

\n
\n---style.css---\n:root {\n --primary-color: #4CAF50;\n --secondary-color: #45a049;\n --background-color: #f5f5f5;\n --text-color: #333;\n --canvas-color: #222;\n}\n\n* {\n margin: 0;\n padding: 0;\n box-sizing: border-box;\n}\n\nbody {\n font-family: 'Segoe UI', sans-serif;\n background-color: var(--background-color);\n color: var(--text-color);\n line-height: 1.6;\n min-height: 100vh;\n display: flex;\n flex-direction: column;\n}\n\nheader {\n background-color: var(--primary-color);\n color: white;\n padding: 2rem;\n text-align: center;\n}\n\nh1 {\n font-size: 2.5rem;\n margin-bottom: 0.5rem;\n}\n\nmain {\n flex: 1;\n display: flex;\n justify-content: center;\n align-items: center;\n padding: 2rem;\n}\n\n.game-container {\n text-align: center;\n background: white;\n padding: 2rem;\n border-radius: 10px;\n box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);\n}\n\ncanvas {\n background-color: var(--canvas-color);\n border-radius: 5px;\n margin-bottom: 1rem;\n}\n\n.score-display {\n font-size: 1.2rem;\n margin: 1rem 0;\n color: var(--primary-color);\n}\n\n.game-button {\n background-color: var(--primary-color);\n color: white;\n border: none;\n padding: 0.8rem 1.5rem;\n margin: 0.5rem;\n border-radius: 5px;\n cursor: pointer;\n font-size: 1rem;\n transition: background-color 0.3s ease;\n}\n\n.game-button:hover {\n background-color: var(--secondary-color);\n}\n\nfooter {\n background-color: var(--primary-color);\n color: white;\n text-align: center;\n padding: 1rem;\n}\n\n@media (max-width: 480px) {\n canvas {\n width: 300px;\n height: 300px;\n }\n\n h1 {\n font-size: 2rem;\n }\n}\n---script.js---\nconst canvas = document.getElementById('gameCanvas');\nconst ctx = canvas.getContext('2d');\nconst startButton = document.getElementById('startButton');\nconst resetButton = document.getElementById('resetButton');\nconst scoreDisplay = document.getElementById('score');\n\nconst gridSize = 20;\nconst tileCount = canvas.width / gridSize;\n\nlet snake = [{x: 10, y: 10}];\nlet food = {x: 5, y: 5};\nlet direction = {x: 0, y: 0};\nlet score = 0;\nlet gameRunning = false;\n\nfunction drawGame() {\n if (!gameRunning) return;\n \n // Clear canvas\n ctx.fillStyle = '#222';\n ctx.fillRect(0, 0, canvas.width, canvas.height);\n\n // Draw snake\n ctx.fillStyle = '#4CAF50';\n snake.forEach(segment => {\n ctx.fillRect(segment.x * gridSize, segment.y * gridSize, gridSize, gridSize);\n });\n\n // Draw food\n ctx.fillStyle = '#FF5252';\n ctx.fillRect(food.x * gridSize, food.y * gridSize, gridSize, gridSize);\n\n // Move snake\n const head = {x: snake[0].x + direction.x, y: snake[0].y + direction.y};\n\n // Check collision with walls or self\n if (head.x < 0 || head.x >= tileCount || head.y < 0 || head.y >= tileCount ||\n snake.some(segment => segment.x === head.x && segment.y === head.y)) {\n gameRunning = false;\n return;\n }\n\n snake.unshift(head);\n\n // Check if snake eats food\n if (head.x === food.x && head.y === food.y) {\n score++;\n scoreDisplay.textContent = score;\n placeFood();\n } else {\n snake.pop();\n }\n\n requestAnimationFrame(drawGame);\n}\n\nfunction placeFood() {\n food = {\n x: Math.floor(Math.random() * tileCount),\n y: Math.floor(Math.random() * tileCount)\n };\n \n // Make sure food doesn't spawn on snake\n while (snake.some(segment => segment.x === food.x && segment.y === food.y)) {\n food = {\n x: Math.floor(Math.random() * tileCount),\n y: Math.floor(Math.random() * tileCount)\n };\n }\n}\n\nfunction startGame() {\n if (gameRunning) return;\n snake = [{x: 10, y: 10}];\n direction = {x: 0, y: 0};\n score = 0;\n scoreDisplay.textContent = score;\n placeFood();\n gameRunning = true;\n drawGame();\n}\n\nfunction resetGame() {\n gameRunning = false;\n startGame();\n}\n\nwindow.addEventListener('keydown', e => {\n if (!gameRunning) return;\n \n switch(e.key) {\n case 'ArrowUp':\n if (direction.y === 0) direction = {x: 0, y: -1};\n break;\n case 'ArrowDown':\n if (direction.y === 0) direction = {x: 0, y: 1};\n break;\n case 'ArrowLeft':\n if (direction.x === 0) direction = {x: -1, y: 0};\n break;\n case 'ArrowRight':\n if (direction.x === 0) direction = {x: 1, y: 0};\n break;\n }\n});\n\nstartButton.addEventListener('click', startGame);\nresetButton.addEventListener('click', resetGame);\n---end---"
+ },
+ "logprobs": null,
+ "finish_reason": "stop"
+ }
+ ],
+ "usage": {
+ "prompt_tokens": 239,
+ "completion_tokens": 1509,
+ "total_tokens": 1748,
+ "prompt_cache_hit_tokens": 0,
+ "prompt_cache_miss_tokens": 239
+ },
+ "system_fingerprint": "fp_f1afce2943"
+ }
readme.scroll
Changed around line 1
+ # snakescroll.scroll.pub
+ Website generated by DeepSeek from prompt: Website to play snake game
script.js
Changed around line 1
+ const canvas = document.getElementById('gameCanvas');
+ const ctx = canvas.getContext('2d');
+ const startButton = document.getElementById('startButton');
+ const resetButton = document.getElementById('resetButton');
+ const scoreDisplay = document.getElementById('score');
+
+ const gridSize = 20;
+ const tileCount = canvas.width / gridSize;
+
+ let snake = [{x: 10, y: 10}];
+ let food = {x: 5, y: 5};
+ let direction = {x: 0, y: 0};
+ let score = 0;
+ let gameRunning = false;
+
+ function drawGame() {
+ if (!gameRunning) return;
+
+ // Clear canvas
+ ctx.fillStyle = '#222';
+ ctx.fillRect(0, 0, canvas.width, canvas.height);
+
+ // Draw snake
+ ctx.fillStyle = '#4CAF50';
+ snake.forEach(segment => {
+ ctx.fillRect(segment.x * gridSize, segment.y * gridSize, gridSize, gridSize);
+ });
+
+ // Draw food
+ ctx.fillStyle = '#FF5252';
+ ctx.fillRect(food.x * gridSize, food.y * gridSize, gridSize, gridSize);
+
+ // Move snake
+ const head = {x: snake[0].x + direction.x, y: snake[0].y + direction.y};
+
+ // Check collision with walls or self
+ if (head.x < 0 || head.x >= tileCount || head.y < 0 || head.y >= tileCount ||
+ snake.some(segment => segment.x === head.x && segment.y === head.y)) {
+ gameRunning = false;
+ return;
+ }
+
+ snake.unshift(head);
+
+ // Check if snake eats food
+ if (head.x === food.x && head.y === food.y) {
+ score++;
+ scoreDisplay.textContent = score;
+ placeFood();
+ } else {
+ snake.pop();
+ }
+
+ requestAnimationFrame(drawGame);
+ }
+
+ function placeFood() {
+ food = {
+ x: Math.floor(Math.random() * tileCount),
+ y: Math.floor(Math.random() * tileCount)
+ };
+
+ // Make sure food doesn't spawn on snake
+ while (snake.some(segment => segment.x === food.x && segment.y === food.y)) {
+ food = {
+ x: Math.floor(Math.random() * tileCount),
+ y: Math.floor(Math.random() * tileCount)
+ };
+ }
+ }
+
+ function startGame() {
+ if (gameRunning) return;
+ snake = [{x: 10, y: 10}];
+ direction = {x: 0, y: 0};
+ score = 0;
+ scoreDisplay.textContent = score;
+ placeFood();
+ gameRunning = true;
+ drawGame();
+ }
+
+ function resetGame() {
+ gameRunning = false;
+ startGame();
+ }
+
+ window.addEventListener('keydown', e => {
+ if (!gameRunning) return;
+
+ switch(e.key) {
+ case 'ArrowUp':
+ if (direction.y === 0) direction = {x: 0, y: -1};
+ break;
+ case 'ArrowDown':
+ if (direction.y === 0) direction = {x: 0, y: 1};
+ break;
+ case 'ArrowLeft':
+ if (direction.x === 0) direction = {x: -1, y: 0};
+ break;
+ case 'ArrowRight':
+ if (direction.x === 0) direction = {x: 1, y: 0};
+ break;
+ }
+ });
+
+ startButton.addEventListener('click', startGame);
+ resetButton.addEventListener('click', resetGame);
style.css
Changed around line 1
+ :root {
+ --primary-color: #4CAF50;
+ --secondary-color: #45a049;
+ --background-color: #f5f5f5;
+ --text-color: #333;
+ --canvas-color: #222;
+ }
+
+ * {
+ margin: 0;
+ padding: 0;
+ box-sizing: border-box;
+ }
+
+ body {
+ font-family: 'Segoe UI', sans-serif;
+ background-color: var(--background-color);
+ color: var(--text-color);
+ line-height: 1.6;
+ min-height: 100vh;
+ display: flex;
+ flex-direction: column;
+ }
+
+ header {
+ background-color: var(--primary-color);
+ color: white;
+ padding: 2rem;
+ text-align: center;
+ }
+
+ h1 {
+ font-size: 2.5rem;
+ margin-bottom: 0.5rem;
+ }
+
+ main {
+ flex: 1;
+ display: flex;
+ justify-content: center;
+ align-items: center;
+ padding: 2rem;
+ }
+
+ .game-container {
+ text-align: center;
+ background: white;
+ padding: 2rem;
+ border-radius: 10px;
+ box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
+ }
+
+ canvas {
+ background-color: var(--canvas-color);
+ border-radius: 5px;
+ margin-bottom: 1rem;
+ }
+
+ .score-display {
+ font-size: 1.2rem;
+ margin: 1rem 0;
+ color: var(--primary-color);
+ }
+
+ .game-button {
+ background-color: var(--primary-color);
+ color: white;
+ border: none;
+ padding: 0.8rem 1.5rem;
+ margin: 0.5rem;
+ border-radius: 5px;
+ cursor: pointer;
+ font-size: 1rem;
+ transition: background-color 0.3s ease;
+ }
+
+ .game-button:hover {
+ background-color: var(--secondary-color);
+ }
+
+ footer {
+ background-color: var(--primary-color);
+ color: white;
+ text-align: center;
+ padding: 1rem;
+ }
+
+ @media (max-width: 480px) {
+ canvas {
+ width: 300px;
+ height: 300px;
+ }
+
+ h1 {
+ font-size: 2rem;
+ }
+ }