-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.html
More file actions
572 lines (541 loc) · 15.6 KB
/
Copy pathindex.html
File metadata and controls
572 lines (541 loc) · 15.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Cosmic Defender 3D</title>
<style>
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
overflow: hidden;
background: #000;
font-family: 'Courier New', monospace;
color: #fff;
user-select: none;
}
canvas { display: block; }
/* Overlay screens */
.screen {
position: fixed;
inset: 0;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
z-index: 100;
transition: opacity 0.3s;
}
.screen.hidden { display: none; }
/* Loading screen */
#loading-screen { background: #000; }
#loading-screen h1 {
font-size: 2.5rem;
color: #0af;
text-shadow: 0 0 20px #0af, 0 0 40px #06f;
margin-bottom: 1rem;
}
#loading-screen .bar-track {
width: 300px;
height: 6px;
background: #222;
border-radius: 3px;
overflow: hidden;
margin-top: 0.5rem;
}
#loading-screen .bar-fill {
height: 100%;
width: 0%;
background: linear-gradient(90deg, #0af, #0ff);
transition: width 0.2s;
}
#loading-screen p { color: #889; font-size: 0.9rem; }
/* Main menu */
#menu-screen {
background: radial-gradient(ellipse at center, #0a0a2a 0%, #000 70%);
}
#menu-screen h1 {
font-size: 3rem;
color: #0af;
text-shadow: 0 0 30px #0af, 0 0 60px #06f;
margin-bottom: 0.5rem;
letter-spacing: 0.2em;
}
#menu-screen .subtitle {
color: #668;
font-size: 1rem;
margin-bottom: 3rem;
}
.menu-btn {
display: block;
width: 240px;
padding: 14px 0;
margin: 8px 0;
background: transparent;
border: 1px solid #0af;
color: #0af;
font-family: 'Courier New', monospace;
font-size: 1.1rem;
cursor: pointer;
letter-spacing: 0.15em;
transition: all 0.2s;
}
.menu-btn:hover {
background: rgba(0, 170, 255, 0.15);
box-shadow: 0 0 20px rgba(0, 170, 255, 0.3);
}
#menu-screen .high-score {
margin-top: 2rem;
color: #ff0;
font-size: 1.1rem;
text-shadow: 0 0 10px rgba(255, 255, 0, 0.5);
}
#menu-screen .controls-hint {
position: absolute;
bottom: 2rem;
color: #445;
font-size: 0.8rem;
text-align: center;
line-height: 1.8;
}
#menu-screen .github-link {
position: absolute;
top: 1rem;
right: 1.5rem;
color: #445;
text-decoration: none;
transition: color 0.2s;
display: flex;
align-items: center;
}
#menu-screen .github-link svg {
width: 1.5rem;
height: 1.5rem;
fill: currentColor;
}
#menu-screen .github-link:hover { color: #0af; }
/* Pause screen */
#pause-screen { background: rgba(0, 0, 0, 0.7); }
#pause-screen h2 {
font-size: 2rem;
color: #0af;
text-shadow: 0 0 20px #0af;
margin-bottom: 2rem;
}
/* Game over screen */
#gameover-screen { background: rgba(0, 0, 0, 0.85); }
#gameover-screen h2 {
font-size: 2.5rem;
color: #f44;
text-shadow: 0 0 30px #f44;
margin-bottom: 0.5rem;
}
#gameover-screen .final-score {
font-size: 2rem;
color: #ff0;
text-shadow: 0 0 15px rgba(255, 255, 0, 0.5);
margin-bottom: 0.5rem;
}
#gameover-screen .stats {
color: #889;
font-size: 0.9rem;
margin-bottom: 2rem;
line-height: 1.8;
}
.new-high-score {
color: #ff0;
font-size: 1.2rem;
text-shadow: 0 0 15px rgba(255, 255, 0, 0.5);
animation: pulse 1s infinite;
margin-bottom: 1rem;
}
.new-high-score.hidden { display: none; }
@keyframes pulse {
0%, 100% { opacity: 1; }
50% { opacity: 0.5; }
}
/* Share buttons */
.share-label {
color: #889;
font-size: 0.75rem;
letter-spacing: 0.1em;
margin-bottom: 0.5rem;
}
.share-row {
display: flex;
flex-wrap: wrap;
gap: 6px;
justify-content: center;
margin-bottom: 1rem;
}
.share-btn {
padding: 5px 9px;
background: transparent;
border: 1px solid #446;
color: #889;
font-family: 'Courier New', monospace;
font-size: 0.7rem;
cursor: pointer;
letter-spacing: 0.08em;
transition: all 0.2s;
}
.share-btn:hover {
border-color: #0af;
color: #0af;
box-shadow: 0 0 10px rgba(0, 170, 255, 0.2);
}
.share-btn.copied {
border-color: #0f8;
color: #0f8;
}
/* Wave announcement */
#wave-announce {
position: fixed;
top: 30%;
left: 50%;
transform: translate(-50%, -50%);
text-align: center;
z-index: 50;
pointer-events: none;
opacity: 0;
transition: opacity 0.3s;
}
#wave-announce.visible { opacity: 1; }
#wave-announce .wave-num {
font-size: 3rem;
color: #0af;
text-shadow: 0 0 30px #0af, 0 0 60px #06f;
}
#wave-announce .wave-sub {
font-size: 1rem;
color: #889;
margin-top: 0.5rem;
}
/* HUD */
#hud {
position: fixed;
inset: 0;
pointer-events: none;
z-index: 10;
}
#hud.hidden { display: none; }
/* Crosshair */
#crosshair {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 24px;
height: 24px;
}
#crosshair .ch-line {
position: absolute;
background: rgba(0, 255, 255, 0.8);
}
#crosshair .ch-h { width: 8px; height: 2px; top: 11px; }
#crosshair .ch-v { width: 2px; height: 8px; left: 11px; }
#crosshair .ch-l { left: 0; }
#crosshair .ch-r { right: 0; }
#crosshair .ch-t { top: 0; }
#crosshair .ch-b { bottom: 0; }
#crosshair .ch-dot {
position: absolute;
width: 2px;
height: 2px;
top: 11px;
left: 11px;
background: rgba(0, 255, 255, 1);
}
/* Health bar */
#health-container {
position: absolute;
bottom: 30px;
left: 30px;
}
#health-container .bar-row {
display: flex;
align-items: center;
gap: 8px;
margin-bottom: 6px;
}
#health-container .label {
font-size: 0.85rem;
color: #0f4;
text-shadow: 0 0 6px #0f4;
width: 46px;
letter-spacing: 0.05em;
}
#health-container .label.shield-label {
color: #0af;
text-shadow: 0 0 6px #0af;
}
#health-container .bar-value {
font-size: 0.85rem;
color: #ccc;
min-width: 52px;
text-align: right;
}
#health-track {
width: 180px;
height: 16px;
background: rgba(0, 255, 68, 0.1);
border: 1px solid rgba(0, 255, 68, 0.4);
border-radius: 2px;
overflow: hidden;
}
#health-fill {
height: 100%;
width: 100%;
background: linear-gradient(90deg, #0a3, #0f4);
box-shadow: 0 0 8px rgba(0, 255, 68, 0.6);
transition: width 0.2s, background 0.2s, box-shadow 0.2s;
}
#shield-track {
width: 180px;
height: 14px;
background: rgba(0, 170, 255, 0.1);
border: 1px solid rgba(0, 170, 255, 0.4);
border-radius: 2px;
overflow: hidden;
}
#shield-fill {
height: 100%;
width: 100%;
background: linear-gradient(90deg, #07f, #0af);
box-shadow: 0 0 8px rgba(0, 170, 255, 0.6);
transition: width 0.2s;
}
/* Ammo */
#ammo-display {
position: absolute;
bottom: 30px;
right: 30px;
text-align: right;
}
#ammo-display .ammo-count {
font-size: 2rem;
color: #fff;
}
#ammo-display .ammo-count.low { color: #f84; }
#ammo-display .ammo-count.reloading {
color: #fa0;
animation: pulse 0.6s ease-in-out infinite;
}
#ammo-display .ammo-label {
font-size: 0.7rem;
color: #888;
}
#reload-bar {
width: 80px;
height: 3px;
background: rgba(255, 255, 255, 0.1);
margin-top: 4px;
display: none;
}
#reload-bar.visible { display: block; }
#reload-fill {
height: 100%;
width: 0%;
background: #0af;
transition: width 0.05s;
}
/* Score */
#score-display {
position: absolute;
top: 20px;
right: 30px;
text-align: right;
}
#score-display .score-val {
font-size: 1.5rem;
color: #ff0;
text-shadow: 0 0 10px rgba(255, 255, 0, 0.3);
}
#score-display .score-label {
font-size: 0.6rem;
color: #888;
}
/* Wave indicator */
#wave-display {
position: absolute;
top: 20px;
left: 50%;
transform: translateX(-50%);
text-align: center;
}
#wave-display .wave-val {
font-size: 1.2rem;
color: #0af;
}
#wave-display .wave-label {
font-size: 0.6rem;
color: #888;
}
/* Combo */
#combo-display {
position: absolute;
top: 55px;
right: 30px;
text-align: right;
opacity: 0;
transition: opacity 0.3s;
}
#combo-display.active { opacity: 1; }
#combo-display .combo-val {
font-size: 1rem;
color: #f80;
text-shadow: 0 0 10px rgba(255, 136, 0, 0.5);
}
/* Enemy count */
#enemies-display {
position: absolute;
top: 20px;
left: 30px;
}
#enemies-display .enemies-val {
font-size: 1rem;
color: #f66;
}
#enemies-display .enemies-label {
font-size: 0.6rem;
color: #888;
}
/* Hit marker */
#hit-marker {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 20px;
height: 20px;
opacity: 0;
pointer-events: none;
}
#hit-marker .hm-line {
position: absolute;
width: 8px;
height: 2px;
background: #fff;
transform-origin: center;
}
#hit-marker .hm-tl { top: 2px; left: 2px; transform: rotate(45deg); }
#hit-marker .hm-tr { top: 2px; right: 2px; transform: rotate(-45deg); }
#hit-marker .hm-bl { bottom: 2px; left: 2px; transform: rotate(-45deg); }
#hit-marker .hm-br { bottom: 2px; right: 2px; transform: rotate(45deg); }
/* Damage vignette */
#damage-vignette {
position: fixed;
inset: 0;
pointer-events: none;
z-index: 9;
opacity: 0;
background: radial-gradient(ellipse at center, transparent 50%, rgba(255, 0, 0, 0.6) 100%);
transition: opacity 0.1s;
}
</style>
</head>
<body>
<!-- Loading Screen -->
<div id="loading-screen" class="screen">
<h1>COSMIC DEFENDER 3D</h1>
<p>Loading assets...</p>
<div class="bar-track">
<div class="bar-fill" id="loading-fill"></div>
</div>
</div>
<!-- Main Menu -->
<div id="menu-screen" class="screen hidden">
<h1>COSMIC DEFENDER 3D</h1>
<p class="subtitle">DEFEND HUMANITY AGAINST THE ALIEN INVASION</p>
<button class="menu-btn" id="btn-play">PLAY</button>
<button class="menu-btn" id="btn-how">HOW TO PLAY</button>
<p class="high-score" id="menu-high-score"></p>
<div class="controls-hint" id="controls-hint">
WASD - Move | MOUSE - Aim | LEFT CLICK - Shoot | R - Reload<br>
SPACE - Jump | ESC - Pause
</div>
<a class="github-link" href="https://github.com/jonathanbossenger/cosmic-defender-3d" target="_blank" rel="noopener noreferrer" aria-label="View source code on GitHub"><svg viewBox="0 0 98 96" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M48.854 0C21.839 0 0 22 0 49.217c0 21.756 13.993 40.172 33.405 46.69 2.427.49 3.316-1.059 3.316-2.362 0-1.141-.08-5.052-.08-9.127-13.59 2.934-16.42-5.867-16.42-5.867-2.184-5.704-5.42-7.17-5.42-7.17-4.448-3.015.324-3.015.324-3.015 4.934.326 7.523 5.052 7.523 5.052 4.367 7.496 11.404 5.378 14.235 4.074.404-3.178 1.699-5.378 3.074-6.6-10.839-1.141-22.243-5.378-22.243-24.283 0-5.378 1.94-9.778 5.014-13.2-.485-1.222-2.184-6.275.486-13.038 0 0 4.125-1.304 13.426 5.052a46.97 46.97 0 0 1 12.214-1.63c4.125 0 8.33.571 12.213 1.63 9.302-6.356 13.427-5.052 13.427-5.052 2.67 6.763.97 11.816.485 13.038 3.155 3.422 5.015 7.822 5.015 13.2 0 18.905-11.404 23.06-22.324 24.283 1.78 1.548 3.316 4.481 3.316 9.126 0 6.6-.08 11.897-.08 13.526 0 1.304.89 2.853 3.316 2.364 19.412-6.52 33.405-24.935 33.405-46.691C97.707 22 75.788 0 48.854 0z"/></svg></a>
</div>
<!-- Pause Screen -->
<div id="pause-screen" class="screen hidden">
<h2>PAUSED</h2>
<button class="menu-btn" id="btn-resume">RESUME</button>
<button class="menu-btn" id="btn-quit">QUIT TO MENU</button>
</div>
<!-- Game Over Screen -->
<div id="gameover-screen" class="screen hidden">
<h2>GAME OVER</h2>
<p class="new-high-score hidden" id="new-high-score">NEW HIGH SCORE!</p>
<p class="final-score" id="final-score">0</p>
<div class="stats" id="final-stats"></div>
<div id="share-buttons">
<p class="share-label">SHARE YOUR SCORE</p>
<div class="share-row">
<button class="share-btn" id="share-twitter">Twitter</button>
<button class="share-btn" id="share-bluesky">Bluesky</button>
<button class="share-btn" id="share-mastodon">Mastodon</button>
<button class="share-btn" id="share-linkedin">LinkedIn</button>
<button class="share-btn" id="share-facebook">Facebook</button>
<button class="share-btn" id="share-instagram">Instagram</button>
<button class="share-btn" id="share-tiktok">TikTok</button>
</div>
</div>
<button class="menu-btn" id="btn-restart">PLAY AGAIN</button>
<button class="menu-btn" id="btn-menu">MAIN MENU</button>
</div>
<!-- Wave Announcement -->
<div id="wave-announce">
<div class="wave-num" id="wave-announce-num">WAVE 1</div>
<div class="wave-sub" id="wave-announce-sub">Prepare yourself</div>
</div>
<!-- HUD -->
<div id="hud" class="hidden">
<div id="crosshair">
<div class="ch-line ch-h ch-l"></div>
<div class="ch-line ch-h ch-r"></div>
<div class="ch-line ch-v ch-t"></div>
<div class="ch-line ch-v ch-b"></div>
<div class="ch-dot"></div>
</div>
<div id="health-container">
<div class="bar-row">
<div class="label">HP</div>
<div id="health-track"><div id="health-fill"></div></div>
<div class="bar-value" id="health-value">100/100</div>
</div>
<div class="bar-row">
<div class="label shield-label">SH</div>
<div id="shield-track"><div id="shield-fill"></div></div>
<div class="bar-value" id="shield-value">100/100</div>
</div>
</div>
<div id="ammo-display">
<div class="ammo-count" id="ammo-count">20</div>
<div class="ammo-label">AMMO</div>
<div id="reload-bar"><div id="reload-fill"></div></div>
</div>
<div id="score-display">
<div class="score-label">SCORE</div>
<div class="score-val" id="score-val">0</div>
</div>
<div id="wave-display">
<div class="wave-label">WAVE</div>
<div class="wave-val" id="wave-val">1</div>
</div>
<div id="combo-display">
<div class="combo-val" id="combo-val">x1.0</div>
</div>
<div id="enemies-display">
<div class="enemies-label">ENEMIES</div>
<div class="enemies-val" id="enemies-val">0</div>
</div>
<div id="hit-marker">
<div class="hm-line hm-tl"></div>
<div class="hm-line hm-tr"></div>
<div class="hm-line hm-bl"></div>
<div class="hm-line hm-br"></div>
</div>
</div>
<div id="damage-vignette"></div>
<script type="module" src="/src/main.js"></script>
</body>
</html>