Spaces:
Running
Running
Add 3 files
Browse files- README.md +7 -5
- index.html +588 -19
- prompts.txt +0 -0
README.md
CHANGED
|
@@ -1,10 +1,12 @@
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
-
emoji:
|
| 4 |
-
colorFrom:
|
| 5 |
-
colorTo:
|
| 6 |
sdk: static
|
| 7 |
pinned: false
|
|
|
|
|
|
|
| 8 |
---
|
| 9 |
|
| 10 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
|
| 1 |
---
|
| 2 |
+
title: games
|
| 3 |
+
emoji: 🐳
|
| 4 |
+
colorFrom: yellow
|
| 5 |
+
colorTo: purple
|
| 6 |
sdk: static
|
| 7 |
pinned: false
|
| 8 |
+
tags:
|
| 9 |
+
- deepsite
|
| 10 |
---
|
| 11 |
|
| 12 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
index.html
CHANGED
|
@@ -1,19 +1,588 @@
|
|
| 1 |
-
<!
|
| 2 |
-
<html>
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="ru">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>Змейка - Классическая игра</title>
|
| 7 |
+
<script src="https://cdn.tailwindcss.com"></script>
|
| 8 |
+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
| 9 |
+
<style>
|
| 10 |
+
@keyframes pulse {
|
| 11 |
+
0% { transform: scale(1); }
|
| 12 |
+
50% { transform: scale(1.05); }
|
| 13 |
+
100% { transform: scale(1); }
|
| 14 |
+
}
|
| 15 |
+
|
| 16 |
+
.pulse {
|
| 17 |
+
animation: pulse 1.5s infinite;
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
.snake-segment {
|
| 21 |
+
transition: all 0.1s ease;
|
| 22 |
+
box-shadow: 0 0 8px rgba(74, 222, 128, 0.7);
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
.food {
|
| 26 |
+
animation: spin 3s linear infinite;
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
@keyframes spin {
|
| 30 |
+
0% { transform: rotate(0deg) scale(1); }
|
| 31 |
+
50% { transform: rotate(180deg) scale(1.2); }
|
| 32 |
+
100% { transform: rotate(360deg) scale(1); }
|
| 33 |
+
}
|
| 34 |
+
|
| 35 |
+
.game-over {
|
| 36 |
+
backdrop-filter: blur(5px);
|
| 37 |
+
}
|
| 38 |
+
|
| 39 |
+
#game-board {
|
| 40 |
+
border: 8px solid #4f46e5;
|
| 41 |
+
box-shadow: 0 0 30px rgba(79, 70, 229, 0.5);
|
| 42 |
+
}
|
| 43 |
+
</style>
|
| 44 |
+
</head>
|
| 45 |
+
<body class="bg-gray-900 text-white min-h-screen flex flex-col items-center justify-center p-4">
|
| 46 |
+
<div class="max-w-4xl w-full">
|
| 47 |
+
<header class="flex justify-between items-center mb-6">
|
| 48 |
+
<h1 class="text-4xl font-bold bg-gradient-to-r from-green-400 to-blue-500 bg-clip-text text-transparent">
|
| 49 |
+
<i class="fas fa-snake mr-2"></i>Змейка
|
| 50 |
+
</h1>
|
| 51 |
+
<div class="flex items-center space-x-6">
|
| 52 |
+
<div class="bg-gray-800 px-4 py-2 rounded-lg">
|
| 53 |
+
<span class="text-gray-400 mr-2"><i class="fas fa-star"></i></span>
|
| 54 |
+
<span id="score" class="text-xl font-bold">0</span>
|
| 55 |
+
</div>
|
| 56 |
+
<div class="bg-gray-800 px-4 py-2 rounded-lg">
|
| 57 |
+
<span class="text-gray-400 mr-2"><i class="fas fa-clock"></i></span>
|
| 58 |
+
<span id="high-score" class="text-xl font-bold">0</span>
|
| 59 |
+
</div>
|
| 60 |
+
</div>
|
| 61 |
+
</header>
|
| 62 |
+
|
| 63 |
+
<div class="relative">
|
| 64 |
+
<canvas id="game-board" class="w-full bg-gray-800 rounded-xl" height="500"></canvas>
|
| 65 |
+
|
| 66 |
+
<div id="start-screen" class="absolute inset-0 flex flex-col items-center justify-center bg-gray-900 bg-opacity-90 rounded-xl">
|
| 67 |
+
<div class="text-center max-w-md px-4">
|
| 68 |
+
<h2 class="text-3xl font-bold mb-4 bg-gradient-to-r from-purple-500 to-pink-500 bg-clip-text text-transparent">
|
| 69 |
+
Классическая Змейка
|
| 70 |
+
</h2>
|
| 71 |
+
<p class="text-gray-300 mb-6">
|
| 72 |
+
Собери как можно больше еды, избегая стен и своего хвоста!
|
| 73 |
+
</p>
|
| 74 |
+
<button id="start-btn" class="bg-gradient-to-r from-green-400 to-blue-500 hover:from-green-500 hover:to-blue-600 text-white font-bold py-3 px-8 rounded-full text-lg pulse">
|
| 75 |
+
<i class="fas fa-play mr-2"></i>Начать игру
|
| 76 |
+
</button>
|
| 77 |
+
<div class="mt-8 text-gray-400">
|
| 78 |
+
<p class="flex items-center justify-center mb-2">
|
| 79 |
+
<i class="fas fa-arrow-up mr-2"></i> <i class="fas fa-arrow-down mr-2"></i>
|
| 80 |
+
<i class="fas fa-arrow-left mr-2"></i> <i class="fas fa-arrow-right"></i>
|
| 81 |
+
<span class="ml-2">- Управление</span>
|
| 82 |
+
</p>
|
| 83 |
+
<p class="flex items-center justify-center">
|
| 84 |
+
<i class="fas fa-space-shuttle mr-2"></i>
|
| 85 |
+
<span>Пробел - Пауза</span>
|
| 86 |
+
</p>
|
| 87 |
+
</div>
|
| 88 |
+
</div>
|
| 89 |
+
</div>
|
| 90 |
+
|
| 91 |
+
<div id="game-over" class="absolute inset-0 hidden flex-col items-center justify-center bg-gray-900 bg-opacity-90 rounded-xl game-over">
|
| 92 |
+
<div class="text-center">
|
| 93 |
+
<h2 class="text-4xl font-bold mb-4 text-red-500">
|
| 94 |
+
<i class="fas fa-skull mr-2"></i>Игра окончена!
|
| 95 |
+
</h2>
|
| 96 |
+
<p class="text-2xl mb-6">
|
| 97 |
+
Ваш счет: <span id="final-score" class="font-bold text-green-400">0</span>
|
| 98 |
+
</p>
|
| 99 |
+
<div class="flex space-x-4 justify-center">
|
| 100 |
+
<button id="restart-btn" class="bg-gradient-to-r from-green-400 to-blue-500 hover:from-green-500 hover:to-blue-600 text-white font-bold py-3 px-6 rounded-full">
|
| 101 |
+
<i class="fas fa-redo mr-2"></i>Играть снова
|
| 102 |
+
</button>
|
| 103 |
+
<button id="menu-btn" class="bg-gradient-to-r from-purple-500 to-pink-500 hover:from-purple-600 hover:to-pink-600 text-white font-bold py-3 px-6 rounded-full">
|
| 104 |
+
<i class="fas fa-home mr-2"></i>Меню
|
| 105 |
+
</button>
|
| 106 |
+
</div>
|
| 107 |
+
</div>
|
| 108 |
+
</div>
|
| 109 |
+
|
| 110 |
+
<div id="pause-screen" class="absolute inset-0 hidden flex-col items-center justify-center bg-gray-900 bg-opacity-80 rounded-xl">
|
| 111 |
+
<div class="text-center">
|
| 112 |
+
<h2 class="text-4xl font-bold mb-6 text-yellow-400">
|
| 113 |
+
<i class="fas fa-pause mr-2"></i>Пауза
|
| 114 |
+
</h2>
|
| 115 |
+
<button id="resume-btn" class="bg-gradient-to-r from-green-400 to-blue-500 hover:from-green-500 hover:to-blue-600 text-white font-bold py-3 px-8 rounded-full text-lg">
|
| 116 |
+
<i class="fas fa-play mr-2"></i>Продолжить
|
| 117 |
+
</button>
|
| 118 |
+
</div>
|
| 119 |
+
</div>
|
| 120 |
+
</div>
|
| 121 |
+
|
| 122 |
+
<div class="mt-6 grid grid-cols-1 md:grid-cols-3 gap-4">
|
| 123 |
+
<div class="bg-gray-800 p-4 rounded-lg">
|
| 124 |
+
<h3 class="text-lg font-semibold mb-2 text-green-400">
|
| 125 |
+
<i class="fas fa-trophy mr-2"></i>Рекорды
|
| 126 |
+
</h3>
|
| 127 |
+
<ul id="leaderboard" class="space-y-2">
|
| 128 |
+
<li class="flex justify-between">
|
| 129 |
+
<span>1. Игрок 1</span>
|
| 130 |
+
<span>250</span>
|
| 131 |
+
</li>
|
| 132 |
+
<li class="flex justify-between text-gray-400">
|
| 133 |
+
<span>2. Игрок 2</span>
|
| 134 |
+
<span>180</span>
|
| 135 |
+
</li>
|
| 136 |
+
<li class="flex justify-between text-gray-400">
|
| 137 |
+
<span>3. Игрок 3</span>
|
| 138 |
+
<span>150</span>
|
| 139 |
+
</li>
|
| 140 |
+
</ul>
|
| 141 |
+
</div>
|
| 142 |
+
|
| 143 |
+
<div class="bg-gray-800 p-4 rounded-lg">
|
| 144 |
+
<h3 class="text-lg font-semibold mb-2 text-blue-400">
|
| 145 |
+
<i class="fas fa-info-circle mr-2"></i>Правила
|
| 146 |
+
</h3>
|
| 147 |
+
<ul class="space-y-2 text-gray-300">
|
| 148 |
+
<li class="flex items-start">
|
| 149 |
+
<i class="fas fa-check-circle text-green-400 mt-1 mr-2"></i>
|
| 150 |
+
<span>Управляйте змейкой с помощью стрелок</span>
|
| 151 |
+
</li>
|
| 152 |
+
<li class="flex items-start">
|
| 153 |
+
<i class="fas fa-check-circle text-green-400 mt-1 mr-2"></i>
|
| 154 |
+
<span>Собирайте еду для увеличения длины</span>
|
| 155 |
+
</li>
|
| 156 |
+
<li class="flex items-start">
|
| 157 |
+
<i class="fas fa-times-circle text-red-400 mt-1 mr-2"></i>
|
| 158 |
+
<span>Не врезайтесь в стены и себя</span>
|
| 159 |
+
</li>
|
| 160 |
+
</ul>
|
| 161 |
+
</div>
|
| 162 |
+
|
| 163 |
+
<div class="bg-gray-800 p-4 rounded-lg">
|
| 164 |
+
<h3 class="text-lg font-semibold mb-2 text-purple-400">
|
| 165 |
+
<i class="fas fa-cog mr-2"></i>Настройки
|
| 166 |
+
</h3>
|
| 167 |
+
<div class="space-y-4">
|
| 168 |
+
<div>
|
| 169 |
+
<label class="block text-gray-300 mb-1">Скорость</label>
|
| 170 |
+
<select id="speed-select" class="w-full bg-gray-700 rounded px-3 py-2">
|
| 171 |
+
<option value="150">Медленно</option>
|
| 172 |
+
<option value="100" selected>Средне</option>
|
| 173 |
+
<option value="70">Быстро</option>
|
| 174 |
+
<option value="40">Очень быстро</option>
|
| 175 |
+
</select>
|
| 176 |
+
</div>
|
| 177 |
+
<div>
|
| 178 |
+
<label class="block text-gray-300 mb-1">Цвет змейки</label>
|
| 179 |
+
<div class="flex space-x-2">
|
| 180 |
+
<button data-color="bg-green-500" class="w-6 h-6 rounded-full bg-green-500 border-2 border-white"></button>
|
| 181 |
+
<button data-color="bg-blue-500" class="w-6 h-6 rounded-full bg-blue-500"></button>
|
| 182 |
+
<button data-color="bg-red-500" class="w-6 h-6 rounded-full bg-red-500"></button>
|
| 183 |
+
<button data-color="bg-purple-500" class="w-6 h-6 rounded-full bg-purple-500"></button>
|
| 184 |
+
<button data-color="bg-yellow-500" class="w-6 h-6 rounded-full bg-yellow-500"></button>
|
| 185 |
+
</div>
|
| 186 |
+
</div>
|
| 187 |
+
</div>
|
| 188 |
+
</div>
|
| 189 |
+
</div>
|
| 190 |
+
</div>
|
| 191 |
+
|
| 192 |
+
<footer class="mt-8 text-center text-gray-500 text-sm">
|
| 193 |
+
<p>© 2023 Классическая Змейка | Создано с <i class="fas fa-heart text-red-500"></i> для любителей ретро-игр</p>
|
| 194 |
+
</footer>
|
| 195 |
+
|
| 196 |
+
<script>
|
| 197 |
+
document.addEventListener('DOMContentLoaded', () => {
|
| 198 |
+
const canvas = document.getElementById('game-board');
|
| 199 |
+
const ctx = canvas.getContext('2d');
|
| 200 |
+
const startScreen = document.getElementById('start-screen');
|
| 201 |
+
const gameOverScreen = document.getElementById('game-over');
|
| 202 |
+
const pauseScreen = document.getElementById('pause-screen');
|
| 203 |
+
const startBtn = document.getElementById('start-btn');
|
| 204 |
+
const restartBtn = document.getElementById('restart-btn');
|
| 205 |
+
const resumeBtn = document.getElementById('resume-btn');
|
| 206 |
+
const menuBtn = document.getElementById('menu-btn');
|
| 207 |
+
const scoreElement = document.getElementById('score');
|
| 208 |
+
const highScoreElement = document.getElementById('high-score');
|
| 209 |
+
const finalScoreElement = document.getElementById('final-score');
|
| 210 |
+
const speedSelect = document.getElementById('speed-select');
|
| 211 |
+
const colorButtons = document.querySelectorAll('[data-color]');
|
| 212 |
+
|
| 213 |
+
// Установка размеров canvas
|
| 214 |
+
canvas.width = canvas.offsetWidth;
|
| 215 |
+
canvas.height = canvas.offsetHeight;
|
| 216 |
+
|
| 217 |
+
// Настройки игры
|
| 218 |
+
const gridSize = 20;
|
| 219 |
+
const tileCountX = Math.floor(canvas.width / gridSize);
|
| 220 |
+
const tileCountY = Math.floor(canvas.height / gridSize);
|
| 221 |
+
|
| 222 |
+
let snake = [];
|
| 223 |
+
let food = {};
|
| 224 |
+
let direction = 'right';
|
| 225 |
+
let nextDirection = 'right';
|
| 226 |
+
let gameSpeed = 100;
|
| 227 |
+
let gameLoop;
|
| 228 |
+
let score = 0;
|
| 229 |
+
let highScore = localStorage.getItem('snakeHighScore') || 0;
|
| 230 |
+
let isPaused = false;
|
| 231 |
+
let snakeColor = 'bg-green-500';
|
| 232 |
+
|
| 233 |
+
highScoreElement.textContent = highScore;
|
| 234 |
+
|
| 235 |
+
// Цвета
|
| 236 |
+
const colors = {
|
| 237 |
+
'bg-green-500': '#10B981',
|
| 238 |
+
'bg-blue-500': '#3B82F6',
|
| 239 |
+
'bg-red-500': '#EF4444',
|
| 240 |
+
'bg-purple-500': '#8B5CF6',
|
| 241 |
+
'bg-yellow-500': '#F59E0B'
|
| 242 |
+
};
|
| 243 |
+
|
| 244 |
+
// Инициализация игры
|
| 245 |
+
function initGame() {
|
| 246 |
+
// Создаем змейку
|
| 247 |
+
snake = [];
|
| 248 |
+
for (let i = 5; i >= 0; i--) {
|
| 249 |
+
snake.push({ x: i, y: 0 });
|
| 250 |
+
}
|
| 251 |
+
|
| 252 |
+
// Создаем еду
|
| 253 |
+
createFood();
|
| 254 |
+
|
| 255 |
+
// Сбрасываем счет
|
| 256 |
+
score = 0;
|
| 257 |
+
scoreElement.textContent = score;
|
| 258 |
+
|
| 259 |
+
// Устанавливаем направление
|
| 260 |
+
direction = 'right';
|
| 261 |
+
nextDirection = 'right';
|
| 262 |
+
|
| 263 |
+
// Устанавливаем скорость
|
| 264 |
+
gameSpeed = parseInt(speedSelect.value);
|
| 265 |
+
}
|
| 266 |
+
|
| 267 |
+
// Создание еды
|
| 268 |
+
function createFood() {
|
| 269 |
+
food = {
|
| 270 |
+
x: Math.floor(Math.random() * tileCountX),
|
| 271 |
+
y: Math.floor(Math.random() * tileCountY)
|
| 272 |
+
};
|
| 273 |
+
|
| 274 |
+
// Проверяем, чтобы еда не появилась на змейке
|
| 275 |
+
for (let segment of snake) {
|
| 276 |
+
if (segment.x === food.x && segment.y === food.y) {
|
| 277 |
+
return createFood();
|
| 278 |
+
}
|
| 279 |
+
}
|
| 280 |
+
}
|
| 281 |
+
|
| 282 |
+
// Основной игровой цикл
|
| 283 |
+
function gameUpdate() {
|
| 284 |
+
if (isPaused) return;
|
| 285 |
+
|
| 286 |
+
// Обновляем направление
|
| 287 |
+
direction = nextDirection;
|
| 288 |
+
|
| 289 |
+
// Получаем голову змейки
|
| 290 |
+
const head = { ...snake[0] };
|
| 291 |
+
|
| 292 |
+
// Двигаем голову в зависимости от направления
|
| 293 |
+
switch (direction) {
|
| 294 |
+
case 'up':
|
| 295 |
+
head.y--;
|
| 296 |
+
break;
|
| 297 |
+
case 'down':
|
| 298 |
+
head.y++;
|
| 299 |
+
break;
|
| 300 |
+
case 'left':
|
| 301 |
+
head.x--;
|
| 302 |
+
break;
|
| 303 |
+
case 'right':
|
| 304 |
+
head.x++;
|
| 305 |
+
break;
|
| 306 |
+
}
|
| 307 |
+
|
| 308 |
+
// Проверка на столкновение со стенами
|
| 309 |
+
if (head.x < 0 || head.x >= tileCountX || head.y < 0 || head.y >= tileCountY) {
|
| 310 |
+
return gameOver();
|
| 311 |
+
}
|
| 312 |
+
|
| 313 |
+
// Проверка на столкновение с собой
|
| 314 |
+
for (let segment of snake) {
|
| 315 |
+
if (segment.x === head.x && segment.y === head.y) {
|
| 316 |
+
return gameOver();
|
| 317 |
+
}
|
| 318 |
+
}
|
| 319 |
+
|
| 320 |
+
// Добавляем новую голову
|
| 321 |
+
snake.unshift(head);
|
| 322 |
+
|
| 323 |
+
// Проверка на съедение еды
|
| 324 |
+
if (head.x === food.x && head.y === food.y) {
|
| 325 |
+
// Увеличиваем счет
|
| 326 |
+
score++;
|
| 327 |
+
scoreElement.textContent = score;
|
| 328 |
+
|
| 329 |
+
// Создаем новую еду
|
| 330 |
+
createFood();
|
| 331 |
+
} else {
|
| 332 |
+
// Удаляем хвост, если не съели еду
|
| 333 |
+
snake.pop();
|
| 334 |
+
}
|
| 335 |
+
|
| 336 |
+
// Отрисовка игры
|
| 337 |
+
drawGame();
|
| 338 |
+
}
|
| 339 |
+
|
| 340 |
+
// Отрисовка игры
|
| 341 |
+
function drawGame() {
|
| 342 |
+
// Очищаем canvas
|
| 343 |
+
ctx.fillStyle = '#1F2937';
|
| 344 |
+
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
| 345 |
+
|
| 346 |
+
// Рисуем сетку
|
| 347 |
+
ctx.strokeStyle = '#374151';
|
| 348 |
+
ctx.lineWidth = 0.5;
|
| 349 |
+
|
| 350 |
+
for (let x = 0; x < tileCountX; x++) {
|
| 351 |
+
for (let y = 0; y < tileCountY; y++) {
|
| 352 |
+
ctx.strokeRect(x * gridSize, y * gridSize, gridSize, gridSize);
|
| 353 |
+
}
|
| 354 |
+
}
|
| 355 |
+
|
| 356 |
+
// Рисуем змейку
|
| 357 |
+
const color = colors[snakeColor] || '#10B981';
|
| 358 |
+
|
| 359 |
+
snake.forEach((segment, index) => {
|
| 360 |
+
// Голова
|
| 361 |
+
if (index === 0) {
|
| 362 |
+
ctx.fillStyle = color;
|
| 363 |
+
ctx.beginPath();
|
| 364 |
+
ctx.roundRect(segment.x * gridSize, segment.y * gridSize, gridSize, gridSize, 4);
|
| 365 |
+
ctx.fill();
|
| 366 |
+
|
| 367 |
+
// Глаза
|
| 368 |
+
ctx.fillStyle = 'white';
|
| 369 |
+
let eye1X, eye1Y, eye2X, eye2Y;
|
| 370 |
+
|
| 371 |
+
switch (direction) {
|
| 372 |
+
case 'up':
|
| 373 |
+
eye1X = segment.x * gridSize + 4;
|
| 374 |
+
eye1Y = segment.y * gridSize + 4;
|
| 375 |
+
eye2X = segment.x * gridSize + gridSize - 8;
|
| 376 |
+
eye2Y = segment.y * gridSize + 4;
|
| 377 |
+
break;
|
| 378 |
+
case 'down':
|
| 379 |
+
eye1X = segment.x * gridSize + 4;
|
| 380 |
+
eye1Y = segment.y * gridSize + gridSize - 8;
|
| 381 |
+
eye2X = segment.x * gridSize + gridSize - 8;
|
| 382 |
+
eye2Y = segment.y * gridSize + gridSize - 8;
|
| 383 |
+
break;
|
| 384 |
+
case 'left':
|
| 385 |
+
eye1X = segment.x * gridSize + 4;
|
| 386 |
+
eye1Y = segment.y * gridSize + 4;
|
| 387 |
+
eye2X = segment.x * gridSize + 4;
|
| 388 |
+
eye2Y = segment.y * gridSize + gridSize - 8;
|
| 389 |
+
break;
|
| 390 |
+
case 'right':
|
| 391 |
+
eye1X = segment.x * gridSize + gridSize - 8;
|
| 392 |
+
eye1Y = segment.y * gridSize + 4;
|
| 393 |
+
eye2X = segment.x * gridSize + gridSize - 8;
|
| 394 |
+
eye2Y = segment.y * gridSize + gridSize - 8;
|
| 395 |
+
break;
|
| 396 |
+
}
|
| 397 |
+
|
| 398 |
+
ctx.beginPath();
|
| 399 |
+
ctx.arc(eye1X + 2, eye1Y + 2, 2, 0, Math.PI * 2);
|
| 400 |
+
ctx.arc(eye2X + 2, eye2Y + 2, 2, 0, Math.PI * 2);
|
| 401 |
+
ctx.fill();
|
| 402 |
+
|
| 403 |
+
// Зрачки
|
| 404 |
+
ctx.fillStyle = 'black';
|
| 405 |
+
ctx.beginPath();
|
| 406 |
+
ctx.arc(eye1X + 2, eye1Y + 2, 1, 0, Math.PI * 2);
|
| 407 |
+
ctx.arc(eye2X + 2, eye2Y + 2, 1, 0, Math.PI * 2);
|
| 408 |
+
ctx.fill();
|
| 409 |
+
}
|
| 410 |
+
// Тело
|
| 411 |
+
else {
|
| 412 |
+
ctx.fillStyle = color;
|
| 413 |
+
ctx.beginPath();
|
| 414 |
+
ctx.roundRect(segment.x * gridSize, segment.y * gridSize, gridSize, gridSize, 4);
|
| 415 |
+
ctx.fill();
|
| 416 |
+
}
|
| 417 |
+
});
|
| 418 |
+
|
| 419 |
+
// Рисуем еду
|
| 420 |
+
ctx.fillStyle = '#EF4444';
|
| 421 |
+
ctx.beginPath();
|
| 422 |
+
ctx.arc(
|
| 423 |
+
food.x * gridSize + gridSize / 2,
|
| 424 |
+
food.y * gridSize + gridSize / 2,
|
| 425 |
+
gridSize / 2 - 2,
|
| 426 |
+
0,
|
| 427 |
+
Math.PI * 2
|
| 428 |
+
);
|
| 429 |
+
ctx.fill();
|
| 430 |
+
|
| 431 |
+
// Эффект свечения еды
|
| 432 |
+
ctx.shadowColor = '#EF4444';
|
| 433 |
+
ctx.shadowBlur = 10;
|
| 434 |
+
ctx.fill();
|
| 435 |
+
ctx.shadowColor = 'transparent';
|
| 436 |
+
}
|
| 437 |
+
|
| 438 |
+
// Конец игры
|
| 439 |
+
function gameOver() {
|
| 440 |
+
clearInterval(gameLoop);
|
| 441 |
+
|
| 442 |
+
// Обновляем рекорд
|
| 443 |
+
if (score > highScore) {
|
| 444 |
+
highScore = score;
|
| 445 |
+
localStorage.setItem('snakeHighScore', highScore);
|
| 446 |
+
highScoreElement.textContent = highScore;
|
| 447 |
+
}
|
| 448 |
+
|
| 449 |
+
finalScoreElement.textContent = score;
|
| 450 |
+
gameOverScreen.classList.remove('hidden');
|
| 451 |
+
}
|
| 452 |
+
|
| 453 |
+
// Управление
|
| 454 |
+
document.addEventListener('keydown', (e) => {
|
| 455 |
+
switch (e.key) {
|
| 456 |
+
case 'ArrowUp':
|
| 457 |
+
if (direction !== 'down') nextDirection = 'up';
|
| 458 |
+
break;
|
| 459 |
+
case 'ArrowDown':
|
| 460 |
+
if (direction !== 'up') nextDirection = 'down';
|
| 461 |
+
break;
|
| 462 |
+
case 'ArrowLeft':
|
| 463 |
+
if (direction !== 'right') nextDirection = 'left';
|
| 464 |
+
break;
|
| 465 |
+
case 'ArrowRight':
|
| 466 |
+
if (direction !== 'left') nextDirection = 'right';
|
| 467 |
+
break;
|
| 468 |
+
case ' ':
|
| 469 |
+
togglePause();
|
| 470 |
+
break;
|
| 471 |
+
}
|
| 472 |
+
});
|
| 473 |
+
|
| 474 |
+
// Пауза
|
| 475 |
+
function togglePause() {
|
| 476 |
+
if (!startScreen.classList.contains('hidden') || gameOverScreen.classList.contains('hidden') === false) return;
|
| 477 |
+
|
| 478 |
+
isPaused = !isPaused;
|
| 479 |
+
|
| 480 |
+
if (isPaused) {
|
| 481 |
+
pauseScreen.classList.remove('hidden');
|
| 482 |
+
} else {
|
| 483 |
+
pauseScreen.classList.add('hidden');
|
| 484 |
+
}
|
| 485 |
+
}
|
| 486 |
+
|
| 487 |
+
// Кнопки управления
|
| 488 |
+
startBtn.addEventListener('click', () => {
|
| 489 |
+
startScreen.classList.add('hidden');
|
| 490 |
+
initGame();
|
| 491 |
+
gameLoop = setInterval(gameUpdate, gameSpeed);
|
| 492 |
+
});
|
| 493 |
+
|
| 494 |
+
restartBtn.addEventListener('click', () => {
|
| 495 |
+
gameOverScreen.classList.add('hidden');
|
| 496 |
+
initGame();
|
| 497 |
+
gameLoop = setInterval(gameUpdate, gameSpeed);
|
| 498 |
+
});
|
| 499 |
+
|
| 500 |
+
resumeBtn.addEventListener('click', () => {
|
| 501 |
+
togglePause();
|
| 502 |
+
});
|
| 503 |
+
|
| 504 |
+
menuBtn.addEventListener('click', () => {
|
| 505 |
+
gameOverScreen.classList.add('hidden');
|
| 506 |
+
startScreen.classList.remove('hidden');
|
| 507 |
+
});
|
| 508 |
+
|
| 509 |
+
// Изменение скорости
|
| 510 |
+
speedSelect.addEventListener('change', () => {
|
| 511 |
+
gameSpeed = parseInt(speedSelect.value);
|
| 512 |
+
|
| 513 |
+
if (gameLoop) {
|
| 514 |
+
clearInterval(gameLoop);
|
| 515 |
+
gameLoop = setInterval(gameUpdate, gameSpeed);
|
| 516 |
+
}
|
| 517 |
+
});
|
| 518 |
+
|
| 519 |
+
// Изменение цвета змейки
|
| 520 |
+
colorButtons.forEach(button => {
|
| 521 |
+
button.addEventListener('click', () => {
|
| 522 |
+
snakeColor = button.dataset.color;
|
| 523 |
+
|
| 524 |
+
// Удаляем активный класс у всех кнопок
|
| 525 |
+
colorButtons.forEach(btn => {
|
| 526 |
+
btn.classList.remove('border-2', 'border-white');
|
| 527 |
+
});
|
| 528 |
+
|
| 529 |
+
// Добавляем активный класс к выбранной кнопке
|
| 530 |
+
button.classList.add('border-2', 'border-white');
|
| 531 |
+
});
|
| 532 |
+
});
|
| 533 |
+
|
| 534 |
+
// Адаптация к изменению размеров окна
|
| 535 |
+
window.addEventListener('resize', () => {
|
| 536 |
+
canvas.width = canvas.offsetWidth;
|
| 537 |
+
canvas.height = canvas.offsetHeight;
|
| 538 |
+
|
| 539 |
+
// Пересчитываем количество клеток
|
| 540 |
+
tileCountX = Math.floor(canvas.width / gridSize);
|
| 541 |
+
tileCountY = Math.floor(canvas.height / gridSize);
|
| 542 |
+
|
| 543 |
+
// Перерисовываем игру
|
| 544 |
+
drawGame();
|
| 545 |
+
});
|
| 546 |
+
|
| 547 |
+
// Сенсорное управление для мобильных устройств
|
| 548 |
+
let touchStartX = 0;
|
| 549 |
+
let touchStartY = 0;
|
| 550 |
+
|
| 551 |
+
canvas.addEventListener('touchstart', (e) => {
|
| 552 |
+
touchStartX = e.touches[0].clientX;
|
| 553 |
+
touchStartY = e.touches[0].clientY;
|
| 554 |
+
}, false);
|
| 555 |
+
|
| 556 |
+
canvas.addEventListener('touchmove', (e) => {
|
| 557 |
+
if (!touchStartX || !touchStartY) return;
|
| 558 |
+
|
| 559 |
+
const touchEndX = e.touches[0].clientX;
|
| 560 |
+
const touchEndY = e.touches[0].clientY;
|
| 561 |
+
|
| 562 |
+
const diffX = touchStartX - touchEndX;
|
| 563 |
+
const diffY = touchStartY - touchEndY;
|
| 564 |
+
|
| 565 |
+
if (Math.abs(diffX) > Math.abs(diffY)) {
|
| 566 |
+
// Горизонтальный свайп
|
| 567 |
+
if (diffX > 0 && direction !== 'right') {
|
| 568 |
+
nextDirection = 'left';
|
| 569 |
+
} else if (diffX < 0 && direction !== 'left') {
|
| 570 |
+
nextDirection = 'right';
|
| 571 |
+
}
|
| 572 |
+
} else {
|
| 573 |
+
// Вертикальный свайп
|
| 574 |
+
if (diffY > 0 && direction !== 'down') {
|
| 575 |
+
nextDirection = 'up';
|
| 576 |
+
} else if (diffY < 0 && direction !== 'up') {
|
| 577 |
+
nextDirection = 'down';
|
| 578 |
+
}
|
| 579 |
+
}
|
| 580 |
+
|
| 581 |
+
touchStartX = 0;
|
| 582 |
+
touchStartY = 0;
|
| 583 |
+
e.preventDefault();
|
| 584 |
+
});
|
| 585 |
+
});
|
| 586 |
+
</script>
|
| 587 |
+
<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=aktaevaktan/games" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
|
| 588 |
+
</html>
|
prompts.txt
ADDED
|
File without changes
|