Tingchenliang commited on
Commit
716e188
·
verified ·
1 Parent(s): 09160f2

Add 2 files

Browse files
Files changed (2) hide show
  1. README.md +6 -4
  2. index.html +446 -19
README.md CHANGED
@@ -1,10 +1,12 @@
1
  ---
2
- title: Pilot Game
3
- emoji: 🏃
4
  colorFrom: blue
5
- colorTo: purple
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: pilot-game
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,446 @@
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="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Sky Pilot Adventure</title>
7
+ <script src="https://cdn.tailwindcss.com"></script>
8
+ <style>
9
+ @import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');
10
+
11
+ body {
12
+ font-family: 'Press Start 2P', cursive;
13
+ overflow: hidden;
14
+ background: linear-gradient(to bottom, #1a2980, #26d0ce);
15
+ height: 100vh;
16
+ margin: 0;
17
+ user-select: none;
18
+ }
19
+
20
+ #game-container {
21
+ position: relative;
22
+ width: 100%;
23
+ height: 100%;
24
+ overflow: hidden;
25
+ }
26
+
27
+ #plane {
28
+ position: absolute;
29
+ width: 60px;
30
+ height: 60px;
31
+ transition: transform 0.1s ease-out;
32
+ z-index: 10;
33
+ }
34
+
35
+ .cloud {
36
+ position: absolute;
37
+ background-color: white;
38
+ border-radius: 50%;
39
+ opacity: 0.8;
40
+ }
41
+
42
+ .star {
43
+ position: absolute;
44
+ width: 30px;
45
+ height: 30px;
46
+ background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="gold"><path d="M12 17.27L18.18 21l-1.64-7.03L22 9.24l-7.19-.61L12 2 9.19 8.63 2 9.24l5.46 4.73L5.82 21z"/></svg>');
47
+ background-size: contain;
48
+ z-index: 5;
49
+ animation: twinkle 1s infinite alternate;
50
+ }
51
+
52
+ @keyframes twinkle {
53
+ from { opacity: 0.7; transform: scale(0.9); }
54
+ to { opacity: 1; transform: scale(1.1); }
55
+ }
56
+
57
+ #game-over {
58
+ position: absolute;
59
+ top: 0;
60
+ left: 0;
61
+ width: 100%;
62
+ height: 100%;
63
+ background-color: rgba(0, 0, 0, 0.7);
64
+ display: none;
65
+ flex-direction: column;
66
+ justify-content: center;
67
+ align-items: center;
68
+ z-index: 100;
69
+ }
70
+
71
+ #start-screen {
72
+ position: absolute;
73
+ top: 0;
74
+ left: 0;
75
+ width: 100%;
76
+ height: 100%;
77
+ display: flex;
78
+ flex-direction: column;
79
+ justify-content: center;
80
+ align-items: center;
81
+ z-index: 100;
82
+ background: linear-gradient(to bottom, #1a2980, #26d0ce);
83
+ }
84
+
85
+ .title {
86
+ font-size: 3rem;
87
+ color: white;
88
+ text-shadow: 4px 4px 0px rgba(0, 0, 0, 0.5);
89
+ margin-bottom: 2rem;
90
+ animation: float 3s ease-in-out infinite;
91
+ }
92
+
93
+ @keyframes float {
94
+ 0% { transform: translateY(0px); }
95
+ 50% { transform: translateY(-20px); }
96
+ 100% { transform: translateY(0px); }
97
+ }
98
+
99
+ .btn {
100
+ background-color: #FFD700;
101
+ color: #1a2980;
102
+ border: none;
103
+ padding: 15px 30px;
104
+ font-size: 1.2rem;
105
+ font-family: 'Press Start 2P', cursive;
106
+ cursor: pointer;
107
+ border-radius: 10px;
108
+ box-shadow: 0 5px 0 #b8860b;
109
+ transition: all 0.1s;
110
+ margin: 10px;
111
+ }
112
+
113
+ .btn:hover {
114
+ background-color: #FFC000;
115
+ }
116
+
117
+ .btn:active {
118
+ transform: translateY(5px);
119
+ box-shadow: 0 0px 0 #b8860b;
120
+ }
121
+
122
+ .score-display {
123
+ position: absolute;
124
+ top: 20px;
125
+ left: 20px;
126
+ color: white;
127
+ font-size: 1.2rem;
128
+ text-shadow: 2px 2px 0px rgba(0, 0, 0, 0.5);
129
+ z-index: 50;
130
+ }
131
+ </style>
132
+ </head>
133
+ <body>
134
+ <div id="start-screen">
135
+ <h1 class="title">SKY PILOT ADVENTURE</h1>
136
+ <button id="start-btn" class="btn">START GAME</button>
137
+ <div class="mt-8 text-white text-center">
138
+ <p>Use mouse or touch to control the plane</p>
139
+ <p>Avoid clouds and collect stars!</p>
140
+ </div>
141
+ </div>
142
+
143
+ <div id="game-container">
144
+ <div class="score-display">
145
+ Score: <span id="score">0</span> |
146
+ High Score: <span id="high-score">0</span>
147
+ </div>
148
+ <img id="plane" src="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23FFD700'><path d='M22 16.21v-1.895L14 8V4a2 2 0 0 0-4 0v4l-8 6.315v1.895l8-2.526V18l-2 2v2l3.5-1 3.5 1v-2l-2-2v-4.316l8 2.526z'/></svg>" alt="Plane">
149
+
150
+ <div id="game-over">
151
+ <h1 class="text-4xl text-white mb-8">GAME OVER</h1>
152
+ <p class="text-2xl text-yellow-300 mb-8">Your Score: <span id="final-score">0</span></p>
153
+ <button id="restart-btn" class="btn">PLAY AGAIN</button>
154
+ </div>
155
+ </div>
156
+
157
+ <script>
158
+ // Game variables
159
+ let score = 0;
160
+ let highScore = localStorage.getItem('highScore') || 0;
161
+ let gameRunning = false;
162
+ let gameSpeed = 3;
163
+ let planeX = 50;
164
+ let planeY = 50;
165
+ let planeElement = document.getElementById('plane');
166
+ let gameContainer = document.getElementById('game-container');
167
+ let scoreElement = document.getElementById('score');
168
+ let highScoreElement = document.getElementById('highScore');
169
+ let finalScoreElement = document.getElementById('final-score');
170
+ let gameOverScreen = document.getElementById('game-over');
171
+ let startScreen = document.getElementById('start-screen');
172
+ let clouds = [];
173
+ let stars = [];
174
+ let animationId;
175
+
176
+ // Initialize game
177
+ function init() {
178
+ // Set high score display
179
+ document.getElementById('high-score').textContent = highScore;
180
+
181
+ // Event listeners
182
+ document.getElementById('start-btn').addEventListener('click', startGame);
183
+ document.getElementById('restart-btn').addEventListener('click', restartGame);
184
+
185
+ // Touch/mouse controls
186
+ gameContainer.addEventListener('mousemove', movePlane);
187
+ gameContainer.addEventListener('touchmove', function(e) {
188
+ e.preventDefault();
189
+ movePlane(e.touches[0]);
190
+ });
191
+ }
192
+
193
+ // Start game
194
+ function startGame() {
195
+ startScreen.style.display = 'none';
196
+ gameRunning = true;
197
+ score = 0;
198
+ gameSpeed = 3;
199
+ updateScore();
200
+
201
+ // Position plane in center
202
+ planeX = gameContainer.clientWidth / 2;
203
+ planeY = gameContainer.clientHeight / 2;
204
+ updatePlanePosition();
205
+
206
+ // Clear any existing elements
207
+ clearGameElements();
208
+
209
+ // Start game loop
210
+ gameLoop();
211
+
212
+ // Start spawning obstacles and stars
213
+ setInterval(spawnCloud, 1500);
214
+ setInterval(spawnStar, 2000);
215
+ }
216
+
217
+ // Game loop
218
+ function gameLoop() {
219
+ if (!gameRunning) return;
220
+
221
+ // Move clouds
222
+ moveClouds();
223
+
224
+ // Move stars
225
+ moveStars();
226
+
227
+ // Check collisions
228
+ checkCollisions();
229
+
230
+ // Increase difficulty over time
231
+ if (score > 0 && score % 10 === 0) {
232
+ gameSpeed = 3 + Math.floor(score / 10) * 0.5;
233
+ }
234
+
235
+ animationId = requestAnimationFrame(gameLoop);
236
+ }
237
+
238
+ // Move plane with mouse/touch
239
+ function movePlane(e) {
240
+ if (!gameRunning) return;
241
+
242
+ const rect = gameContainer.getBoundingClientRect();
243
+ planeX = e.clientX - rect.left;
244
+ planeY = e.clientY - rect.top;
245
+
246
+ // Keep plane within bounds
247
+ planeX = Math.max(30, Math.min(planeX, gameContainer.clientWidth - 30));
248
+ planeY = Math.max(30, Math.min(planeY, gameContainer.clientHeight - 30));
249
+
250
+ updatePlanePosition();
251
+ }
252
+
253
+ // Update plane position on screen
254
+ function updatePlanePosition() {
255
+ planeElement.style.left = (planeX - 30) + 'px';
256
+ planeElement.style.top = (planeY - 30) + 'px';
257
+
258
+ // Tilt plane based on movement direction
259
+ // (This would be more sophisticated with velocity tracking)
260
+ const tilt = ((planeX / gameContainer.clientWidth) - 0.5) * 30;
261
+ planeElement.style.transform = `rotate(${tilt}deg)`;
262
+ }
263
+
264
+ // Spawn a new cloud
265
+ function spawnCloud() {
266
+ if (!gameRunning) return;
267
+
268
+ const cloud = document.createElement('div');
269
+ cloud.className = 'cloud';
270
+
271
+ // Random size
272
+ const size = Math.random() * 60 + 40;
273
+ cloud.style.width = size + 'px';
274
+ cloud.style.height = size + 'px';
275
+
276
+ // Random position (off screen to the right)
277
+ const yPos = Math.random() * (gameContainer.clientHeight - size);
278
+ cloud.style.left = gameContainer.clientWidth + 'px';
279
+ cloud.style.top = yPos + 'px';
280
+
281
+ gameContainer.appendChild(cloud);
282
+ clouds.push({
283
+ element: cloud,
284
+ x: gameContainer.clientWidth,
285
+ y: yPos,
286
+ width: size,
287
+ height: size,
288
+ speed: Math.random() * 2 + gameSpeed
289
+ });
290
+ }
291
+
292
+ // Move all clouds
293
+ function moveClouds() {
294
+ for (let i = clouds.length - 1; i >= 0; i--) {
295
+ const cloud = clouds[i];
296
+ cloud.x -= cloud.speed;
297
+ cloud.element.style.left = cloud.x + 'px';
298
+
299
+ // Remove if off screen
300
+ if (cloud.x + cloud.width < 0) {
301
+ gameContainer.removeChild(cloud.element);
302
+ clouds.splice(i, 1);
303
+ }
304
+ }
305
+ }
306
+
307
+ // Spawn a new star
308
+ function spawnStar() {
309
+ if (!gameRunning) return;
310
+
311
+ const star = document.createElement('div');
312
+ star.className = 'star';
313
+
314
+ // Random position (off screen to the right)
315
+ const yPos = Math.random() * (gameContainer.clientHeight - 30);
316
+ star.style.left = gameContainer.clientWidth + 'px';
317
+ star.style.top = yPos + 'px';
318
+
319
+ gameContainer.appendChild(star);
320
+ stars.push({
321
+ element: star,
322
+ x: gameContainer.clientWidth,
323
+ y: yPos,
324
+ width: 30,
325
+ height: 30,
326
+ speed: gameSpeed + 1
327
+ });
328
+ }
329
+
330
+ // Move all stars
331
+ function moveStars() {
332
+ for (let i = stars.length - 1; i >= 0; i--) {
333
+ const star = stars[i];
334
+ star.x -= star.speed;
335
+ star.element.style.left = star.x + 'px';
336
+
337
+ // Remove if off screen
338
+ if (star.x + star.width < 0) {
339
+ gameContainer.removeChild(star.element);
340
+ stars.splice(i, 1);
341
+ }
342
+ }
343
+ }
344
+
345
+ // Check for collisions
346
+ function checkCollisions() {
347
+ // Plane dimensions
348
+ const planeSize = 40;
349
+ const planeLeft = planeX - planeSize/2;
350
+ const planeRight = planeX + planeSize/2;
351
+ const planeTop = planeY - planeSize/2;
352
+ const planeBottom = planeY + planeSize/2;
353
+
354
+ // Check cloud collisions
355
+ for (const cloud of clouds) {
356
+ if (planeRight > cloud.x &&
357
+ planeLeft < cloud.x + cloud.width &&
358
+ planeBottom > cloud.y &&
359
+ planeTop < cloud.y + cloud.height) {
360
+ gameOver();
361
+ return;
362
+ }
363
+ }
364
+
365
+ // Check star collisions
366
+ for (let i = stars.length - 1; i >= 0; i--) {
367
+ const star = stars[i];
368
+ if (planeRight > star.x &&
369
+ planeLeft < star.x + star.width &&
370
+ planeBottom > star.y &&
371
+ planeTop < star.y + star.height) {
372
+ // Collect star
373
+ gameContainer.removeChild(star.element);
374
+ stars.splice(i, 1);
375
+ score += 5;
376
+ updateScore();
377
+
378
+ // Play sound
379
+ playSound('collect');
380
+ }
381
+ }
382
+ }
383
+
384
+ // Update score display
385
+ function updateScore() {
386
+ scoreElement.textContent = score;
387
+ }
388
+
389
+ // Game over
390
+ function gameOver() {
391
+ gameRunning = false;
392
+ cancelAnimationFrame(animationId);
393
+
394
+ // Update high score
395
+ if (score > highScore) {
396
+ highScore = score;
397
+ localStorage.setItem('highScore', highScore);
398
+ document.getElementById('high-score').textContent = highScore;
399
+ }
400
+
401
+ // Show game over screen
402
+ finalScoreElement.textContent = score;
403
+ gameOverScreen.style.display = 'flex';
404
+
405
+ // Play sound
406
+ playSound('crash');
407
+ }
408
+
409
+ // Restart game
410
+ function restartGame() {
411
+ gameOverScreen.style.display = 'none';
412
+ startGame();
413
+ }
414
+
415
+ // Clear game elements
416
+ function clearGameElements() {
417
+ // Remove all clouds
418
+ for (const cloud of clouds) {
419
+ gameContainer.removeChild(cloud.element);
420
+ }
421
+ clouds = [];
422
+
423
+ // Remove all stars
424
+ for (const star of stars) {
425
+ gameContainer.removeChild(star.element);
426
+ }
427
+ stars = [];
428
+ }
429
+
430
+ // Simple sound effects
431
+ function playSound(type) {
432
+ const audio = new Audio();
433
+ if (type === 'collect') {
434
+ audio.src = 'data:audio/wav;base64,UklGRl9vT19XQVZFZm10IBAAAAABAAEAQB8AAEAfAAABAAgAZGF0YU...'; // Short beep
435
+ } else if (type === 'crash') {
436
+ audio.src = 'data:audio/wav;base64,UklGRl9vT19XQVZFZm10IBAAAAABAAEAQB8AAEAfAAABAAgAZGF0YU...'; // Crash sound
437
+ }
438
+ audio.volume = 0.2;
439
+ audio.play().catch(e => console.log("Audio play failed:", e));
440
+ }
441
+
442
+ // Initialize when loaded
443
+ window.addEventListener('load', init);
444
+ </script>
445
+ <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=Tingchenliang/pilot-game" style="color: #fff;text-decoration: underline;" target="_blank" >🧬 Remix</a></p></body>
446
+ </html>