Dremmar commited on
Commit
51e7e1f
·
verified ·
1 Parent(s): a8e8506

Add 2 files

Browse files
Files changed (2) hide show
  1. README.md +7 -5
  2. index.html +468 -19
README.md CHANGED
@@ -1,10 +1,12 @@
1
  ---
2
- title: Flap Borb
3
- emoji: 🐨
4
- colorFrom: indigo
5
- colorTo: pink
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: flap-borb
3
+ emoji: 🐳
4
+ colorFrom: blue
5
+ colorTo: blue
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,468 @@
1
- <!doctype html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8" />
5
- <meta name="viewport" content="width=device-width" />
6
- <title>My static Space</title>
7
- <link rel="stylesheet" href="style.css" />
8
- </head>
9
- <body>
10
- <div class="card">
11
- <h1>Welcome to your static Space!</h1>
12
- <p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p>
13
- <p>
14
- Also don't forget to check the
15
- <a href="https://huggingface.co/docs/hub/spaces" target="_blank">Spaces documentation</a>.
16
- </p>
17
- </div>
18
- </body>
19
- </html>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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>Flappy Bird</title>
7
+ <script src="https://cdn.tailwindcss.com"></script>
8
+ <style>
9
+ #game-container {
10
+ position: relative;
11
+ width: 400px;
12
+ height: 600px;
13
+ overflow: hidden;
14
+ background: linear-gradient(#87CEEB, #E0F7FA);
15
+ border-radius: 10px;
16
+ box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
17
+ }
18
+
19
+ #bird {
20
+ position: absolute;
21
+ width: 40px;
22
+ height: 30px;
23
+ background-color: #FFD700;
24
+ border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
25
+ left: 50px;
26
+ z-index: 10;
27
+ transition: transform 0.3s;
28
+ }
29
+
30
+ .pipe {
31
+ position: absolute;
32
+ width: 60px;
33
+ background-color: #4CAF50;
34
+ border: 3px solid #2E7D32;
35
+ border-radius: 5px;
36
+ right: -60px;
37
+ }
38
+
39
+ .pipe-top {
40
+ top: 0;
41
+ border-bottom: none;
42
+ border-radius: 5px 5px 0 0;
43
+ }
44
+
45
+ .pipe-bottom {
46
+ bottom: 0;
47
+ border-top: none;
48
+ border-radius: 0 0 5px 5px;
49
+ }
50
+
51
+ .cloud {
52
+ position: absolute;
53
+ background-color: rgba(255, 255, 255, 0.8);
54
+ border-radius: 50%;
55
+ filter: blur(5px);
56
+ }
57
+
58
+ #ground {
59
+ position: absolute;
60
+ width: 100%;
61
+ height: 30px;
62
+ background-color: #8BC34A;
63
+ bottom: 0;
64
+ border-top: 3px solid #689F38;
65
+ z-index: 20;
66
+ }
67
+
68
+ #score-display {
69
+ position: absolute;
70
+ top: 20px;
71
+ left: 0;
72
+ right: 0;
73
+ text-align: center;
74
+ font-size: 30px;
75
+ font-weight: bold;
76
+ color: white;
77
+ text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
78
+ z-index: 30;
79
+ }
80
+
81
+ #game-over {
82
+ position: absolute;
83
+ top: 0;
84
+ left: 0;
85
+ right: 0;
86
+ bottom: 0;
87
+ background-color: rgba(0, 0, 0, 0.7);
88
+ display: flex;
89
+ flex-direction: column;
90
+ justify-content: center;
91
+ align-items: center;
92
+ z-index: 40;
93
+ display: none;
94
+ }
95
+
96
+ #start-screen {
97
+ position: absolute;
98
+ top: 0;
99
+ left: 0;
100
+ right: 0;
101
+ bottom: 0;
102
+ background-color: rgba(0, 0, 0, 0.3);
103
+ display: flex;
104
+ flex-direction: column;
105
+ justify-content: center;
106
+ align-items: center;
107
+ z-index: 50;
108
+ }
109
+
110
+ @keyframes flap {
111
+ 0% { transform: rotate(0deg) translateY(0); }
112
+ 50% { transform: rotate(0deg) translateY(-5px); }
113
+ 100% { transform: rotate(0deg) translateY(0); }
114
+ }
115
+
116
+ .flap-animation {
117
+ animation: flap 0.3s ease-out;
118
+ }
119
+
120
+ .beak {
121
+ position: absolute;
122
+ width: 10px;
123
+ height: 10px;
124
+ background-color: #FF9800;
125
+ top: 10px;
126
+ right: -5px;
127
+ border-radius: 50% 0 0 50%;
128
+ }
129
+
130
+ .eye {
131
+ position: absolute;
132
+ width: 8px;
133
+ height: 8px;
134
+ background-color: black;
135
+ border-radius: 50%;
136
+ top: 8px;
137
+ right: 8px;
138
+ }
139
+ </style>
140
+ </head>
141
+ <body class="bg-gray-100 min-h-screen flex flex-col items-center justify-center p-4">
142
+ <div class="text-center mb-4">
143
+ <h1 class="text-3xl font-bold text-gray-800">Flappy Bird</h1>
144
+ <p class="text-gray-600 mt-2">Нажмите пробел, кликните или коснитесь экрана, чтобы прыгнуть</p>
145
+ </div>
146
+
147
+ <div id="game-container" class="relative">
148
+ <div id="bird">
149
+ <div class="beak"></div>
150
+ <div class="eye"></div>
151
+ </div>
152
+ <div id="ground"></div>
153
+ <div id="score-display">0</div>
154
+
155
+ <div id="game-over">
156
+ <div class="bg-white p-6 rounded-lg text-center">
157
+ <h2 class="text-2xl font-bold text-red-500 mb-2">Игра окончена!</h2>
158
+ <p id="final-score" class="text-xl font-semibold mb-4">Счет: 0</p>
159
+ <button id="restart-btn" class="px-6 py-3 bg-blue-500 hover:bg-blue-600 text-white rounded-lg font-semibold transition">
160
+ Играть снова
161
+ </button>
162
+ </div>
163
+ </div>
164
+
165
+ <div id="start-screen">
166
+ <div class="bg-white p-6 rounded-lg text-center">
167
+ <h2 class="text-2xl font-bold text-blue-500 mb-4">Flappy Bird</h2>
168
+ <button id="start-btn" class="px-6 py-3 bg-green-500 hover:bg-green-600 text-white rounded-lg font-semibold transition">
169
+ Начать игру
170
+ </button>
171
+ </div>
172
+ </div>
173
+ </div>
174
+
175
+ <div class="mt-6 text-gray-600 text-sm">
176
+ <p>Летящая птица автоматически падает вниз. Кликайте по экрану, чтобы она взлетала вверх.</p>
177
+ <p>Избегайте труб и земли, старайтесь набрать максимальное количество очков.</p>
178
+ </div>
179
+
180
+ <script>
181
+ document.addEventListener('DOMContentLoaded', () => {
182
+ // Элементы игры
183
+ const gameContainer = document.getElementById('game-container');
184
+ const bird = document.getElementById('bird');
185
+ const scoreDisplay = document.getElementById('score-display');
186
+ const gameOverScreen = document.getElementById('game-over');
187
+ const finalScoreDisplay = document.getElementById('final-score');
188
+ const restartBtn = document.getElementById('restart-btn');
189
+ const startScreen = document.getElementById('start-screen');
190
+ const startBtn = document.getElementById('start-btn');
191
+
192
+ // Размеры игры
193
+ const gameWidth = gameContainer.offsetWidth;
194
+ const gameHeight = gameContainer.offsetHeight;
195
+ const groundHeight = 30;
196
+
197
+ // Состояние игры
198
+ let gameStarted = false;
199
+ let gameOver = false;
200
+ let score = 0;
201
+ let gravity = 0.5;
202
+ let birdVelocity = 0;
203
+ let birdPosition = gameHeight / 2;
204
+ let pipes = [];
205
+ let clouds = [];
206
+ let pipeGap = 150;
207
+ let pipeFrequency = 2000; // мс
208
+ let lastPipeTime = 0;
209
+ let animationId;
210
+ let gameSpeed = 2;
211
+
212
+ // Инициализация игры
213
+ function init() {
214
+ // Создаем несколько облаков в начале
215
+ for (let i = 0; i < 3; i++) {
216
+ createCloud(i * (gameWidth / 3) + Math.random() * 100);
217
+ }
218
+
219
+ // Устанавливаем начальную позицию птицы
220
+ bird.style.top = `${birdPosition}px`;
221
+
222
+ // Скрываем экран завершения игры
223
+ gameOverScreen.style.display = 'none';
224
+
225
+ // Показываем начальный экран
226
+ startScreen.style.display = 'flex';
227
+ }
228
+
229
+ // Создание облака
230
+ function createCloud(x) {
231
+ const cloud = {
232
+ x: x,
233
+ y: Math.random() * (gameHeight / 3),
234
+ width: 60 + Math.random() * 40,
235
+ height: 30 + Math.random() * 20,
236
+ speed: 0.5 + Math.random() * 0.5
237
+ };
238
+
239
+ clouds.push(cloud);
240
+
241
+ // Создаем DOM-элемент облака
242
+ const cloudElement = document.createElement('div');
243
+ cloudElement.className = 'cloud';
244
+ cloudElement.style.left = `${cloud.x}px`;
245
+ cloudElement.style.top = `${cloud.y}px`;
246
+ cloudElement.style.width = `${cloud.width}px`;
247
+ cloudElement.style.height = `${cloud.height}px`;
248
+ gameContainer.appendChild(cloudElement);
249
+
250
+ cloud.element = cloudElement;
251
+ }
252
+
253
+ // Создание труб
254
+ function createPipe() {
255
+ const pipeHeight = Math.floor(Math.random() * (gameHeight - groundHeight - pipeGap - 100)) + 50;
256
+
257
+ // Верхняя труба
258
+ const topPipe = document.createElement('div');
259
+ topPipe.className = 'pipe pipe-top';
260
+ topPipe.style.height = `${pipeHeight}px`;
261
+ gameContainer.appendChild(topPipe);
262
+
263
+ // Нижняя труба
264
+ const bottomPipe = document.createElement('div');
265
+ bottomPipe.className = 'pipe pipe-bottom';
266
+ bottomPipe.style.height = `${gameHeight - pipeHeight - pipeGap - groundHeight}px`;
267
+ gameContainer.appendChild(bottomPipe);
268
+
269
+ pipes.push({
270
+ top: topPipe,
271
+ bottom: bottomPipe,
272
+ x: gameWidth,
273
+ topHeight: pipeHeight,
274
+ bottomHeight: gameHeight - pipeHeight - pipeGap - groundHeight,
275
+ passed: false
276
+ });
277
+ }
278
+
279
+ // Движение птицы
280
+ function moveBird() {
281
+ birdVelocity += gravity;
282
+ birdPosition += birdVelocity;
283
+
284
+ // Ограничиваем положение птицы
285
+ if (birdPosition < 0) {
286
+ birdPosition = 0;
287
+ birdVelocity = 0;
288
+ }
289
+
290
+ // Птица ударилась о землю
291
+ if (birdPosition > gameHeight - groundHeight - bird.offsetHeight) {
292
+ birdPosition = gameHeight - groundHeight - bird.offsetHeight;
293
+ endGame();
294
+ }
295
+
296
+ // Применяем положение и поворот
297
+ bird.style.top = `${birdPosition}px`;
298
+ bird.style.transform = `rotate(${birdVelocity * 5}deg)`;
299
+ }
300
+
301
+ // Движение труб
302
+ function movePipes() {
303
+ const now = Date.now();
304
+
305
+ // Создаем новые трубы с интервалом
306
+ if (now - lastPipeTime > pipeFrequency && pipes.length < 4) {
307
+ createPipe();
308
+ lastPipeTime = now;
309
+
310
+ // Постепенно увеличиваем сложность
311
+ if (score > 0 && score % 5 === 0) {
312
+ pipeFrequency = Math.max(1000, pipeFrequency - 50);
313
+ gameSpeed = Math.min(5, gameSpeed + 0.1);
314
+ }
315
+ }
316
+
317
+ // Удаляем трубы за пределами экрана
318
+ pipes = pipes.filter(pipe => {
319
+ pipe.x -= gameSpeed;
320
+
321
+ pipe.top.style.left = `${pipe.x}px`;
322
+ pipe.bottom.style.left = `${pipe.x}px`;
323
+
324
+ // Проверка столкновения
325
+ if (
326
+ (birdPosition < pipe.topHeight &&
327
+ bird.offsetLeft + bird.offsetWidth > pipe.x &&
328
+ bird.offsetLeft < pipe.x + pipe.top.offsetWidth) ||
329
+ (birdPosition + bird.offsetHeight > gameHeight - pipe.bottomHeight - groundHeight &&
330
+ bird.offsetLeft + bird.offsetWidth > pipe.x &&
331
+ bird.offsetLeft < pipe.x + pipe.bottom.offsetWidth)
332
+ ) {
333
+ endGame();
334
+ }
335
+
336
+ // Начисление очков за пролет между трубами
337
+ if (!pipe.passed && pipe.x + pipe.top.offsetWidth < bird.offsetLeft) {
338
+ pipe.passed = true;
339
+ updateScore();
340
+ }
341
+
342
+ // Удаляем трубы за пределами экрана
343
+ if (pipe.x < -pipe.top.offsetWidth) {
344
+ gameContainer.removeChild(pipe.top);
345
+ gameContainer.removeChild(pipe.bottom);
346
+ return false;
347
+ }
348
+
349
+ return true;
350
+ });
351
+ }
352
+
353
+ // Движение облаков
354
+ function moveClouds() {
355
+ clouds.forEach(cloud => {
356
+ cloud.x -= cloud.speed;
357
+ cloud.element.style.left = `${cloud.x}px`;
358
+
359
+ // Перемещаем облако в начало при выходе за границы
360
+ if (cloud.x + cloud.width < 0) {
361
+ cloud.x = gameWidth;
362
+ cloud.y = Math.random() * (gameHeight / 3);
363
+ cloud.element.style.left = `${cloud.x}px`;
364
+ cloud.element.style.top = `${cloud.y}px`;
365
+ }
366
+ });
367
+
368
+ // Добавляем новые облака, если их мало
369
+ if (clouds.length < 5 && Math.random() < 0.01) {
370
+ createCloud(gameWidth);
371
+ }
372
+ }
373
+
374
+ // Обновление счета
375
+ function updateScore() {
376
+ score++;
377
+ scoreDisplay.textContent = score;
378
+ }
379
+
380
+ // Прыжок птицы
381
+ function jump() {
382
+ if (!gameStarted || gameOver) return;
383
+
384
+ birdVelocity = -8;
385
+ bird.classList.add('flap-animation');
386
+
387
+ // Убираем анимацию после завершения
388
+ setTimeout(() => {
389
+ bird.classList.remove('flap-animation');
390
+ }, 300);
391
+ }
392
+
393
+ // Завершение игры
394
+ function endGame() {
395
+ gameOver = true;
396
+ cancelAnimationFrame(animationId);
397
+
398
+ // Показываем экран завершения игры
399
+ finalScoreDisplay.textContent = `Счет: ${score}`;
400
+ gameOverScreen.style.display = 'flex';
401
+ }
402
+
403
+ // Начало игры
404
+ function startGame() {
405
+ // Сбрасываем состояние игры
406
+ gameStarted = true;
407
+ gameOver = false;
408
+ score = 0;
409
+ birdVelocity = 0;
410
+ birdPosition = gameHeight / 2;
411
+ pipes = [];
412
+ gameSpeed = 2;
413
+ pipeFrequency = 2000;
414
+
415
+ // Обновляем отображение
416
+ scoreDisplay.textContent = '0';
417
+ startScreen.style.display = 'none';
418
+ gameOverScreen.style.display = 'none';
419
+
420
+ // Очищаем старые трубы
421
+ document.querySelectorAll('.pipe').forEach(pipe => pipe.remove());
422
+
423
+ // Запускаем игровой цикл
424
+ gameLoop();
425
+ }
426
+
427
+ // Перезапуск игры
428
+ function restartGame() {
429
+ pipes.forEach(pipe => {
430
+ gameContainer.removeChild(pipe.top);
431
+ gameContainer.removeChild(pipe.bottom);
432
+ });
433
+
434
+ startGame();
435
+ }
436
+
437
+ // Основной игровой цикл
438
+ function gameLoop() {
439
+ if (gameOver) return;
440
+
441
+ moveBird();
442
+ movePipes();
443
+ moveClouds();
444
+
445
+ animationId = requestAnimationFrame(gameLoop);
446
+ }
447
+
448
+ // Обработчики событий
449
+ document.addEventListener('keydown', (e) => {
450
+ if (e.code === 'Space') {
451
+ e.preventDefault();
452
+ jump();
453
+ }
454
+ });
455
+
456
+ gameContainer.addEventListener('click', () => {
457
+ jump();
458
+ });
459
+
460
+ startBtn.addEventListener('click', startGame);
461
+ restartBtn.addEventListener('click', restartGame);
462
+
463
+ // Инициализация игры
464
+ init();
465
+ });
466
+ </script>
467
+ <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=Dremmar/flap-borb" style="color: #fff;text-decoration: underline;" target="_blank" >🧬 Remix</a></p></body>
468
+ </html>