victor HF Staff commited on
Commit
f3e3455
·
verified ·
1 Parent(s): 6252b27

Add index.html

Browse files
Files changed (1) hide show
  1. index.html +452 -19
index.html CHANGED
@@ -1,19 +1,452 @@
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>Cyber Pong Explosion</title>
7
+ <style>
8
+ @import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700&display=swap');
9
+
10
+ * {
11
+ margin: 0;
12
+ padding: 0;
13
+ box-sizing: border-box;
14
+ }
15
+
16
+ body {
17
+ background-color: #0a0a1a;
18
+ color: #00ff9d;
19
+ font-family: 'Orbitron', sans-serif;
20
+ overflow: hidden;
21
+ height: 100vh;
22
+ display: flex;
23
+ flex-direction: column;
24
+ align-items: center;
25
+ justify-content: space-between;
26
+ }
27
+
28
+ header {
29
+ width: 100%;
30
+ padding: 1rem;
31
+ text-align: center;
32
+ background: linear-gradient(90deg, rgba(0,0,0,0) 0%, rgba(0,255,157,0.2) 50%, rgba(0,0,0,0) 100%);
33
+ border-bottom: 1px solid #00ff9d;
34
+ }
35
+
36
+ h1 {
37
+ font-size: 2.5rem;
38
+ text-shadow: 0 0 10px #00ff9d, 0 0 20px #00ff9d;
39
+ letter-spacing: 3px;
40
+ }
41
+
42
+ .score-container {
43
+ display: flex;
44
+ justify-content: space-between;
45
+ width: 600px;
46
+ margin: 1rem auto;
47
+ }
48
+
49
+ .score {
50
+ font-size: 1.5rem;
51
+ text-shadow: 0 0 5px #00ff9d;
52
+ padding: 0.5rem 1rem;
53
+ background-color: rgba(0,0,0,0.5);
54
+ border-radius: 5px;
55
+ border: 1px solid #00ff9d;
56
+ }
57
+
58
+ #gameCanvas {
59
+ border: 2px solid #00ff9d;
60
+ box-shadow: 0 0 20px #00ff9d, inset 0 0 10px #00ff9d;
61
+ background-color: #000;
62
+ display: block;
63
+ margin: 0 auto;
64
+ }
65
+
66
+ .controls {
67
+ display: flex;
68
+ gap: 2rem;
69
+ margin: 1rem 0;
70
+ }
71
+
72
+ button {
73
+ background: linear-gradient(to bottom, #002a1d, #003d2b);
74
+ color: #00ff9d;
75
+ border: 1px solid #00ff9d;
76
+ padding: 0.8rem 1.5rem;
77
+ font-family: 'Orbitron', sans-serif;
78
+ font-size: 1rem;
79
+ cursor: pointer;
80
+ border-radius: 4px;
81
+ text-transform: uppercase;
82
+ letter-spacing: 1px;
83
+ transition: all 0.3s;
84
+ }
85
+
86
+ button:hover {
87
+ background: linear-gradient(to bottom, #003d2b, #004f38);
88
+ box-shadow: 0 0 10px #00ff9d;
89
+ transform: translateY(-2px);
90
+ }
91
+
92
+ .explosion {
93
+ position: absolute;
94
+ pointer-events: none;
95
+ transform: translate(-50%, -50%);
96
+ border-radius: 50%;
97
+ opacity: 0;
98
+ }
99
+
100
+ footer {
101
+ width: 100%;
102
+ padding: 1rem;
103
+ text-align: center;
104
+ background: linear-gradient(90deg, rgba(0,0,0,0) 0%, rgba(0,255,157,0.2) 50%, rgba(0,0,0,0) 100%);
105
+ border-top: 1px solid #00ff9d;
106
+ font-size: 0.8rem;
107
+ }
108
+ </style>
109
+ </head>
110
+ <body>
111
+ <header>
112
+ <h1>CYBER PONG EXPLOSION</h1>
113
+ </header>
114
+
115
+ <div class="score-container">
116
+ <div class="score" id="playerScore">PLAYER: 0</div>
117
+ <div class="score" id="aiScore">AI: 0</div>
118
+ </div>
119
+
120
+ <canvas id="gameCanvas" width="800" height="500"></canvas>
121
+
122
+ <div class="controls">
123
+ <button id="startBtn">START GAME</button>
124
+ <button id="pauseBtn">PAUSE</button>
125
+ <button id="resetBtn">RESET</button>
126
+ </div>
127
+
128
+ <footer>
129
+ Use W/S or UP/DOWN keys to control your paddle | © 2023 Cyber Pong Explosion
130
+ </footer>
131
+
132
+ <script>
133
+ document.addEventListener('DOMContentLoaded', () => {
134
+ const canvas = document.getElementById('gameCanvas');
135
+ const ctx = canvas.getContext('2d');
136
+ const playerScoreEl = document.getElementById('playerScore');
137
+ const aiScoreEl = document.getElementById('aiScore');
138
+ const startBtn = document.getElementById('startBtn');
139
+ const pauseBtn = document.getElementById('pauseBtn');
140
+ const resetBtn = document.getElementById('resetBtn');
141
+
142
+ // Game state
143
+ let gameRunning = false;
144
+ let gamePaused = false;
145
+
146
+ // Ball properties
147
+ const ball = {
148
+ x: canvas.width / 2,
149
+ y: canvas.height / 2,
150
+ radius: 10,
151
+ speed: 5,
152
+ dx: 5,
153
+ dy: 5,
154
+ color: '#00ff9d',
155
+ glow: true,
156
+ trail: []
157
+ };
158
+
159
+ // Paddle properties
160
+ const playerPaddle = {
161
+ x: 20,
162
+ y: canvas.height / 2 - 50,
163
+ width: 15,
164
+ height: 100,
165
+ color: '#00ff9d',
166
+ speed: 8,
167
+ score: 0
168
+ };
169
+
170
+ const aiPaddle = {
171
+ x: canvas.width - 35,
172
+ y: canvas.height / 2 - 50,
173
+ width: 15,
174
+ height: 100,
175
+ color: '#ff00aa',
176
+ speed: 5.5,
177
+ score: 0
178
+ };
179
+
180
+ // Key states
181
+ const keys = {
182
+ w: false,
183
+ s: false,
184
+ ArrowUp: false,
185
+ ArrowDown: false
186
+ };
187
+
188
+ // Explosion particles array
189
+ let explosions = [];
190
+
191
+ // Event listeners
192
+ document.addEventListener('keydown', (e) => {
193
+ if (e.key in keys) {
194
+ keys[e.key] = true;
195
+ }
196
+ });
197
+
198
+ document.addEventListener('keyup', (e) => {
199
+ if (e.key in keys) {
200
+ keys[e.key] = false;
201
+ }
202
+ });
203
+
204
+ startBtn.addEventListener('click', startGame);
205
+ pauseBtn.addEventListener('click', togglePause);
206
+ resetBtn.addEventListener('click', resetGame);
207
+
208
+ // Start game function
209
+ function startGame() {
210
+ if (!gameRunning) {
211
+ gameRunning = true;
212
+ gamePaused = false;
213
+ resetBall();
214
+ update();
215
+ }
216
+ }
217
+
218
+ // Toggle pause function
219
+ function togglePause() {
220
+ if (gameRunning) {
221
+ gamePaused = !gamePaused;
222
+ pauseBtn.textContent = gamePaused ? 'RESUME' : 'PAUSE';
223
+ }
224
+ }
225
+
226
+ // Reset game function
227
+ function resetGame() {
228
+ gameRunning = false;
229
+ gamePaused = false;
230
+ playerPaddle.score = 0;
231
+ aiPaddle.score = 0;
232
+ updateScore();
233
+ pauseBtn.textContent = 'PAUSE';
234
+ resetBall();
235
+ draw();
236
+ }
237
+
238
+ // Reset ball to center
239
+ function resetBall() {
240
+ ball.x = canvas.width / 2;
241
+ ball.y = canvas.height / 2;
242
+ ball.dx = 5 * (Math.random() > 0.5 ? 1 : -1);
243
+ ball.dy = 5 * (Math.random() > 0.5 ? 1 : -1);
244
+ }
245
+
246
+ // Update score display
247
+ function updateScore() {
248
+ playerScoreEl.textContent = `PLAYER: ${playerPaddle.score}`;
249
+ aiScoreEl.textContent = `AI: ${aiPaddle.score}`;
250
+ }
251
+
252
+ // Create explosion effect
253
+ function createExplosion(x, y, color) {
254
+ const particleCount = 30 + Math.floor(Math.random() * 30);
255
+
256
+ for (let i = 0; i < particleCount; i++) {
257
+ const angle = Math.random() * Math.PI * 2;
258
+ const speed = 2 + Math.random() * 5;
259
+ const size = 2 + Math.random() * 4;
260
+ const lifetime = 30 + Math.floor(Math.random() * 30);
261
+
262
+ explosions.push({
263
+ x,
264
+ y,
265
+ dx: Math.cos(angle) * speed,
266
+ dy: Math.sin(angle) * speed,
267
+ size,
268
+ color,
269
+ lifetime,
270
+ currentLife: 0
271
+ });
272
+ }
273
+ }
274
+
275
+ // Update game state
276
+ function update() {
277
+ if (!gameRunning || gamePaused) return;
278
+
279
+ // Clear the canvas
280
+ ctx.clearRect(0, 0, canvas.width, canvas.height);
281
+
282
+ // Update ball position
283
+ ball.x += ball.dx;
284
+ ball.y += ball.dy;
285
+
286
+ // Store ball position for trail effect
287
+ ball.trail.push({x: ball.x, y: ball.y});
288
+ if (ball.trail.length > 10) {
289
+ ball.trail.shift();
290
+ }
291
+
292
+ // Ball collision with top and bottom walls
293
+ if (ball.y - ball.radius < 0 || ball.y + ball.radius > canvas.height) {
294
+ ball.dy = -ball.dy;
295
+ createExplosion(ball.x, ball.y, '#00ffff');
296
+ }
297
+
298
+ // Ball collision with paddles
299
+ if (
300
+ ball.x - ball.radius < playerPaddle.x + playerPaddle.width &&
301
+ ball.x + ball.radius > playerPaddle.x &&
302
+ ball.y - ball.radius < playerPaddle.y + playerPaddle.height &&
303
+ ball.y + ball.radius > playerPaddle.y
304
+ ) {
305
+ const collidePoint = (ball.y - (playerPaddle.y + playerPaddle.height / 2)) / (playerPaddle.height / 2);
306
+ const angle = collidePoint * Math.PI / 4;
307
+
308
+ ball.dx = Math.cos(angle) * ball.speed;
309
+ ball.dy = Math.sin(angle) * ball.speed;
310
+ ball.speed += 0.2;
311
+
312
+ createExplosion(ball.x, ball.y, playerPaddle.color);
313
+ }
314
+
315
+ if (
316
+ ball.x + ball.radius > aiPaddle.x &&
317
+ ball.x - ball.radius < aiPaddle.x + aiPaddle.width &&
318
+ ball.y - ball.radius < aiPaddle.y + aiPaddle.height &&
319
+ ball.y + ball.radius > aiPaddle.y
320
+ ) {
321
+ const collidePoint = (ball.y - (aiPaddle.y + aiPaddle.height / 2)) / (aiPaddle.height / 2);
322
+ const angle = Math.PI - collidePoint * Math.PI / 4;
323
+
324
+ ball.dx = Math.cos(angle) * ball.speed;
325
+ ball.dy = Math.sin(angle) * ball.speed;
326
+ ball.speed += 0.2;
327
+
328
+ createExplosion(ball.x, ball.y, aiPaddle.color);
329
+ }
330
+
331
+ // Ball out of bounds (score points)
332
+ if (ball.x - ball.radius < 0) {
333
+ aiPaddle.score++;
334
+ updateScore();
335
+ createExplosion(ball.x, ball.y, aiPaddle.color);
336
+ resetBall();
337
+ }
338
+
339
+ if (ball.x + ball.radius > canvas.width) {
340
+ playerPaddle.score++;
341
+ updateScore();
342
+ createExplosion(ball.x, ball.y, playerPaddle.color);
343
+ resetBall();
344
+ }
345
+
346
+ // AI paddle movement
347
+ const aiPaddleCenter = aiPaddle.y + aiPaddle.height / 2;
348
+ if (aiPaddleCenter < ball.y - 10) {
349
+ aiPaddle.y += aiPaddle.speed;
350
+ } else if (aiPaddleCenter > ball.y + 10) {
351
+ aiPaddle.y -= aiPaddle.speed;
352
+ }
353
+
354
+ // Player paddle movement
355
+ if (keys.w || keys.ArrowUp) {
356
+ playerPaddle.y -= playerPaddle.speed;
357
+ }
358
+ if (keys.s || keys.ArrowDown) {
359
+ playerPaddle.y += playerPaddle.speed;
360
+ }
361
+
362
+ // Keep paddles within canvas
363
+ playerPaddle.y = Math.max(0, Math.min(canvas.height - playerPaddle.height, playerPaddle.y));
364
+ aiPaddle.y = Math.max(0, Math.min(canvas.height - aiPaddle.height, aiPaddle.y));
365
+
366
+ // Update explosions
367
+ explosions.forEach((exp, index) => {
368
+ exp.x += exp.dx;
369
+ exp.y += exp.dy;
370
+ exp.currentLife++;
371
+
372
+ if (exp.currentLife >= exp.lifetime) {
373
+ explosions.splice(index, 1);
374
+ }
375
+ });
376
+
377
+ // Draw everything
378
+ draw();
379
+
380
+ // Continue animation loop
381
+ requestAnimationFrame(update);
382
+ }
383
+
384
+ // Draw game elements
385
+ function draw() {
386
+ // Clear canvas
387
+ ctx.fillStyle = '#0a0a1a';
388
+ ctx.fillRect(0, 0, canvas.width, canvas.height);
389
+
390
+ // Draw center line
391
+ ctx.strokeStyle = 'rgba(0, 255, 157, 0.2)';
392
+ ctx.lineWidth = 2;
393
+ ctx.setLineDash([10, 10]);
394
+ ctx.beginPath();
395
+ ctx.moveTo(canvas.width / 2, 0);
396
+ ctx.lineTo(canvas.width / 2, canvas.height);
397
+ ctx.stroke();
398
+ ctx.setLineDash([]);
399
+
400
+ // Draw ball trail
401
+ ball.trail.forEach((pos, i) => {
402
+ const alpha = i / ball.trail.length;
403
+ ctx.beginPath();
404
+ ctx.arc(pos.x, pos.y, ball.radius * alpha, 0, Math.PI * 2);
405
+ ctx.fillStyle = `rgba(0, 255, 157, ${alpha})`;
406
+ ctx.fill();
407
+ });
408
+
409
+ // Draw ball
410
+ ctx.beginPath();
411
+ ctx.arc(ball.x, ball.y, ball.radius, 0, Math.PI * 2);
412
+ ctx.fillStyle = ball.color;
413
+ ctx.fill();
414
+
415
+ if (ball.glow) {
416
+ ctx.shadowColor = ball.color;
417
+ ctx.shadowBlur = 15;
418
+ }
419
+
420
+ // Draw paddles
421
+ ctx.fillStyle = playerPaddle.color;
422
+ ctx.fillRect(playerPaddle.x, playerPaddle.y, playerPaddle.width, playerPaddle.height);
423
+
424
+ ctx.fillStyle = aiPaddle.color;
425
+ ctx.fillRect(aiPaddle.x, aiPaddle.y, aiPaddle.width, aiPaddle.height);
426
+
427
+ ctx.shadowColor = 'transparent';
428
+
429
+ // Draw explosions
430
+ explosions.forEach(exp => {
431
+ const alpha = 1 - (exp.currentLife / exp.lifetime);
432
+ ctx.fillStyle = `${exp.color}${Math.floor(alpha * 255).toString(16).padStart(2, '0')}`;
433
+ ctx.beginPath();
434
+ ctx.arc(exp.x, exp.y, exp.size, 0, Math.PI * 2);
435
+ ctx.fill();
436
+
437
+ // Add glow effect
438
+ ctx.shadowColor = exp.color;
439
+ ctx.shadowBlur = 10;
440
+ ctx.beginPath();
441
+ ctx.arc(exp.x, exp.y, exp.size / 2, 0, Math.PI * 2);
442
+ ctx.fill();
443
+ ctx.shadowColor = 'transparent';
444
+ });
445
+ }
446
+
447
+ // Initial draw
448
+ draw();
449
+ });
450
+ </script>
451
+ <p style="text-align: center; font-size: 12px; color: #888; margin-top: 16px;">This website has been generated by <a href="https://enzostvs-deepsite.hf.space" target="_blank">DeepSite</a> <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;"></p></body>
452
+ </html>