File size: 26,994 Bytes
abd7acc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Call of Duty: Web Ops</title>
    <script src="https://cdn.tailwindcss.com"></script>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <style>
        @keyframes gunRecoil {
            0% { transform: translateY(0) translateX(-50%); }
            50% { transform: translateY(10px) translateX(-50%); }
            100% { transform: translateY(0) translateX(-50%); }
        }
        
        @keyframes muzzleFlash {
            0% { opacity: 0; transform: scale(0.5); }
            50% { opacity: 1; transform: scale(1.2); }
            100% { opacity: 0; transform: scale(0.5); }
        }
        
        @keyframes bloodSplatter {
            0% { opacity: 0; transform: scale(0.5); }
            50% { opacity: 0.8; transform: scale(1); }
            100% { opacity: 0; transform: scale(1.2); }
        }
        
        @keyframes enemyHit {
            0% { transform: translateX(0); }
            25% { transform: translateX(-5px); }
            50% { transform: translateX(5px); }
            75% { transform: translateX(-5px); }
            100% { transform: translateX(0); }
        }
        
        .gun {
            transition: transform 0.1s ease;
        }
        
        .recoil {
            animation: gunRecoil 0.1s ease-out;
        }
        
        .muzzle-flash {
            position: absolute;
            width: 60px;
            height: 60px;
            background: radial-gradient(circle, rgba(255,165,0,0.8) 0%, rgba(255,69,0,0) 70%);
            border-radius: 50%;
            pointer-events: none;
            z-index: 10;
            animation: muzzleFlash 0.05s ease-out;
        }
        
        .blood-effect {
            position: absolute;
            width: 100%;
            height: 100%;
            background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100" viewBox="0 0 100 100"><path d="M30,50 Q40,30 50,50 Q60,70 70,50 Q80,30 50,10 Q20,30 30,50 Z" fill="rgba(139,0,0,0.3)"/></svg>');
            background-size: 200px 200px;
            pointer-events: none;
            z-index: 5;
            animation: bloodSplatter 0.5s ease-out;
        }
        
        .hitmarker {
            position: absolute;
            width: 30px;
            height: 30px;
            border: 2px solid white;
            pointer-events: none;
            z-index: 15;
            opacity: 0;
        }
        
        .hitmarker.active {
            animation: hitmarkerFade 0.3s ease-out;
        }
        
        @keyframes hitmarkerFade {
            0% { transform: scale(0.5); opacity: 1; }
            100% { transform: scale(1.5); opacity: 0; }
        }
        
        .enemy-hit {
            animation: enemyHit 0.3s ease-out;
        }
        
        .scope-overlay {
            position: absolute;
            width: 100%;
            height: 100%;
            background: radial-gradient(circle, transparent 40%, rgba(0,0,0,0.7) 40.2%);
            pointer-events: none;
            z-index: 5;
        }
        
        .health-bar {
            transition: width 0.3s ease;
        }
        
        .ammo-counter {
            text-shadow: 0 0 5px rgba(255,255,255,0.7);
        }
        
        .kill-feed {
            position: absolute;
            top: 20px;
            right: 20px;
            width: 250px;
            max-height: 200px;
            overflow: hidden;
        }
        
        .kill-entry {
            background: rgba(0,0,0,0.7);
            color: white;
            padding: 5px 10px;
            margin-bottom: 5px;
            border-left: 3px solid #e74c3c;
            transform: translateX(100%);
            animation: slideIn 0.3s forwards, fadeOut 0.3s 3s forwards;
        }
        
        @keyframes slideIn {
            to { transform: translateX(0); }
        }
        
        @keyframes fadeOut {
            to { opacity: 0; max-height: 0; padding: 0; margin: 0; }
        }
    </style>
</head>
<body class="bg-gray-900 text-white overflow-hidden h-screen">
    <!-- Blood effect -->
    <div id="bloodEffect" class="blood-effect opacity-0"></div>
    
    <!-- Hitmarker -->
    <div id="hitmarker" class="hitmarker"></div>
    
    <!-- Scope overlay -->
    <div id="scopeOverlay" class="scope-overlay hidden"></div>
    
    <!-- Kill feed -->
    <div id="killFeed" class="kill-feed"></div>
    
    <!-- Game HUD -->
    <div class="absolute bottom-0 left-0 right-0 p-4 z-10">
        <div class="flex justify-between items-end">
            <!-- Health -->
            <div class="bg-gray-800 rounded-lg p-3 w-40">
                <div class="flex items-center mb-1">
                    <i class="fas fa-heartbeat text-red-500 mr-2"></i>
                    <span class="font-bold">HEALTH</span>
                </div>
                <div class="bg-gray-700 h-4 rounded-full overflow-hidden">
                    <div id="healthBar" class="health-bar bg-red-500 h-full rounded-full" style="width: 100%"></div>
                </div>
            </div>
            
            <!-- Ammo -->
            <div class="bg-gray-800 rounded-lg p-3 text-center">
                <div id="ammoCounter" class="ammo-counter text-2xl font-bold">
                    <span id="currentAmmo">30</span> / <span id="totalAmmo">90</span>
                </div>
                <div class="text-xs mt-1">M4A1 | 5.56mm</div>
            </div>
            
            <!-- Score -->
            <div class="bg-gray-800 rounded-lg p-3 w-40 text-right">
                <div class="flex justify-end items-center">
                    <i class="fas fa-skull text-yellow-500 ml-2"></i>
                    <span class="font-bold">KILLS</span>
                </div>
                <div id="killCount" class="text-2xl font-bold">0</div>
            </div>
        </div>
    </div>
    
    <!-- Gun -->
    <div id="gun" class="gun absolute bottom-10 left-1/2 transform -translate-x-1/2 w-64 h-64 z-20">
        <div class="relative w-full h-full">
            <!-- Rifle -->
            <div class="absolute bottom-0 left-1/2 transform -translate-x-1/2 w-48 h-32 bg-gradient-to-r from-gray-700 to-gray-800 rounded-lg">
                <!-- Barrel -->
                <div class="absolute top-0 left-1/2 transform -translate-x-1/2 w-40 h-6 bg-gray-800 rounded-t-lg"></div>
                <!-- Stock -->
                <div class="absolute bottom-0 right-0 w-16 h-24 bg-gray-900 rounded-br-lg"></div>
                <!-- Magazine -->
                <div class="absolute bottom-4 left-4 w-8 h-16 bg-gray-600 rounded"></div>
                <!-- Scope -->
                <div class="absolute top-2 left-1/2 transform -translate-x-1/2 w-12 h-6 bg-gray-900 rounded-lg flex justify-center items-center">
                    <div class="w-1 h-1 bg-red-500 rounded-full"></div>
                </div>
                <!-- Trigger -->
                <div class="absolute bottom-8 right-8 w-4 h-2 bg-gray-900 rounded"></div>
            </div>
            
            <!-- Muzzle flash (hidden by default) -->
            <div id="muzzleFlash" class="muzzle-flash hidden top-10 left-1/2 transform -translate-x-1/2"></div>
        </div>
    </div>
    
    <!-- Enemies container -->
    <div id="enemiesContainer" class="absolute top-0 left-0 w-full h-full"></div>
    
    <!-- Game Over Screen -->
    <div id="gameOverScreen" class="absolute inset-0 bg-black bg-opacity-90 flex flex-col items-center justify-center hidden z-30">
        <div class="bg-gray-800 p-8 rounded-xl max-w-md w-full text-center border border-red-500">
            <h2 class="text-3xl font-bold text-red-500 mb-4">MISSION FAILED</h2>
            <div class="mb-6">
                <p class="text-xl">Total Kills: <span id="finalKills" class="font-bold text-white">0</span></p>
                <p class="text-xl mt-2">Accuracy: <span id="finalAccuracy" class="font-bold text-white">0%</span></p>
            </div>
            <button id="restartBtn" class="bg-gradient-to-r from-red-700 to-gray-900 px-6 py-3 rounded-full font-bold hover:opacity-90 transition border border-red-500 w-full">
                <i class="fas fa-redo mr-2"></i> Redeploy
            </button>
        </div>
    </div>
    
    <!-- Start Screen -->
    <div id="startScreen" class="absolute inset-0 bg-black bg-opacity-90 flex flex-col items-center justify-center z-30">
        <div class="bg-gray-800 p-8 rounded-xl max-w-md w-full text-center border border-red-500">
            <h1 class="text-4xl font-bold bg-gradient-to-r from-red-500 to-yellow-500 bg-clip-text text-transparent mb-6">
                CALL OF DUTY: WEB OPS
            </h1>
            <div class="mb-8">
                <div class="w-full h-40 bg-gray-900 rounded-lg relative overflow-hidden mb-4">
                    <div class="absolute inset-0 flex items-center justify-center">
                        <div class="w-24 h-24 bg-red-500 rounded-full animate-pulse"></div>
                    </div>
                </div>
                <p class="text-gray-300 mb-2">Eliminate all hostile targets</p>
                <p class="text-gray-400 text-sm">Watch your ammo and health</p>
            </div>
            <button id="startBtn" class="bg-gradient-to-r from-red-700 to-gray-900 px-6 py-3 rounded-full font-bold hover:opacity-90 transition border border-red-500 w-full">
                <i class="fas fa-play mr-2"></i> Deploy Now
            </button>
            <div class="mt-6 text-sm text-gray-500">
                <p>Click to shoot | WASD to move | Space to jump</p>
                <p class="mt-2">Right click to aim down sights</p>
            </div>
        </div>
    </div>

    <script>
        document.addEventListener('DOMContentLoaded', () => {
            // Game elements
            const gameContainer = document.body;
            const gun = document.getElementById('gun');
            const muzzleFlash = document.getElementById('muzzleFlash');
            const healthBar = document.getElementById('healthBar');
            const currentAmmo = document.getElementById('currentAmmo');
            const totalAmmo = document.getElementById('totalAmmo');
            const killCount = document.getElementById('killCount');
            const bloodEffect = document.getElementById('bloodEffect');
            const hitmarker = document.getElementById('hitmarker');
            const scopeOverlay = document.getElementById('scopeOverlay');
            const killFeed = document.getElementById('killFeed');
            const startScreen = document.getElementById('startScreen');
            const gameOverScreen = document.getElementById('gameOverScreen');
            const finalKills = document.getElementById('finalKills');
            const finalAccuracy = document.getElementById('finalAccuracy');
            const startBtn = document.getElementById('startBtn');
            const restartBtn = document.getElementById('restartBtn');
            const enemiesContainer = document.getElementById('enemiesContainer');
            
            // Game state
            let gameRunning = false;
            let health = 100;
            let ammo = 30;
            let totalAmmoCount = 90;
            let kills = 0;
            let shotsFired = 0;
            let shotsHit = 0;
            let enemies = [];
            let enemySpawnInterval;
            let gameLoopInterval;
            let isAiming = false;
            let playerPosition = { x: 0, y: 0 };
            let mouseX = 0;
            let mouseY = 0;
            
            // Initialize game
            initGame();
            
            // Event listeners
            startBtn.addEventListener('click', startGame);
            restartBtn.addEventListener('click', startGame);
            
            // Mouse controls
            gameContainer.addEventListener('mousedown', (e) => {
                if (!gameRunning) return;
                
                if (e.button === 0) { // Left click
                    shoot();
                } else if (e.button === 2) { // Right click
                    aimDownSights(true);
                }
            });
            
            gameContainer.addEventListener('mouseup', (e) => {
                if (e.button === 2) { // Right click release
                    aimDownSights(false);
                }
            });
            
            gameContainer.addEventListener('mousemove', (e) => {
                mouseX = e.clientX;
                mouseY = e.clientY;
                
                // Slight gun movement based on mouse position
                if (gameRunning) {
                    const moveX = (mouseX - window.innerWidth / 2) / 50;
                    const moveY = (mouseY - window.innerHeight / 2) / 50;
                    gun.style.transform = `translateX(-50%) translateY(${moveY}px) translateX(${moveX}px)`;
                }
            });
            
            gameContainer.addEventListener('contextmenu', (e) => {
                e.preventDefault(); // Prevent context menu on right click
            });
            
            // Keyboard controls
            document.addEventListener('keydown', (e) => {
                if (!gameRunning) return;
                
                switch (e.key.toLowerCase()) {
                    case 'w':
                        playerPosition.y = -5;
                        break;
                    case 'a':
                        playerPosition.x = -5;
                        break;
                    case 's':
                        playerPosition.y = 5;
                        break;
                    case 'd':
                        playerPosition.x = 5;
                        break;
                    case ' ':
                        // Jump action
                        break;
                    case 'r':
                        reload();
                        break;
                }
            });
            
            document.addEventListener('keyup', (e) => {
                switch (e.key.toLowerCase()) {
                    case 'w':
                    case 's':
                        playerPosition.y = 0;
                        break;
                    case 'a':
                    case 'd':
                        playerPosition.x = 0;
                        break;
                }
            });
            
            // Game functions
            function initGame() {
                // Reset game state
                health = 100;
                ammo = 30;
                totalAmmoCount = 90;
                kills = 0;
                shotsFired = 0;
                shotsHit = 0;
                enemies = [];
                
                // Update UI
                healthBar.style.width = '100%';
                currentAmmo.textContent = ammo;
                totalAmmo.textContent = totalAmmoCount;
                killCount.textContent = kills;
                
                // Clear enemies
                enemiesContainer.innerHTML = '';
                
                // Show start screen
                startScreen.classList.remove('hidden');
                gameOverScreen.classList.add('hidden');
            }
            
            function startGame() {
                initGame();
                
                // Hide screens
                startScreen.classList.add('hidden');
                gameOverScreen.classList.add('hidden');
                
                // Start game
                gameRunning = true;
                
                // Start game loop
                gameLoopInterval = setInterval(updateGame, 16); // ~60fps
                
                // Start spawning enemies
                enemySpawnInterval = setInterval(spawnEnemy, 2000);
                
                // Initial enemy spawn
                for (let i = 0; i < 3; i++) {
                    setTimeout(spawnEnemy, i * 500);
                }
            }
            
            function updateGame() {
                // Move player (simple movement for this demo)
                // In a full game, this would update the camera position
                
                // Move enemies
                enemies.forEach(enemy => {
                    // Simple movement - in a real game this would be more sophisticated AI
                    enemy.element.style.left = `${enemy.x}px`;
                    enemy.element.style.top = `${enemy.y}px`;
                    
                    // Random movement
                    if (Math.random() < 0.02) {
                        enemy.vx = (Math.random() - 0.5) * 2;
                    }
                    if (Math.random() < 0.02) {
                        enemy.vy = (Math.random() - 0.5) * 2;
                    }
                    
                    enemy.x += enemy.vx;
                    enemy.y += enemy.vy;
                    
                    // Keep enemies in bounds
                    enemy.x = Math.max(0, Math.min(window.innerWidth - 50, enemy.x));
                    enemy.y = Math.max(0, Math.min(window.innerHeight - 80, enemy.y));
                    
                    // Random shooting at player
                    if (Math.random() < 0.005) {
                        enemyShoot(enemy);
                    }
                });
                
                // Check if player is dead
                if (health <= 0) {
                    endGame();
                }
            }
            
            function spawnEnemy() {
                if (!gameRunning || enemies.length >= 10) return;
                
                const enemy = document.createElement('div');
                enemy.className = 'absolute w-12 h-20 bg-gray-700 rounded-lg flex flex-col items-center';
                
                // Random position at edges of screen
                const side = Math.floor(Math.random() * 4); // 0: top, 1: right, 2: bottom, 3: left
                let x, y;
                
                switch (side) {
                    case 0: // top
                        x = Math.random() * window.innerWidth;
                        y = -50;
                        break;
                    case 1: // right
                        x = window.innerWidth;
                        y = Math.random() * window.innerHeight;
                        break;
                    case 2: // bottom
                        x = Math.random() * window.innerWidth;
                        y = window.innerHeight;
                        break;
                    case 3: // left
                        x = -50;
                        y = Math.random() * window.innerHeight;
                        break;
                }
                
                enemy.style.left = `${x}px`;
                enemy.style.top = `${y}px`;
                
                // Enemy appearance
                enemy.innerHTML = `
                    <div class="w-10 h-6 bg-gray-800 rounded-t-lg mt-1 flex justify-center items-center">
                        <div class="w-2 h-2 bg-red-500 rounded-full"></div>
                    </div>
                    <div class="w-full h-12 bg-gray-600 rounded-b-lg flex justify-center items-center">
                        <i class="fas fa-skull text-gray-400 text-xl"></i>
                    </div>
                `;
                
                enemiesContainer.appendChild(enemy);
                
                enemies.push({
                    element: enemy,
                    x: x,
                    y: y,
                    vx: (Math.random() - 0.5) * 2,
                    vy: (Math.random() - 0.5) * 2,
                    health: 100
                });
            }
            
            function shoot() {
                if (ammo <= 0) {
                    // Play empty click sound
                    return;
                }
                
                // Deduct ammo
                ammo--;
                shotsFired++;
                currentAmmo.textContent = ammo;
                
                // Gun recoil animation
                gun.classList.add('recoil');
                setTimeout(() => {
                    gun.classList.remove('recoil');
                }, 100);
                
                // Muzzle flash
                muzzleFlash.classList.remove('hidden');
                setTimeout(() => {
                    muzzleFlash.classList.add('hidden');
                }, 50);
                
                // Check for hits
                const hitEnemy = checkHit();
                if (hitEnemy) {
                    shotsHit++;
                    hitEnemy.health -= 34; // 3 shots to kill
                    
                    // Hitmarker
                    hitmarker.style.left = `${mouseX - 15}px`;
                    hitmarker.style.top = `${mouseY - 15}px`;
                    hitmarker.classList.add('active');
                    setTimeout(() => {
                        hitmarker.classList.remove('active');
                    }, 300);
                    
                    // Enemy hit reaction
                    hitEnemy.element.classList.add('enemy-hit');
                    setTimeout(() => {
                        hitEnemy.element.classList.remove('enemy-hit');
                    }, 300);
                    
                    // Check if enemy died
                    if (hitEnemy.health <= 0) {
                        killEnemy(hitEnemy);
                    }
                }
                
                // Reload if empty
                if (ammo === 0 && totalAmmoCount > 0) {
                    setTimeout(reload, 500);
                }
            }
            
            function checkHit() {
                // Simple hit detection - in a real game this would use proper raycasting
                const mousePos = { x: mouseX, y: mouseY };
                
                for (let i = 0; i < enemies.length; i++) {
                    const enemy = enemies[i];
                    const enemyRect = enemy.element.getBoundingClientRect();
                    
                    if (
                        mousePos.x >= enemyRect.left &&
                        mousePos.x <= enemyRect.right &&
                        mousePos.y >= enemyRect.top &&
                        mousePos.y <= enemyRect.bottom
                    ) {
                        return enemy;
                    }
                }
                
                return null;
            }
            
            function killEnemy(enemy) {
                // Remove enemy
                enemy.element.remove();
                enemies = enemies.filter(e => e !== enemy);
                
                // Increase kill count
                kills++;
                killCount.textContent = kills;
                
                // Add to kill feed
                addKillFeed();
                
                // Spawn new enemy after delay
                setTimeout(spawnEnemy, 1000);
            }
            
            function addKillFeed() {
                const killEntry = document.createElement('div');
                killEntry.className = 'kill-entry';
                killEntry.textContent = `You killed Enemy`;
                killFeed.appendChild(killEntry);
                
                // Auto-remove after animation
                setTimeout(() => {
                    killEntry.remove();
                }, 3500);
            }
            
            function enemyShoot(enemy) {
                // Simple chance to hit player
                if (Math.random() < 0.3) {
                    const damage = 10 + Math.floor(Math.random() * 15);
                    health -= damage;
                    healthBar.style.width = `${health}%`;
                    
                    // Blood effect
                    bloodEffect.style.opacity = '0.5';
                    bloodEffect.classList.add('blood-effect');
                    setTimeout(() => {
                        bloodEffect.style.opacity = '0';
                    }, 500);
                    
                    // Check if player died
                    if (health <= 0) {
                        endGame();
                    }
                }
            }
            
            function reload() {
                if (totalAmmoCount <= 0) return;
                
                const ammoNeeded = 30 - ammo;
                const ammoToReload = Math.min(ammoNeeded, totalAmmoCount);
                
                totalAmmoCount -= ammoToReload;
                ammo += ammoToReload;
                
                currentAmmo.textContent = ammo;
                totalAmmo.textContent = totalAmmoCount;
                
                // Play reload sound in a real game
            }
            
            function aimDownSights(aiming) {
                isAiming = aiming;
                
                if (aiming) {
                    scopeOverlay.classList.remove('hidden');
                    gun.style.transform = 'translateX(-50%) scale(1.2)';
                } else {
                    scopeOverlay.classList.add('hidden');
                    gun.style.transform = 'translateX(-50%)';
                }
            }
            
            function endGame() {
                gameRunning = false;
                
                // Stop game loops
                clearInterval(gameLoopInterval);
                clearInterval(enemySpawnInterval);
                
                // Calculate accuracy
                const accuracy = shotsFired > 0 ? Math.round((shotsHit / shotsFired) * 100) : 0;
                
                // Update final stats
                finalKills.textContent = kills;
                finalAccuracy.textContent = `${accuracy}%`;
                
                // Show game over screen
                gameOverScreen.classList.remove('hidden');
            }
        });
    </script>
<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=Amirreza12cv0/call-of-duty" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
</html>