FriedsU commited on
Commit
888ef33
·
verified ·
1 Parent(s): ace35c4

Add 2 files

Browse files
Files changed (2) hide show
  1. README.md +7 -5
  2. index.html +687 -19
README.md CHANGED
@@ -1,10 +1,12 @@
1
  ---
2
- title: Space
3
- emoji: 📉
4
- colorFrom: pink
5
- colorTo: green
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: space
3
+ emoji: 🐳
4
+ colorFrom: blue
5
+ colorTo: pink
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,687 @@
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>Galaxy Defender</title>
7
+ <script src="https://cdn.tailwindcss.com"></script>
8
+ <style>
9
+ body {
10
+ overflow: hidden;
11
+ background-color: #000;
12
+ font-family: 'Arial', sans-serif;
13
+ margin: 0;
14
+ padding: 0;
15
+ }
16
+
17
+ #game-container {
18
+ position: relative;
19
+ width: 800px;
20
+ height: 600px;
21
+ margin: 20px auto;
22
+ background: linear-gradient(to bottom, #000033 0%, #000000 100%);
23
+ overflow: hidden;
24
+ }
25
+
26
+ #player {
27
+ position: absolute;
28
+ width: 50px;
29
+ height: 50px;
30
+ background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 50 50"><path d="M25 5 L5 25 L15 25 L15 45 L35 45 L35 25 L45 25 Z" fill="%2300FFFF" stroke="%23FFFFFF" stroke-width="2"/></svg>');
31
+ z-index: 10;
32
+ }
33
+
34
+ .enemy {
35
+ position: absolute;
36
+ width: 40px;
37
+ height: 40px;
38
+ background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 40 40"><path d="M20 5 L5 20 L15 20 L15 35 L25 35 L25 20 L35 20 Z" fill="%23FF0000" stroke="%23FFFFFF" stroke-width="2"/></svg>');
39
+ z-index: 5;
40
+ }
41
+
42
+ .bullet {
43
+ position: absolute;
44
+ width: 5px;
45
+ height: 15px;
46
+ background-color: #FFFF00;
47
+ border-radius: 2px;
48
+ z-index: 8;
49
+ }
50
+
51
+ .explosion {
52
+ position: absolute;
53
+ width: 50px;
54
+ height: 50px;
55
+ background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 50 50"><circle cx="25" cy="25" r="20" fill="%23FF9900"/><circle cx="25" cy="25" r="15" fill="%23FF3300"/><circle cx="25" cy="25" r="10" fill="%23FFFF00"/></svg>');
56
+ z-index: 15;
57
+ animation: explode 0.5s forwards;
58
+ }
59
+
60
+ .powerup {
61
+ position: absolute;
62
+ width: 30px;
63
+ height: 30px;
64
+ background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 30 30"><circle cx="15" cy="15" r="12" fill="%2300FF00" stroke="%23FFFFFF" stroke-width="2"/></svg>');
65
+ z-index: 7;
66
+ animation: pulse 1s infinite alternate;
67
+ }
68
+
69
+ .star {
70
+ position: absolute;
71
+ background-color: white;
72
+ border-radius: 50%;
73
+ z-index: 1;
74
+ }
75
+
76
+ #score-display {
77
+ position: absolute;
78
+ top: 10px;
79
+ left: 10px;
80
+ font-size: 20px;
81
+ color: white;
82
+ text-shadow: 0 0 5px #00FFFF;
83
+ z-index: 20;
84
+ }
85
+
86
+ #health-display {
87
+ position: absolute;
88
+ top: 10px;
89
+ right: 10px;
90
+ font-size: 20px;
91
+ color: white;
92
+ text-shadow: 0 0 5px #FF0000;
93
+ z-index: 20;
94
+ }
95
+
96
+ #level-complete {
97
+ position: absolute;
98
+ top: 50%;
99
+ left: 50%;
100
+ transform: translate(-50%, -50%);
101
+ background-color: rgba(0, 0, 0, 0.8);
102
+ color: #00FF00;
103
+ padding: 30px;
104
+ border-radius: 15px;
105
+ text-align: center;
106
+ display: none;
107
+ z-index: 100;
108
+ font-size: 24px;
109
+ border: 2px solid #00FF00;
110
+ box-shadow: 0 0 20px #00FF00;
111
+ }
112
+
113
+ #game-over {
114
+ position: absolute;
115
+ top: 50%;
116
+ left: 50%;
117
+ transform: translate(-50%, -50%);
118
+ background-color: rgba(0, 0, 0, 0.8);
119
+ color: #FF0000;
120
+ padding: 30px;
121
+ border-radius: 15px;
122
+ text-align: center;
123
+ display: none;
124
+ z-index: 100;
125
+ font-size: 24px;
126
+ border: 2px solid #FF0000;
127
+ box-shadow: 0 0 20px #FF0000;
128
+ }
129
+
130
+ #restart-btn {
131
+ background: linear-gradient(to bottom, #FF3300 0%, #990000 100%);
132
+ color: white;
133
+ border: none;
134
+ padding: 10px 20px;
135
+ margin-top: 20px;
136
+ border-radius: 5px;
137
+ cursor: pointer;
138
+ font-size: 18px;
139
+ text-shadow: 0 0 5px #000;
140
+ }
141
+
142
+ #restart-btn:hover {
143
+ background: linear-gradient(to bottom, #FF5500 0%, #BB0000 100%);
144
+ }
145
+
146
+ @keyframes explode {
147
+ 0% { transform: scale(0.5); opacity: 1; }
148
+ 100% { transform: scale(2); opacity: 0; }
149
+ }
150
+
151
+ @keyframes pulse {
152
+ 0% { transform: scale(1); }
153
+ 100% { transform: scale(1.2); }
154
+ }
155
+
156
+ #boss {
157
+ position: absolute;
158
+ width: 80px;
159
+ height: 80px;
160
+ background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 80 80"><path d="M40 10 L10 40 L30 40 L30 70 L50 70 L50 40 L70 40 Z" fill="%23FF00FF" stroke="%23FFFFFF" stroke-width="3"/></svg>');
161
+ z-index: 6;
162
+ }
163
+ </style>
164
+ </head>
165
+ <body class="flex flex-col items-center justify-center min-h-screen bg-black">
166
+ <h1 class="text-4xl font-bold mb-4 text-blue-400 text-center" style="text-shadow: 0 0 10px #00FFFF;">GALAXY DEFENDER</h1>
167
+
168
+ <div id="game-container">
169
+ <div id="player"></div>
170
+ <div id="score-display">SCORE: 0</div>
171
+ <div id="health-display">HEALTH: 100%</div>
172
+
173
+ <div id="level-complete">
174
+ <h2 class="text-3xl font-bold mb-4">LEVEL COMPLETE!</h2>
175
+ <p id="final-score">Your score: 0</p>
176
+ <button id="restart-btn">Play Again</button>
177
+ </div>
178
+
179
+ <div id="game-over">
180
+ <h2 class="text-3xl font-bold mb-4">GAME OVER</h2>
181
+ <p id="game-over-score">Your score: 0</p>
182
+ <button id="restart-btn">Try Again</button>
183
+ </div>
184
+ </div>
185
+
186
+ <div class="mt-4 text-gray-400 text-center">
187
+ <p>Arrow keys to move | Space to shoot | Collect green power-ups</p>
188
+ </div>
189
+
190
+ <script>
191
+ document.addEventListener('DOMContentLoaded', () => {
192
+ // Game elements
193
+ const gameContainer = document.getElementById('game-container');
194
+ const player = document.getElementById('player');
195
+ const scoreDisplay = document.getElementById('score-display');
196
+ const healthDisplay = document.getElementById('health-display');
197
+ const levelCompleteScreen = document.getElementById('level-complete');
198
+ const gameOverScreen = document.getElementById('game-over');
199
+ const finalScoreDisplay = document.getElementById('final-score');
200
+ const gameOverScoreDisplay = document.getElementById('game-over-score');
201
+ const restartBtns = document.querySelectorAll('#restart-btn');
202
+
203
+ // Game state
204
+ let score = 0;
205
+ let health = 100;
206
+ let gameRunning = true;
207
+ let levelComplete = false;
208
+ let playerX = 375;
209
+ let playerY = 500;
210
+ let playerSpeed = 8;
211
+ let bullets = [];
212
+ let enemies = [];
213
+ let explosions = [];
214
+ let powerups = [];
215
+ let stars = [];
216
+ let keys = {};
217
+ let lastShotTime = 0;
218
+ let shotDelay = 300; // ms
219
+ let enemySpawnTimer = 0;
220
+ let enemySpawnDelay = 1000; // ms
221
+ let powerupSpawnTimer = 0;
222
+ let powerupSpawnDelay = 8000; // ms
223
+ let bossActive = false;
224
+ let bossHealth = 10;
225
+
226
+ // Game dimensions
227
+ const gameWidth = gameContainer.offsetWidth;
228
+ const gameHeight = gameContainer.offsetHeight;
229
+ const playerWidth = 50;
230
+ const playerHeight = 50;
231
+
232
+ // Initialize player position
233
+ player.style.left = `${playerX}px`;
234
+ player.style.top = `${playerY}px`;
235
+
236
+ // Create background stars
237
+ function createStars() {
238
+ for (let i = 0; i < 100; i++) {
239
+ const star = document.createElement('div');
240
+ star.className = 'star';
241
+
242
+ const size = Math.random() * 3;
243
+ const x = Math.random() * gameWidth;
244
+ const y = Math.random() * gameHeight;
245
+ const opacity = Math.random();
246
+
247
+ star.style.width = `${size}px`;
248
+ star.style.height = `${size}px`;
249
+ star.style.left = `${x}px`;
250
+ star.style.top = `${y}px`;
251
+ star.style.opacity = opacity;
252
+
253
+ gameContainer.appendChild(star);
254
+ stars.push({
255
+ element: star,
256
+ x: x,
257
+ y: y,
258
+ speed: 0.5 + Math.random() * 2
259
+ });
260
+ }
261
+ }
262
+
263
+ // Event listeners for keyboard
264
+ document.addEventListener('keydown', (e) => {
265
+ keys[e.key] = true;
266
+
267
+ // Space to shoot
268
+ if (e.key === ' ' && gameRunning && !levelComplete) {
269
+ const now = Date.now();
270
+ if (now - lastShotTime > shotDelay) {
271
+ shoot();
272
+ lastShotTime = now;
273
+ }
274
+ }
275
+ });
276
+
277
+ document.addEventListener('keyup', (e) => {
278
+ keys[e.key] = false;
279
+ });
280
+
281
+ restartBtns.forEach(btn => {
282
+ btn.addEventListener('click', restartGame);
283
+ });
284
+
285
+ // Create initial game elements
286
+ function initGame() {
287
+ createStars();
288
+ spawnEnemyWave(5);
289
+ }
290
+
291
+ // Create a bullet
292
+ function shoot() {
293
+ const bullet = document.createElement('div');
294
+ bullet.className = 'bullet';
295
+ bullet.style.left = `${playerX + playerWidth / 2 - 2}px`;
296
+ bullet.style.top = `${playerY - 15}px`;
297
+ gameContainer.appendChild(bullet);
298
+
299
+ bullets.push({
300
+ element: bullet,
301
+ x: playerX + playerWidth / 2 - 2,
302
+ y: playerY - 15,
303
+ speed: 10
304
+ });
305
+ }
306
+
307
+ // Spawn a wave of enemies
308
+ function spawnEnemyWave(count) {
309
+ for (let i = 0; i < count; i++) {
310
+ setTimeout(() => {
311
+ if (!gameRunning || levelComplete) return;
312
+
313
+ const enemy = document.createElement('div');
314
+ enemy.className = 'enemy';
315
+
316
+ const x = Math.random() * (gameWidth - 40);
317
+ const y = -40;
318
+
319
+ enemy.style.left = `${x}px`;
320
+ enemy.style.top = `${y}px`;
321
+ gameContainer.appendChild(enemy);
322
+
323
+ enemies.push({
324
+ element: enemy,
325
+ x: x,
326
+ y: y,
327
+ speed: 2 + Math.random() * 2,
328
+ health: 1
329
+ });
330
+ }, i * 500);
331
+ }
332
+ }
333
+
334
+ // Spawn a boss enemy
335
+ function spawnBoss() {
336
+ if (bossActive) return;
337
+
338
+ bossActive = true;
339
+ const boss = document.createElement('div');
340
+ boss.id = 'boss';
341
+
342
+ const x = gameWidth / 2 - 40;
343
+ const y = -80;
344
+
345
+ boss.style.left = `${x}px`;
346
+ boss.style.top = `${y}px`;
347
+ gameContainer.appendChild(boss);
348
+
349
+ enemies.push({
350
+ element: boss,
351
+ x: x,
352
+ y: y,
353
+ speed: 1.5,
354
+ health: bossHealth,
355
+ isBoss: true
356
+ });
357
+ }
358
+
359
+ // Spawn a powerup
360
+ function spawnPowerup() {
361
+ const powerup = document.createElement('div');
362
+ powerup.className = 'powerup';
363
+
364
+ const x = Math.random() * (gameWidth - 30);
365
+ const y = -30;
366
+
367
+ powerup.style.left = `${x}px`;
368
+ powerup.style.top = `${y}px`;
369
+ gameContainer.appendChild(powerup);
370
+
371
+ powerups.push({
372
+ element: powerup,
373
+ x: x,
374
+ y: y,
375
+ speed: 3
376
+ });
377
+ }
378
+
379
+ // Create explosion effect
380
+ function createExplosion(x, y) {
381
+ const explosion = document.createElement('div');
382
+ explosion.className = 'explosion';
383
+ explosion.style.left = `${x - 25}px`;
384
+ explosion.style.top = `${y - 25}px`;
385
+ gameContainer.appendChild(explosion);
386
+
387
+ explosions.push({
388
+ element: explosion,
389
+ time: 0
390
+ });
391
+
392
+ // Remove explosion after animation
393
+ setTimeout(() => {
394
+ gameContainer.removeChild(explosion);
395
+ }, 500);
396
+ }
397
+
398
+ // Game loop
399
+ function gameLoop() {
400
+ if (!gameRunning) return;
401
+
402
+ // Handle player movement
403
+ handleMovement();
404
+
405
+ // Update bullets
406
+ updateBullets();
407
+
408
+ // Update enemies
409
+ updateEnemies();
410
+
411
+ // Update powerups
412
+ updatePowerups();
413
+
414
+ // Update stars (parallax background)
415
+ updateStars();
416
+
417
+ // Spawn new enemies periodically
418
+ enemySpawnTimer += 16; // ~60fps
419
+ if (enemySpawnTimer >= enemySpawnDelay) {
420
+ if (enemies.length < 10) {
421
+ spawnEnemyWave(3);
422
+ }
423
+ enemySpawnTimer = 0;
424
+
425
+ // Spawn boss after certain score
426
+ if (score >= 500 && !bossActive) {
427
+ spawnBoss();
428
+ }
429
+ }
430
+
431
+ // Spawn powerups periodically
432
+ powerupSpawnTimer += 16;
433
+ if (powerupSpawnTimer >= powerupSpawnDelay) {
434
+ spawnPowerup();
435
+ powerupSpawnTimer = 0;
436
+ }
437
+
438
+ // Check for level completion (after boss is defeated)
439
+ if (bossActive && enemies.length === 0) {
440
+ levelComplete = true;
441
+ showLevelComplete();
442
+ }
443
+
444
+ requestAnimationFrame(gameLoop);
445
+ }
446
+
447
+ // Handle player movement based on keyboard input
448
+ function handleMovement() {
449
+ if (keys['ArrowLeft'] || keys['a']) {
450
+ playerX = Math.max(0, playerX - playerSpeed);
451
+ }
452
+
453
+ if (keys['ArrowRight'] || keys['d']) {
454
+ playerX = Math.min(gameWidth - playerWidth, playerX + playerSpeed);
455
+ }
456
+
457
+ if (keys['ArrowUp'] || keys['w']) {
458
+ playerY = Math.max(0, playerY - playerSpeed);
459
+ }
460
+
461
+ if (keys['ArrowDown'] || keys['s']) {
462
+ playerY = Math.min(gameHeight - playerHeight, playerY + playerSpeed);
463
+ }
464
+
465
+ player.style.left = `${playerX}px`;
466
+ player.style.top = `${playerY}px`;
467
+ }
468
+
469
+ // Update all active bullets
470
+ function updateBullets() {
471
+ for (let i = bullets.length - 1; i >= 0; i--) {
472
+ const bullet = bullets[i];
473
+ bullet.y -= bullet.speed;
474
+ bullet.element.style.top = `${bullet.y}px`;
475
+
476
+ // Remove bullets that go off screen
477
+ if (bullet.y < -15) {
478
+ gameContainer.removeChild(bullet.element);
479
+ bullets.splice(i, 1);
480
+ }
481
+ }
482
+ }
483
+
484
+ // Update all active enemies
485
+ function updateEnemies() {
486
+ for (let i = enemies.length - 1; i >= 0; i--) {
487
+ const enemy = enemies[i];
488
+ enemy.y += enemy.speed;
489
+ enemy.element.style.top = `${enemy.y}px`;
490
+
491
+ // Remove enemies that go off screen
492
+ if (enemy.y > gameHeight) {
493
+ gameContainer.removeChild(enemy.element);
494
+ enemies.splice(i, 1);
495
+ }
496
+
497
+ // Check for bullet collisions
498
+ for (let j = bullets.length - 1; j >= 0; j--) {
499
+ const bullet = bullets[j];
500
+
501
+ if (checkCollision(bullet, enemy)) {
502
+ // Hit enemy
503
+ enemy.health--;
504
+
505
+ // Remove bullet
506
+ gameContainer.removeChild(bullet.element);
507
+ bullets.splice(j, 1);
508
+
509
+ // Create explosion if enemy is destroyed
510
+ if (enemy.health <= 0) {
511
+ createExplosion(enemy.x + 20, enemy.y + 20);
512
+ gameContainer.removeChild(enemy.element);
513
+ enemies.splice(i, 1);
514
+
515
+ // Add score
516
+ const points = enemy.isBoss ? 200 : 50;
517
+ score += points;
518
+ scoreDisplay.textContent = `SCORE: ${score}`;
519
+
520
+ // Check if boss was defeated
521
+ if (enemy.isBoss) {
522
+ bossActive = false;
523
+ }
524
+ }
525
+
526
+ break;
527
+ }
528
+ }
529
+
530
+ // Check for player collision
531
+ if (checkCollision({x: playerX, y: playerY, width: playerWidth, height: playerHeight}, enemy)) {
532
+ createExplosion(enemy.x + 20, enemy.y + 20);
533
+ gameContainer.removeChild(enemy.element);
534
+ enemies.splice(i, 1);
535
+
536
+ // Reduce player health
537
+ health -= enemy.isBoss ? 30 : 10;
538
+ health = Math.max(0, health);
539
+ healthDisplay.textContent = `HEALTH: ${health}%`;
540
+
541
+ if (health <= 0) {
542
+ gameOver();
543
+ }
544
+ }
545
+ }
546
+ }
547
+
548
+ // Update all active powerups
549
+ function updatePowerups() {
550
+ for (let i = powerups.length - 1; i >= 0; i--) {
551
+ const powerup = powerups[i];
552
+ powerup.y += powerup.speed;
553
+ powerup.element.style.top = `${powerup.y}px`;
554
+
555
+ // Remove powerups that go off screen
556
+ if (powerup.y > gameHeight) {
557
+ gameContainer.removeChild(powerup.element);
558
+ powerups.splice(i, 1);
559
+ }
560
+
561
+ // Check for player collision
562
+ if (checkCollision({x: playerX, y: playerY, width: playerWidth, height: playerHeight}, powerup)) {
563
+ gameContainer.removeChild(powerup.element);
564
+ powerups.splice(i, 1);
565
+
566
+ // Apply powerup effect
567
+ health = Math.min(100, health + 20);
568
+ healthDisplay.textContent = `HEALTH: ${health}%`;
569
+
570
+ // Temporary speed boost
571
+ const originalSpeed = playerSpeed;
572
+ playerSpeed = 12;
573
+ setTimeout(() => {
574
+ playerSpeed = originalSpeed;
575
+ }, 5000);
576
+ }
577
+ }
578
+ }
579
+
580
+ // Update background stars
581
+ function updateStars() {
582
+ for (let i = 0; i < stars.length; i++) {
583
+ const star = stars[i];
584
+ star.y += star.speed;
585
+
586
+ if (star.y > gameHeight) {
587
+ star.y = 0;
588
+ star.x = Math.random() * gameWidth;
589
+ }
590
+
591
+ star.element.style.top = `${star.y}px`;
592
+ }
593
+ }
594
+
595
+ // Check collision between two objects
596
+ function checkCollision(obj1, obj2) {
597
+ const obj1Width = obj1.width || 40;
598
+ const obj1Height = obj1.height || 40;
599
+ const obj2Width = obj2.width || 40;
600
+ const obj2Height = obj2.height || 40;
601
+
602
+ return (
603
+ obj1.x < obj2.x + obj2Width &&
604
+ obj1.x + obj1Width > obj2.x &&
605
+ obj1.y < obj2.y + obj2Height &&
606
+ obj1.y + obj1Height > obj2.y
607
+ );
608
+ }
609
+
610
+ // Show level complete screen
611
+ function showLevelComplete() {
612
+ gameRunning = false;
613
+ finalScoreDisplay.textContent = `Your score: ${score}`;
614
+ levelCompleteScreen.style.display = 'block';
615
+ }
616
+
617
+ // Game over function
618
+ function gameOver() {
619
+ gameRunning = false;
620
+ gameOverScoreDisplay.textContent = `Your score: ${score}`;
621
+ gameOverScreen.style.display = 'block';
622
+
623
+ // Create explosion at player position
624
+ createExplosion(playerX + 25, playerY + 25);
625
+ player.style.display = 'none';
626
+ }
627
+
628
+ // Restart game function
629
+ function restartGame() {
630
+ // Reset game state
631
+ score = 0;
632
+ health = 100;
633
+ gameRunning = true;
634
+ levelComplete = false;
635
+ bossActive = false;
636
+ playerX = 375;
637
+ playerY = 500;
638
+ playerSpeed = 8;
639
+
640
+ // Reset displays
641
+ scoreDisplay.textContent = `SCORE: 0`;
642
+ healthDisplay.textContent = `HEALTH: 100%`;
643
+ player.style.display = 'block';
644
+ player.style.left = `${playerX}px`;
645
+ player.style.top = `${playerY}px`;
646
+
647
+ // Hide screens
648
+ levelCompleteScreen.style.display = 'none';
649
+ gameOverScreen.style.display = 'none';
650
+
651
+ // Clear all game elements
652
+ bullets.forEach(bullet => {
653
+ gameContainer.removeChild(bullet.element);
654
+ });
655
+
656
+ enemies.forEach(enemy => {
657
+ gameContainer.removeChild(enemy.element);
658
+ });
659
+
660
+ powerups.forEach(powerup => {
661
+ gameContainer.removeChild(powerup.element);
662
+ });
663
+
664
+ stars.forEach(star => {
665
+ gameContainer.removeChild(star.element);
666
+ });
667
+
668
+ // Clear arrays
669
+ bullets = [];
670
+ enemies = [];
671
+ powerups = [];
672
+ stars = [];
673
+
674
+ // Create new game elements
675
+ initGame();
676
+
677
+ // Start game
678
+ requestAnimationFrame(gameLoop);
679
+ }
680
+
681
+ // Start the game
682
+ initGame();
683
+ gameLoop();
684
+ });
685
+ </script>
686
+ <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=FriedsU/space" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
687
+ </html>