Arda0161 commited on
Commit
3b9549e
·
verified ·
1 Parent(s): 55ab959

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +1514 -19
index.html CHANGED
@@ -1,19 +1,1514 @@
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>TACTICAL BODYCAM: MULTI-ROOM MESSY SAFEHOUSES</title>
7
+ <style>
8
+ * {
9
+ margin: 0;
10
+ padding: 0;
11
+ box-sizing: border-box;
12
+ user-select: none;
13
+ }
14
+ body, html {
15
+ width: 100%;
16
+ height: 100%;
17
+ overflow: hidden;
18
+ background-color: #030305;
19
+ font-family: 'Courier New', Courier, monospace;
20
+ }
21
+ #game-container {
22
+ width: 100%;
23
+ height: 100%;
24
+ position: absolute;
25
+ top: 0;
26
+ left: 0;
27
+ }
28
+ .bodycam-overlay {
29
+ position: absolute;
30
+ top: 0;
31
+ left: 0;
32
+ width: 100%;
33
+ height: 100%;
34
+ pointer-events: none;
35
+ z-index: 10;
36
+ box-shadow: inset 0 0 150px rgba(0,0,0,0.95);
37
+ }
38
+ #nv-filter {
39
+ position: absolute;
40
+ top: 0;
41
+ left: 0;
42
+ width: 100%;
43
+ height: 100%;
44
+ pointer-events: none;
45
+ z-index: 8;
46
+ background: rgba(0, 255, 60, 0.12);
47
+ mix-blend-mode: screen;
48
+ display: none;
49
+ box-shadow: inset 0 0 100px rgba(0,255,60,0.4);
50
+ }
51
+ #sniper-scope {
52
+ position: absolute;
53
+ top: 0;
54
+ left: 0;
55
+ width: 100%;
56
+ height: 100%;
57
+ pointer-events: none;
58
+ z-index: 25;
59
+ display: none;
60
+ background: radial-gradient(circle, transparent 28%, rgba(0,0,0,0.92) 62%);
61
+ border: 2px solid rgba(0, 255, 204, 0.5);
62
+ }
63
+ .scope-crosshair-h {
64
+ position: absolute;
65
+ top: 50%;
66
+ left: 0;
67
+ width: 100%;
68
+ height: 1px;
69
+ background: rgba(0, 255, 204, 0.7);
70
+ }
71
+ .scope-crosshair-v {
72
+ position: absolute;
73
+ top: 0;
74
+ left: 50%;
75
+ width: 1px;
76
+ height: 100%;
77
+ background: rgba(0, 255, 204, 0.7);
78
+ }
79
+ .hud-top-left {
80
+ position: absolute;
81
+ top: 30px;
82
+ left: 40px;
83
+ color: #fff;
84
+ font-size: 20px;
85
+ font-weight: bold;
86
+ letter-spacing: 2px;
87
+ text-shadow: 0 0 6px rgba(255,255,255,0.8);
88
+ display: flex;
89
+ align-items: center;
90
+ gap: 15px;
91
+ }
92
+ .rec-dot {
93
+ width: 14px;
94
+ height: 14px;
95
+ background-color: #ff0000;
96
+ border-radius: 50%;
97
+ box-shadow: 0 0 12px #ff0000;
98
+ animation: blink 1s infinite;
99
+ }
100
+ @keyframes blink {
101
+ 0% { opacity: 1; }
102
+ 50% { opacity: 0.1; }
103
+ 100% { opacity: 1; }
104
+ }
105
+ .hud-top-right {
106
+ position: absolute;
107
+ top: 30px;
108
+ right: 40px;
109
+ color: #00ffcc;
110
+ font-size: 18px;
111
+ text-align: right;
112
+ text-shadow: 0 0 6px rgba(0,255,204,0.6);
113
+ }
114
+ #radio-hud {
115
+ position: absolute;
116
+ top: 100px;
117
+ left: 40px;
118
+ background: rgba(10, 15, 25, 0.85);
119
+ border-left: 4px solid #00ffcc;
120
+ color: #00ffcc;
121
+ padding: 10px 18px;
122
+ font-size: 15px;
123
+ border-radius: 4px;
124
+ opacity: 0;
125
+ transition: opacity 0.4s ease;
126
+ box-shadow: 0 0 15px rgba(0,255,204,0.3);
127
+ max-width: 480px;
128
+ }
129
+ #interaction-prompt {
130
+ position: absolute;
131
+ top: 58%;
132
+ left: 50%;
133
+ transform: translate(-50%, -50%);
134
+ color: #ffaa00;
135
+ font-size: 16px;
136
+ font-weight: bold;
137
+ letter-spacing: 2px;
138
+ text-shadow: 0 0 8px rgba(255,170,0,0.8);
139
+ display: none;
140
+ z-index: 15;
141
+ background: rgba(0,0,0,0.7);
142
+ padding: 8px 16px;
143
+ border: 1px solid #ffaa00;
144
+ border-radius: 4px;
145
+ }
146
+ #world-markers {
147
+ position: absolute;
148
+ top: 0;
149
+ left: 0;
150
+ width: 100%;
151
+ height: 100%;
152
+ pointer-events: none;
153
+ z-index: 9;
154
+ }
155
+ .waypoint {
156
+ position: absolute;
157
+ transform: translate(-50%, -50%);
158
+ padding: 4px 8px;
159
+ font-size: 12px;
160
+ font-weight: bold;
161
+ border-radius: 3px;
162
+ letter-spacing: 1px;
163
+ white-space: nowrap;
164
+ display: none;
165
+ box-shadow: 0 0 10px rgba(0,0,0,0.8);
166
+ }
167
+ .wp-cover { background: rgba(0, 150, 255, 0.75); color: #fff; border: 1px solid #00ffcc; }
168
+ .wp-enemy { background: rgba(180, 0, 0, 0.75); color: #fff; border: 1px solid #ff3333; }
169
+ .wp-item { background: rgba(200, 150, 0, 0.75); color: #fff; border: 1px solid #ffcc00; }
170
+ .wp-ammo { background: rgba(0, 200, 100, 0.75); color: #fff; border: 1px solid #00ff88; }
171
+
172
+ .hud-bottom {
173
+ position: absolute;
174
+ bottom: 30px;
175
+ left: 40px;
176
+ right: 40px;
177
+ display: flex;
178
+ justify-content: space-between;
179
+ align-items: flex-end;
180
+ color: #fff;
181
+ text-shadow: 0 0 5px rgba(0,0,0,0.9);
182
+ }
183
+ .stats-box {
184
+ background: rgba(10, 10, 15, 0.85);
185
+ border: 1px solid rgba(0, 255, 204, 0.4);
186
+ padding: 15px 25px;
187
+ backdrop-filter: blur(8px);
188
+ border-radius: 6px;
189
+ box-shadow: 0 0 20px rgba(0,0,0,0.6);
190
+ }
191
+ .stat-line {
192
+ font-size: 16px;
193
+ margin-bottom: 5px;
194
+ letter-spacing: 1px;
195
+ }
196
+ .heartrate-container {
197
+ width: 350px;
198
+ height: 80px;
199
+ background: rgba(10, 10, 15, 0.85);
200
+ border: 1px solid rgba(255, 0, 0, 0.5);
201
+ position: relative;
202
+ overflow: hidden;
203
+ border-radius: 6px;
204
+ box-shadow: 0 0 15px rgba(255,0,0,0.2);
205
+ }
206
+ #ecg-canvas {
207
+ width: 100%;
208
+ height: 100%;
209
+ }
210
+ .crosshair {
211
+ position: absolute;
212
+ top: 50%;
213
+ left: 50%;
214
+ width: 6px;
215
+ height: 6px;
216
+ background: rgba(255,255,255,0.7);
217
+ border-radius: 50%;
218
+ transform: translate(-50%, -50%);
219
+ pointer-events: none;
220
+ box-shadow: 0 0 4px #000;
221
+ }
222
+ #blood-overlay {
223
+ position: absolute;
224
+ top: 0;
225
+ left: 0;
226
+ width: 100%;
227
+ height: 100%;
228
+ background: radial-gradient(circle, rgba(140,0,0,0) 25%, rgba(120,0,0,0.95) 95%);
229
+ opacity: 0;
230
+ pointer-events: none;
231
+ transition: opacity 0.3s ease;
232
+ z-index: 5;
233
+ }
234
+ #instructions {
235
+ position: absolute;
236
+ top: 0;
237
+ left: 0;
238
+ width: 100%;
239
+ height: 100%;
240
+ background: rgba(3, 3, 5, 0.96);
241
+ display: flex;
242
+ flex-direction: column;
243
+ justify-content: center;
244
+ align-items: center;
245
+ z-index: 100;
246
+ color: #fff;
247
+ text-align: center;
248
+ padding: 20px;
249
+ }
250
+ #instructions h1 {
251
+ font-size: 40px;
252
+ color: #ff3333;
253
+ margin-bottom: 15px;
254
+ letter-spacing: 3px;
255
+ text-shadow: 0 0 20px rgba(255,51,51,0.6);
256
+ }
257
+ #instructions p {
258
+ font-size: 15px;
259
+ color: #ccc;
260
+ max-width: 800px;
261
+ line-height: 1.6;
262
+ margin-bottom: 30px;
263
+ }
264
+ .btn-start {
265
+ background: #ff3333;
266
+ color: white;
267
+ border: none;
268
+ padding: 15px 40px;
269
+ font-size: 18px;
270
+ font-weight: bold;
271
+ cursor: pointer;
272
+ letter-spacing: 2px;
273
+ transition: all 0.2s;
274
+ box-shadow: 0 0 25px rgba(255,51,51,0.5);
275
+ font-family: 'Courier New', Courier, monospace;
276
+ border-radius: 4px;
277
+ }
278
+ .btn-start:hover {
279
+ background: #ff5555;
280
+ box-shadow: 0 0 35px rgba(255,85,85,0.8);
281
+ transform: scale(1.05);
282
+ }
283
+ .indicator-badge {
284
+ position: absolute;
285
+ top: 80px;
286
+ left: 40px;
287
+ color: #ffff00;
288
+ font-size: 14px;
289
+ letter-spacing: 1px;
290
+ display: none;
291
+ text-shadow: 0 0 5px rgba(255,255,0,0.8);
292
+ }
293
+ #nv-ind {
294
+ position: absolute;
295
+ top: 105px;
296
+ left: 40px;
297
+ color: #00ff44;
298
+ font-size: 14px;
299
+ letter-spacing: 1px;
300
+ display: none;
301
+ text-shadow: 0 0 8px rgba(0,255,68,0.8);
302
+ }
303
+ #laser-ind {
304
+ position: absolute;
305
+ top: 130px;
306
+ left: 40px;
307
+ color: #ff2222;
308
+ font-size: 14px;
309
+ letter-spacing: 1px;
310
+ display: none;
311
+ text-shadow: 0 0 8px rgba(255,34,34,0.8);
312
+ }
313
+ </style>
314
+ </head>
315
+ <body>
316
+
317
+ <div id="instructions">
318
+ <h1>TACTICAL BODYCAM: MESSY SAFEHOUSES</h1>
319
+ <p>Multiple detailed safehouses added with messy rooms (debris, flipped tables, clutter). Heart rate accelerates dynamically under panic/combat, with fast ECG responsiveness.</p>
320
+ <p style="color: #00ffcc; margin-bottom: 20px;">
321
+ [W, A, S, D] Move | [MOUSE] Look | [K] Night Vision | [1, 2, 3] Switch Weapon<br>
322
+ [LEFT CLICK] Shoot | [R] Reload | [G] Throw Grenade<br>
323
+ <strong style="color: #ffaa00;">[HOLD U] Breach House Doors</strong> | <strong style="color: #ff5555;">[M] Stand Still & Press to Take Medication (Lowers Heart Rate)</strong><br>
324
+ <strong style="color: #00ffcc;">[RIGHT CLICK TAP] Toggle Laser (Rifles) | [RIGHT CLICK HOLD] Sniper Scope (Sniper)</strong>
325
+ </p>
326
+ <button class="btn-start" id="start-btn">START OPERATION</button>
327
+ </div>
328
+
329
+ <div id="game-container"></div>
330
+ <div id="blood-overlay"></div>
331
+ <div id="nv-filter"></div>
332
+ <div id="sniper-scope">
333
+ <div class="scope-crosshair-h"></div>
334
+ <div class="scope-crosshair-v"></div>
335
+ </div>
336
+ <div id="interaction-prompt">HOLD [U] TO BREACH DOOR</div>
337
+
338
+ <div class="bodycam-overlay">
339
+ <div class="hud-top-left">
340
+ <div class="rec-dot"></div>
341
+ <span>REC [ 4K / 60FPS - BODYCAM ]</span>
342
+ </div>
343
+ <div class="indicator-badge" id="cam-ind">SECURITY CAMERA ACTIVE [PRESS C TO EXIT]</div>
344
+ <div id="nv-ind">NIGHT VISION ACTIVE [GEN-3 NVG]</div>
345
+ <div id="laser-ind">TACTICAL LASER ACTIVE</div>
346
+ <div id="radio-hud">ALPHA-2: Safehouse interiors are heavily cluttered. Clear every room!</div>
347
+
348
+ <div id="world-markers">
349
+ <div id="marker-cover" class="waypoint wp-cover">ZONE [0m]</div>
350
+ <div id="marker-enemy" class="waypoint wp-enemy">HOSTILE [0m]</div>
351
+ <div id="marker-item" class="waypoint wp-item">KEYCARD [0m]</div>
352
+ <div id="marker-ammo" class="waypoint wp-ammo">AMMO [0m]</div>
353
+ </div>
354
+
355
+ <div class="hud-top-right" id="score-display">
356
+ CASH: $0<br>
357
+ LEVEL: 1 | ENEMIES: 8 | KEYCARDS: 0/2
358
+ </div>
359
+ <div class="crosshair"></div>
360
+ <div class="hud-bottom">
361
+ <div class="stats-box">
362
+ <div class="stat-line" id="hp-display">HP: 100 HP</div>
363
+ <div class="stat-line" id="ammo-display">AMMO: 30 / 90</div>
364
+ <div class="stat-line" id="weapon-display">WEAPON: M4A1-S TACTICAL</div>
365
+ </div>
366
+ <div class="heartrate-container">
367
+ <canvas id="ecg-canvas"></canvas>
368
+ </div>
369
+ </div>
370
+ </div>
371
+
372
+ <!-- Three.js CDN -->
373
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r128/three.min.js"></script>
374
+ <script>
375
+ let scene, camera, renderer;
376
+ let player = {
377
+ x: 0, z: 68, rotY: 0, rotX: 0,
378
+ targetRotY: 0, targetRotX: 0,
379
+ hp: 100, money: 0, keycards: 0, isDead: false
380
+ };
381
+
382
+ const weapons = [
383
+ { name: "M4A1-S TACTICAL", ammo: 30, reserve: 90, damage: 50, color: 0x1f242d },
384
+ { name: "AK-47 ELITE", ammo: 30, reserve: 90, damage: 70, color: 0x5c4033 },
385
+ { name: "AWP SNIPER", ammo: 10, reserve: 30, damage: 100, color: 0x113322 }
386
+ ];
387
+ let currentWeaponIndex = 0;
388
+ let currentLevel = 1;
389
+ const maxLevel = 3;
390
+
391
+ let keys = { w: false, a: false, s: false, d: false, u: false };
392
+ let isPointerLocked = false;
393
+ let enemies = [];
394
+ let grenades = [];
395
+ let bloodDecals = [];
396
+ let keycards = [];
397
+ let ammoDrops = [];
398
+ let doors = [];
399
+ let securityCameras = [];
400
+ let flashingLights = [];
401
+ let currentCamIndex = -1;
402
+ let nightVisionActive = false;
403
+ let laserActive = false;
404
+ let sniperZoomActive = false;
405
+ let laserMesh = null;
406
+ let audioCtx = null;
407
+ let walls = [];
408
+ let weaponModelGroup;
409
+ let uKeyHoldTime = 0;
410
+ let targetDoorToBreach = null;
411
+
412
+ const mapSize = 160;
413
+ const instructionsEl = document.getElementById('instructions');
414
+ const startBtn = document.getElementById('start-btn');
415
+ const hpDisplay = document.getElementById('hp-display');
416
+ const ammoDisplay = document.getElementById('ammo-display');
417
+ const scoreDisplay = document.getElementById('score-display');
418
+ const weaponDisplay = document.getElementById('weapon-display');
419
+ const bloodOverlay = document.getElementById('blood-overlay');
420
+ const camInd = document.getElementById('cam-ind');
421
+ const nvInd = document.getElementById('nv-ind');
422
+ const laserInd = document.getElementById('laser-ind');
423
+ const nvFilter = document.getElementById('nv-filter');
424
+ const sniperScope = document.getElementById('sniper-scope');
425
+ const radioHud = document.getElementById('radio-hud');
426
+ const interactionPrompt = document.getElementById('interaction-prompt');
427
+
428
+ const markerCover = document.getElementById('marker-cover');
429
+ const markerEnemy = document.getElementById('marker-enemy');
430
+ const markerItem = document.getElementById('marker-item');
431
+ const markerAmmo = document.getElementById('marker-ammo');
432
+
433
+ const ecgCanvas = document.getElementById('ecg-canvas');
434
+ const ecgCtx = ecgCanvas.getContext('2d');
435
+ ecgCanvas.width = 350;
436
+ ecgCanvas.height = 80;
437
+ let ecgOffset = 0;
438
+ let heartRate = 78;
439
+ let lastHeartbeatTime = 0;
440
+
441
+ const radioDialogues = [
442
+ "Alpha-2: Rooms are completely trashed. Watch your corners.",
443
+ "Alpha-2: Check inside the safehouses for enemy positions.",
444
+ "Alpha-2: Heart rate spiking! Stand still and press M for blood pressure medication.",
445
+ "Alpha-2: Hold U in front of doors to breach locked rooms.",
446
+ "Alpha-2: Pick up ammo drops from neutralized hostiles."
447
+ ];
448
+
449
+ window.addEventListener('contextmenu', e => e.preventDefault());
450
+
451
+ startBtn.addEventListener('click', () => {
452
+ instructionsEl.style.display = 'none';
453
+ document.body.requestPointerLock();
454
+ initAudio();
455
+ initGame();
456
+ animate();
457
+ startRadioChatter();
458
+ });
459
+
460
+ document.addEventListener('pointerlockchange', () => {
461
+ isPointerLocked = document.pointerLockElement === document.body;
462
+ });
463
+
464
+ window.addEventListener('resize', () => {
465
+ if (camera && renderer) {
466
+ camera.aspect = window.innerWidth / window.innerHeight;
467
+ camera.updateProjectionMatrix();
468
+ renderer.setSize(window.innerWidth, window.innerHeight);
469
+ }
470
+ });
471
+
472
+ function initAudio() {
473
+ if (!audioCtx) audioCtx = new (window.AudioContext || window.webkitAudioContext)();
474
+ }
475
+
476
+ function playGunshotSound() {
477
+ if (!audioCtx) return;
478
+ let osc = audioCtx.createOscillator();
479
+ let gain = audioCtx.createGain();
480
+ osc.type = currentWeaponIndex === 2 ? 'square' : 'sawtooth';
481
+ osc.frequency.setValueAtTime(currentWeaponIndex === 2 ? 70 : 160, audioCtx.currentTime);
482
+ osc.frequency.exponentialRampToValueAtTime(10, audioCtx.currentTime + 0.35);
483
+ gain.gain.setValueAtTime(0.7, audioCtx.currentTime);
484
+ gain.gain.linearRampToValueAtTime(0.01, audioCtx.currentTime + 0.35);
485
+ osc.connect(gain);
486
+ gain.connect(audioCtx.destination);
487
+ osc.start();
488
+ osc.stop(audioCtx.currentTime + 0.35);
489
+ }
490
+
491
+ function playReloadSound() {
492
+ if (!audioCtx) return;
493
+ let osc = audioCtx.createOscillator();
494
+ let gain = audioCtx.createGain();
495
+ osc.type = 'triangle';
496
+ osc.frequency.setValueAtTime(320, audioCtx.currentTime);
497
+ osc.frequency.setValueAtTime(520, audioCtx.currentTime + 0.15);
498
+ gain.gain.setValueAtTime(0.25, audioCtx.currentTime);
499
+ gain.gain.linearRampToValueAtTime(0.01, audioCtx.currentTime + 0.35);
500
+ osc.connect(gain);
501
+ gain.connect(audioCtx.destination);
502
+ osc.start();
503
+ osc.stop(audioCtx.currentTime + 0.35);
504
+ }
505
+
506
+ function playNVSound() {
507
+ if (!audioCtx) return;
508
+ let osc = audioCtx.createOscillator();
509
+ let gain = audioCtx.createGain();
510
+ osc.type = 'sine';
511
+ osc.frequency.setValueAtTime(1200, audioCtx.currentTime);
512
+ osc.frequency.exponentialRampToValueAtTime(400, audioCtx.currentTime + 0.2);
513
+ gain.gain.setValueAtTime(0.3, audioCtx.currentTime);
514
+ gain.gain.linearRampToValueAtTime(0.01, audioCtx.currentTime + 0.2);
515
+ osc.connect(gain);
516
+ gain.connect(audioCtx.destination);
517
+ osc.start();
518
+ osc.stop(audioCtx.currentTime + 0.2);
519
+ }
520
+
521
+ function playHeartbeatThump() {
522
+ if (!audioCtx) return;
523
+ let osc = audioCtx.createOscillator();
524
+ let gain = audioCtx.createGain();
525
+ osc.type = 'sine';
526
+ osc.frequency.setValueAtTime(90, audioCtx.currentTime);
527
+ osc.frequency.exponentialRampToValueAtTime(30, audioCtx.currentTime + 0.12);
528
+ gain.gain.setValueAtTime(0.55, audioCtx.currentTime);
529
+ gain.gain.linearRampToValueAtTime(0.01, audioCtx.currentTime + 0.15);
530
+ osc.connect(gain);
531
+ gain.connect(audioCtx.destination);
532
+ osc.start();
533
+ osc.stop(audioCtx.currentTime + 0.15);
534
+ }
535
+
536
+ function playPillSound() {
537
+ if (!audioCtx) return;
538
+ let osc = audioCtx.createOscillator();
539
+ let gain = audioCtx.createGain();
540
+ osc.type = 'sine';
541
+ osc.frequency.setValueAtTime(400, audioCtx.currentTime);
542
+ osc.frequency.exponentialRampToValueAtTime(800, audioCtx.currentTime + 0.3);
543
+ gain.gain.setValueAtTime(0.4, audioCtx.currentTime);
544
+ gain.gain.linearRampToValueAtTime(0.01, audioCtx.currentTime + 0.3);
545
+ osc.connect(gain);
546
+ gain.connect(audioCtx.destination);
547
+ osc.start();
548
+ osc.stop(audioCtx.currentTime + 0.3);
549
+ }
550
+
551
+ function playBreachSound() {
552
+ if (!audioCtx) return;
553
+ let osc = audioCtx.createOscillator();
554
+ let gain = audioCtx.createGain();
555
+ osc.type = 'sawtooth';
556
+ osc.frequency.setValueAtTime(180, audioCtx.currentTime);
557
+ osc.frequency.exponentialRampToValueAtTime(40, audioCtx.currentTime + 0.4);
558
+ gain.gain.setValueAtTime(0.8, audioCtx.currentTime);
559
+ gain.gain.linearRampToValueAtTime(0.01, audioCtx.currentTime + 0.4);
560
+ osc.connect(gain);
561
+ gain.connect(audioCtx.destination);
562
+ osc.start();
563
+ osc.stop(audioCtx.currentTime + 0.4);
564
+ }
565
+
566
+ function playExplosionSound() {
567
+ if (!audioCtx) return;
568
+ let osc = audioCtx.createOscillator();
569
+ let gain = audioCtx.createGain();
570
+ osc.type = 'sawtooth';
571
+ osc.frequency.setValueAtTime(120, audioCtx.currentTime);
572
+ osc.frequency.exponentialRampToValueAtTime(20, audioCtx.currentTime + 0.6);
573
+ gain.gain.setValueAtTime(0.9, audioCtx.currentTime);
574
+ gain.gain.linearRampToValueAtTime(0.01, audioCtx.currentTime + 0.6);
575
+ osc.connect(gain);
576
+ gain.connect(audioCtx.destination);
577
+ osc.start();
578
+ osc.stop(audioCtx.currentTime + 0.6);
579
+ }
580
+
581
+ function playFlatlineSound() {
582
+ if (!audioCtx) return;
583
+ let osc = audioCtx.createOscillator();
584
+ let gain = audioCtx.createGain();
585
+ osc.type = 'sine';
586
+ osc.frequency.setValueAtTime(800, audioCtx.currentTime);
587
+ gain.gain.setValueAtTime(0.4, audioCtx.currentTime);
588
+ gain.gain.linearRampToValueAtTime(0.01, audioCtx.currentTime + 2.5);
589
+ osc.connect(gain);
590
+ gain.connect(audioCtx.destination);
591
+ osc.start();
592
+ osc.stop(audioCtx.currentTime + 2.5);
593
+ }
594
+
595
+ function speakRadio(text) {
596
+ if ('speechSynthesis' in window) {
597
+ let utterance = new SpeechSynthesisUtterance(text);
598
+ utterance.lang = 'en-US';
599
+ utterance.pitch = 0.70;
600
+ utterance.rate = 1.05;
601
+ window.speechSynthesis.speak(utterance);
602
+ }
603
+ radioHud.innerText = text;
604
+ radioHud.style.opacity = '1';
605
+ setTimeout(() => { radioHud.style.opacity = '0'; }, 4500);
606
+ }
607
+
608
+ function startRadioChatter() {
609
+ setInterval(() => {
610
+ if (!player.isDead && isPointerLocked && currentCamIndex === -1) {
611
+ let msg = radioDialogues[Math.floor(Math.random() * radioDialogues.length)];
612
+ if (heartRate > 130 && Math.random() > 0.4) {
613
+ msg = "Alpha-2: Critical heart rate! Stand still and press M for medication!";
614
+ }
615
+ speakRadio(msg);
616
+ }
617
+ }, 15000);
618
+ }
619
+
620
+ function createProceduralTexture(type) {
621
+ const canvas = document.createElement('canvas');
622
+ canvas.width = 512;
623
+ canvas.height = 512;
624
+ const ctx = canvas.getContext('2d');
625
+
626
+ if (type === 'concrete') {
627
+ ctx.fillStyle = '#0f131a';
628
+ ctx.fillRect(0, 0, 512, 512);
629
+ ctx.strokeStyle = '#182030';
630
+ ctx.lineWidth = 6;
631
+ ctx.strokeRect(0, 0, 512, 512);
632
+ for (let i = 0; i < 3500; i++) {
633
+ ctx.fillStyle = Math.random() > 0.5 ? '#151d2b' : '#080b12';
634
+ ctx.fillRect(Math.random()*512, Math.random()*512, 4, 4);
635
+ }
636
+ } else if (type === 'brick') {
637
+ ctx.fillStyle = '#1c1b1a';
638
+ ctx.fillRect(0, 0, 512, 512);
639
+ ctx.strokeStyle = '#0d0c0b';
640
+ ctx.lineWidth = 4;
641
+ for (let y = 0; y < 512; y += 32) {
642
+ ctx.beginPath();
643
+ ctx.moveTo(0, y);
644
+ ctx.lineTo(512, y);
645
+ ctx.stroke();
646
+ let offset = (y / 32) % 2 === 0 ? 0 : 32;
647
+ for (let x = offset; x < 512; x += 64) {
648
+ ctx.strokeRect(x, y, 64, 32);
649
+ }
650
+ }
651
+ }
652
+ return new THREE.CanvasTexture(canvas);
653
+ }
654
+
655
+ function initGame() {
656
+ scene = new THREE.Scene();
657
+ scene.background = new THREE.Color(0x020307);
658
+ scene.fog = new THREE.FogExp2(0x020307, 0.020);
659
+
660
+ camera = new THREE.PerspectiveCamera(70, window.innerWidth / window.innerHeight, 0.1, 1000);
661
+ camera.rotation.order = 'YXZ';
662
+
663
+ renderer = new THREE.WebGLRenderer({ antialias: true });
664
+ renderer.setSize(window.innerWidth, window.innerHeight);
665
+ renderer.shadowMap.enabled = true;
666
+ renderer.shadowMap.type = THREE.PCFSoftShadowMap;
667
+ document.getElementById('game-container').appendChild(renderer.domElement);
668
+
669
+ const ambientLight = new THREE.AmbientLight(0x121824, 1.8);
670
+ scene.add(ambientLight);
671
+
672
+ const dirLight = new THREE.DirectionalLight(0x335588, 1.2);
673
+ dirLight.position.set(70, 100, 70);
674
+ dirLight.castShadow = true;
675
+ dirLight.shadow.mapSize.width = 2048;
676
+ dirLight.shadow.mapSize.height = 2048;
677
+ scene.add(dirLight);
678
+
679
+ const concreteTex = createProceduralTexture('concrete');
680
+ concreteTex.wrapS = THREE.RepeatWrapping;
681
+ concreteTex.wrapT = THREE.RepeatWrapping;
682
+ concreteTex.repeat.set(16, 16);
683
+
684
+ const floorGeo = new THREE.PlaneGeometry(mapSize, mapSize);
685
+ const floorMat = new THREE.MeshStandardMaterial({ map: concreteTex, roughness: 0.6 });
686
+ const floor = new THREE.Mesh(floorGeo, floorMat);
687
+ floor.rotation.x = -Math.PI / 2;
688
+ floor.receiveShadow = true;
689
+ scene.add(floor);
690
+
691
+ const ceiling = new THREE.Mesh(floorGeo, new THREE.MeshStandardMaterial({ color: 0x05070a }));
692
+ ceiling.position.y = 14;
693
+ ceiling.rotation.x = Math.PI / 2;
694
+ scene.add(ceiling);
695
+
696
+ createMapAssets();
697
+ setupBlinkingLights();
698
+ setupSecurityCameras();
699
+ spawnKeycards(2);
700
+ spawnEnemies(7 + currentLevel * 3);
701
+ updateWeaponModel();
702
+
703
+ window.addEventListener('keydown', onKeyDown);
704
+ window.addEventListener('keyup', onKeyUp);
705
+ window.addEventListener('mousemove', onMouseMove);
706
+ window.addEventListener('mousedown', onMouseDown);
707
+ window.addEventListener('mouseup', onMouseUp);
708
+ updateHUD();
709
+ }
710
+
711
+ function createMapAssets() {
712
+ const brickTex = createProceduralTexture('brick');
713
+ const houseMat = new THREE.MeshStandardMaterial({ map: brickTex, roughness: 0.5 });
714
+ const darkInteriorMat = new THREE.MeshStandardMaterial({ color: 0x090b10, roughness: 0.8 });
715
+ const doorMat = new THREE.MeshStandardMaterial({ color: 0x2b1d12, metalness: 0.3 });
716
+ const woodMat = new THREE.MeshStandardMaterial({ color: 0x24170e, roughness: 0.7 });
717
+ const trashMat = new THREE.MeshStandardMaterial({ color: 0x1f1f2b, roughness: 0.9 });
718
+
719
+ createWall(0, 7, -mapSize/2, mapSize, 14, 3, houseMat);
720
+ createWall(0, 7, mapSize/2, mapSize, 14, 3, houseMat);
721
+ createWall(-mapSize/2, 7, 0, 3, 14, mapSize, houseMat);
722
+ createWall(mapSize/2, 7, 0, 3, 14, mapSize, houseMat);
723
+
724
+ // 4 Adet Detaylı, Dağınık Ev (Safehouse)
725
+ buildMessyHouse(-38, -38, houseMat, darkInteriorMat, doorMat, woodMat, trashMat);
726
+ buildMessyHouse(38, -38, houseMat, darkInteriorMat, doorMat, woodMat, trashMat);
727
+ buildMessyHouse(-38, 38, houseMat, darkInteriorMat, doorMat, woodMat, trashMat);
728
+ buildMessyHouse(38, 38, houseMat, darkInteriorMat, doorMat, woodMat, trashMat);
729
+ }
730
+
731
+ function setupBlinkingLights() {
732
+ // Yanıp sönen ışıklar çok azaltıldı ve yumuşatıldı
733
+ const lightConfigs = [
734
+ { x: -38, z: -38, color: 0xff0055, speed: 0.002 },
735
+ { x: 38, z: 38, color: 0x00ffcc, speed: 0.0025 }
736
+ ];
737
+
738
+ lightConfigs.forEach(cfg => {
739
+ const pointLight = new THREE.PointLight(cfg.color, 1.8, 45);
740
+ pointLight.position.set(cfg.x, 7, cfg.z);
741
+ scene.add(pointLight);
742
+
743
+ const bulbGeo = new THREE.SphereGeometry(0.35, 8, 8);
744
+ const bulbMat = new THREE.MeshBasicMaterial({ color: cfg.color });
745
+ const bulbMesh = new THREE.Mesh(bulbGeo, bulbMat);
746
+ bulbMesh.position.set(cfg.x, 13.6, cfg.z);
747
+ scene.add(bulbMesh);
748
+
749
+ flashingLights.push({
750
+ light: pointLight,
751
+ speed: cfg.speed,
752
+ offset: Math.random() * Math.PI * 2
753
+ });
754
+ });
755
+ }
756
+
757
+ function buildMessyHouse(cx, cz, wallMat, interiorMat, doorMat, woodMat, trashMat) {
758
+ let width = 32, depth = 32, floorHeight = 6;
759
+
760
+ // Dış duvarlar
761
+ createWall(cx - width/2, floorHeight, cz, 2, floorHeight*2, depth, wallMat);
762
+ createWall(cx + width/2, floorHeight, cz, 2, floorHeight*2, depth, wallMat);
763
+ createWall(cx, floorHeight, cz - depth/2, width, floorHeight*2, 2, wallMat);
764
+ createWall(cx, floorHeight, cz + depth/2, width, floorHeight*2, 2, wallMat);
765
+
766
+ // Tavan
767
+ const ceilingGeo = new THREE.BoxGeometry(width, 0.5, depth);
768
+ const ceilingMesh = new THREE.Mesh(ceilingGeo, interiorMat);
769
+ ceilingMesh.position.set(cx, floorHeight, cz);
770
+ ceilingMesh.receiveShadow = true;
771
+ ceilingMesh.castShadow = true;
772
+ scene.add(ceilingMesh);
773
+ walls.push({ x: cx, z: cz, w: width, d: depth });
774
+
775
+ // İç Odalar (Çoklu oda bölmeleri)
776
+ createWall(cx - 5, floorHeight/2, cz - 3, 1, floorHeight, 16, interiorMat);
777
+ createWall(cx + 6, floorHeight/2, cz + 4, 14, floorHeight, 1, interiorMat);
778
+ createWall(cx - 2, floorHeight/2, cz + 8, 1, floorHeight, 12, interiorMat);
779
+
780
+ let y2 = floorHeight + floorHeight/2;
781
+ createWall(cx, y2, cz, 1.2, floorHeight, depth - 4, interiorMat);
782
+ createWall(cx, y2, cz, width - 4, floorHeight, 1.2, interiorMat);
783
+
784
+ // Evlerin İçi Dağınık (Devrilmiş masalar, kırık sandalyeler, çöpler, saçılmış kutular)
785
+ for (let i = 0; i < 7; i++) {
786
+ let rx = cx + (Math.random() - 0.5) * 22;
787
+ let rz = cz + (Math.random() - 0.5) * 22;
788
+ let isTable = Math.random() > 0.5;
789
+
790
+ let objGeo = isTable ? new THREE.BoxGeometry(3.2, 1.2, 1.8) : new THREE.BoxGeometry(1.2, 1.2, 1.2);
791
+ let objMesh = new THREE.Mesh(objGeo, isTable ? woodMat : trashMat);
792
+ objMesh.position.set(rx, 0.6, rz);
793
+ // Dağınık görünüm için rastgele yatırılmış / döndürülmüş
794
+ objMesh.rotation.x = (Math.random() - 0.5) * 0.8;
795
+ objMesh.rotation.z = (Math.random() - 0.5) * 0.8;
796
+ objMesh.rotation.y = Math.random() * Math.PI;
797
+ objMesh.castShadow = true;
798
+ scene.add(objMesh);
799
+ }
800
+
801
+ // Giriş Kapısı
802
+ const doorGeo = new THREE.BoxGeometry(3, 5, 0.6);
803
+ let doorMesh = new THREE.Mesh(doorGeo, doorMat);
804
+ doorMesh.position.set(cx, 3, cz + depth/2 - 1);
805
+ scene.add(doorMesh);
806
+
807
+ doors.push({
808
+ mesh: doorMesh,
809
+ x: cx,
810
+ z: cz + depth/2 - 1,
811
+ isLocked: true,
812
+ isBreached: false
813
+ });
814
+ }
815
+
816
+ function createWall(x, y, z, w, h, d, mat) {
817
+ const geo = new THREE.BoxGeometry(w, h, d);
818
+ const mesh = new THREE.Mesh(geo, mat);
819
+ mesh.position.set(x, y, z);
820
+ mesh.castShadow = true;
821
+ mesh.receiveShadow = true;
822
+ scene.add(mesh);
823
+ walls.push({ x, z, w, d });
824
+ }
825
+
826
+ function setupSecurityCameras() {
827
+ const camPositions = [
828
+ { x: -65, y: 11, z: -65, rotY: Math.PI / 4 },
829
+ { x: 65, y: 11, z: -65, rotY: -Math.PI / 4 },
830
+ { x: -65, y: 11, z: 65, rotY: 3 * Math.PI / 4 },
831
+ { x: 65, y: 11, z: 65, rotY: -3 * Math.PI / 4 }
832
+ ];
833
+
834
+ camPositions.forEach((pos) => {
835
+ const camObj = new THREE.PerspectiveCamera(65, window.innerWidth / window.innerHeight, 0.1, 200);
836
+ camObj.position.set(pos.x, pos.y, pos.z);
837
+ camObj.rotation.y = pos.rotY;
838
+ scene.add(camObj);
839
+ securityCameras.push(camObj);
840
+
841
+ const mountGeo = new THREE.BoxGeometry(1, 1, 2);
842
+ const mountMat = new THREE.MeshStandardMaterial({ color: 0x111111 });
843
+ const mesh = new THREE.Mesh(mountGeo, mountMat);
844
+ mesh.position.set(pos.x, pos.y, pos.z);
845
+ mesh.rotation.y = pos.rotY;
846
+ scene.add(mesh);
847
+ });
848
+ }
849
+
850
+ function spawnKeycards(count) {
851
+ for (let i = 0; i < count; i++) {
852
+ const geo = new THREE.BoxGeometry(1.2, 0.1, 0.8);
853
+ const mat = new THREE.MeshStandardMaterial({ color: 0xffaa00, emissive: 0xffaa00, emissiveIntensity: 0.6 });
854
+ const mesh = new THREE.Mesh(geo, mat);
855
+
856
+ let kx = (Math.random() - 0.5) * 110;
857
+ let kz = (Math.random() - 0.5) * 110;
858
+ mesh.position.set(kx, 0.2, kz);
859
+ scene.add(mesh);
860
+
861
+ keycards.push({ mesh: mesh, collected: false });
862
+ }
863
+ }
864
+
865
+ function spawnAmmoDrop(pos) {
866
+ const geo = new THREE.BoxGeometry(0.8, 0.4, 0.6);
867
+ const mat = new THREE.MeshStandardMaterial({ color: 0x00ff88, emissive: 0x00ff88, emissiveIntensity: 0.5 });
868
+ const mesh = new THREE.Mesh(geo, mat);
869
+ mesh.position.set(pos.x, 0.2, pos.z);
870
+ scene.add(mesh);
871
+ ammoDrops.push({ mesh: mesh, collected: false });
872
+ }
873
+
874
+ function spawnEnemies(count) {
875
+ for (let i = 0; i < count; i++) {
876
+ const group = new THREE.Group();
877
+
878
+ const bodyGeo = new THREE.BoxGeometry(1.3, 2.1, 0.9);
879
+ const bodyMat = new THREE.MeshStandardMaterial({ color: 0x4a1414, roughness: 0.4 });
880
+ const body = new THREE.Mesh(bodyGeo, bodyMat);
881
+ body.position.y = 1.05;
882
+ body.castShadow = true;
883
+ group.add(body);
884
+
885
+ const vestGeo = new THREE.BoxGeometry(1.35, 1.1, 0.95);
886
+ const vestMat = new THREE.MeshStandardMaterial({ color: 0x1c222b, roughness: 0.3, metalness: 0.2 });
887
+ const vest = new THREE.Mesh(vestGeo, vestMat);
888
+ vest.position.y = 1.25;
889
+ group.add(vest);
890
+
891
+ const headGeo = new THREE.BoxGeometry(0.7, 0.7, 0.7);
892
+ const headMat = new THREE.MeshStandardMaterial({ color: 0xd6a87b });
893
+ const head = new THREE.Mesh(headGeo, headMat);
894
+ head.position.y = 2.45;
895
+ group.add(head);
896
+
897
+ const helmetGeo = new THREE.BoxGeometry(0.82, 0.4, 0.82);
898
+ const helmetMat = new THREE.MeshStandardMaterial({ color: 0x121b16, metalness: 0.4, roughness: 0.2 });
899
+ const helmet = new THREE.Mesh(helmetGeo, helmetMat);
900
+ helmet.position.y = 2.75;
901
+ group.add(helmet);
902
+
903
+ let rx, rz;
904
+ do {
905
+ rx = (Math.random() - 0.5) * 120;
906
+ rz = (Math.random() - 0.5) * 120;
907
+ } while (Math.abs(rx) < 25 && Math.abs(rz) < 25);
908
+
909
+ group.position.set(rx, 0, rz);
910
+ scene.add(group);
911
+
912
+ enemies.push({
913
+ mesh: group,
914
+ hp: 100,
915
+ speed: 0.026 + Math.random() * 0.015
916
+ });
917
+ }
918
+ }
919
+
920
+ function updateWeaponModel() {
921
+ if (weaponModelGroup) camera.remove(weaponModelGroup);
922
+
923
+ weaponModelGroup = new THREE.Group();
924
+ let wInfo = weapons[currentWeaponIndex];
925
+
926
+ const bodyGeo = new THREE.BoxGeometry(0.16, 0.22, 1.1);
927
+ const bodyMat = new THREE.MeshStandardMaterial({ color: wInfo.color, metalness: 0.85, roughness: 0.2 });
928
+ const body = new THREE.Mesh(bodyGeo, bodyMat);
929
+ weaponModelGroup.add(body);
930
+
931
+ const barrelGeo = new THREE.CylinderGeometry(0.05, 0.05, 0.6, 12);
932
+ const barrelMat = new THREE.MeshStandardMaterial({ color: 0x111111, metalness: 0.9, roughness: 0.1 });
933
+ const barrel = new THREE.Mesh(barrelGeo, barrelMat);
934
+ barrel.rotation.x = Math.PI / 2;
935
+ barrel.position.set(0, 0.02, -0.8);
936
+ weaponModelGroup.add(barrel);
937
+
938
+ if (currentWeaponIndex === 2) {
939
+ const scopeGeo = new THREE.CylinderGeometry(0.08, 0.08, 0.4, 12);
940
+ const scope = new THREE.Mesh(scopeGeo, barrelMat);
941
+ scope.rotation.x = Math.PI / 2;
942
+ scope.position.set(0, 0.18, -0.1);
943
+ weaponModelGroup.add(scope);
944
+ } else {
945
+ const magGeo = new THREE.BoxGeometry(0.12, 0.35, 0.2);
946
+ const mag = new THREE.Mesh(magGeo, barrelMat);
947
+ mag.position.set(0, -0.22, 0.1);
948
+ weaponModelGroup.add(mag);
949
+
950
+ const laserGeo = new THREE.CylinderGeometry(0.02, 0.02, 0.3, 8);
951
+ const laserMat = new THREE.MeshBasicMaterial({ color: 0xff0000 });
952
+ laserMesh = new THREE.Mesh(laserGeo, laserMat);
953
+ laserMesh.rotation.x = Math.PI / 2;
954
+ laserMesh.position.set(0.08, -0.05, -0.5);
955
+ laserMesh.visible = laserActive && currentWeaponIndex !== 2;
956
+ weaponModelGroup.add(laserMesh);
957
+ }
958
+
959
+ weaponModelGroup.position.set(0.38, -0.32, -0.65);
960
+ camera.add(weaponModelGroup);
961
+ scene.add(camera);
962
+ }
963
+
964
+ function updateLaserVisibility() {
965
+ if (laserMesh && currentWeaponIndex !== 2) {
966
+ laserMesh.visible = laserActive;
967
+ }
968
+ laserInd.style.display = (laserActive && currentWeaponIndex !== 2) ? 'block' : 'none';
969
+ }
970
+
971
+ function onKeyDown(e) {
972
+ if (player.isDead) return;
973
+ const code = e.code;
974
+ const key = e.key.toLowerCase();
975
+
976
+ if (code === 'KeyW' || key === 'w') keys.w = true;
977
+ if (code === 'KeyS' || key === 's') keys.s = true;
978
+ if (code === 'KeyA' || key === 'a') keys.a = true;
979
+ if (code === 'KeyD' || key === 'd') keys.d = true;
980
+ if (code === 'KeyU' || key === 'u') keys.u = true;
981
+
982
+ if (code === 'KeyR' || key === 'r') reloadWeapon();
983
+ if (code === 'KeyG' || key === 'g') throwGrenade();
984
+ if (code === 'KeyF' || key === 'f') toggleSecurityCamera();
985
+ if (code === 'KeyC' || key === 'c') exitSecurityCamera();
986
+ if (code === 'KeyK' || key === 'k') toggleNightVision();
987
+
988
+ if (code === 'KeyM' || key === 'm') {
989
+ let isMoving = keys.w || keys.a || keys.s || keys.d;
990
+ if (!isMoving && heartRate > 85) {
991
+ heartRate = Math.max(70, heartRate - 50);
992
+ bloodOverlay.style.opacity = Math.max(0, parseFloat(bloodOverlay.style.opacity || 0) - 0.5);
993
+ playPillSound();
994
+ speakRadio("Alpha-2: Medication administered. Heart rate stabilizing.");
995
+ } else if (isMoving) {
996
+ speakRadio("Alpha-2: Stop moving before taking medication!");
997
+ }
998
+ }
999
+
1000
+ if (key === '1') switchWeapon(0);
1001
+ if (key === '2') switchWeapon(1);
1002
+ if (key === '3') switchWeapon(2);
1003
+ }
1004
+
1005
+ function onKeyUp(e) {
1006
+ const code = e.code;
1007
+ const key = e.key.toLowerCase();
1008
+
1009
+ if (code === 'KeyW' || key === 'w') keys.w = false;
1010
+ if (code === 'KeyS' || key === 's') keys.s = false;
1011
+ if (code === 'KeyA' || key === 'a') keys.a = false;
1012
+ if (code === 'KeyD' || key === 'd') keys.d = false;
1013
+ if (code === 'KeyU' || key === 'u') {
1014
+ keys.u = false;
1015
+ uKeyHoldTime = 0;
1016
+ interactionPrompt.style.display = 'none';
1017
+ }
1018
+ }
1019
+
1020
+ function onMouseMove(e) {
1021
+ if (!isPointerLocked || player.isDead || currentCamIndex !== -1) return;
1022
+ let sensitivity = sniperZoomActive ? 0.0008 : 0.0022;
1023
+ player.targetRotY -= e.movementX * sensitivity;
1024
+ player.targetRotX -= e.movementY * sensitivity;
1025
+ player.targetRotX = Math.max(-Math.PI / 2.3, Math.min(Math.PI / 2.3, player.targetRotX));
1026
+ }
1027
+
1028
+ function switchWeapon(index) {
1029
+ currentWeaponIndex = index;
1030
+ if (currentWeaponIndex === 2) {
1031
+ laserActive = false;
1032
+ }
1033
+ updateWeaponModel();
1034
+ updateLaserVisibility();
1035
+ updateHUD();
1036
+ }
1037
+
1038
+ function onMouseDown(e) {
1039
+ if (!isPointerLocked || player.isDead || currentCamIndex !== -1) return;
1040
+ if (e.button === 0) {
1041
+ shootWeapon();
1042
+ } else if (e.button === 2) {
1043
+ if (currentWeaponIndex === 2) {
1044
+ sniperZoomActive = true;
1045
+ camera.fov = 20;
1046
+ camera.updateProjectionMatrix();
1047
+ sniperScope.style.display = 'block';
1048
+ playNVSound();
1049
+ } else {
1050
+ laserActive = !laserActive;
1051
+ playPillSound();
1052
+ speakRadio(laserActive ? "Alpha-2: Tactical laser activated." : "Alpha-2: Tactical laser deactivated.");
1053
+ updateLaserVisibility();
1054
+ }
1055
+ }
1056
+ }
1057
+
1058
+ function onMouseUp(e) {
1059
+ if (e.button === 2 && currentWeaponIndex === 2 && sniperZoomActive) {
1060
+ sniperZoomActive = false;
1061
+ camera.fov = 70;
1062
+ camera.updateProjectionMatrix();
1063
+ sniperScope.style.display = 'none';
1064
+ }
1065
+ }
1066
+
1067
+ function exitSecurityCamera() {
1068
+ if (currentCamIndex !== -1) {
1069
+ currentCamIndex = -1;
1070
+ camInd.style.display = 'none';
1071
+ }
1072
+ }
1073
+
1074
+ function toggleSecurityCamera() {
1075
+ currentCamIndex++;
1076
+ if (currentCamIndex >= securityCameras.length) {
1077
+ currentCamIndex = -1;
1078
+ camInd.style.display = 'none';
1079
+ } else {
1080
+ camInd.style.display = 'block';
1081
+ }
1082
+ }
1083
+
1084
+ function toggleNightVision() {
1085
+ nightVisionActive = !nightVisionActive;
1086
+ playNVSound();
1087
+ if (nightVisionActive) {
1088
+ scene.background = new THREE.Color(0x002200);
1089
+ scene.fog.color = new THREE.Color(0x002200);
1090
+ nvFilter.style.display = 'block';
1091
+ nvInd.style.display = 'block';
1092
+ speakRadio("Alpha-2: Night vision engaged.");
1093
+ } else {
1094
+ scene.background = new THREE.Color(0x020307);
1095
+ scene.fog.color = new THREE.Color(0x020307);
1096
+ nvFilter.style.display = 'none';
1097
+ nvInd.style.display = 'none';
1098
+ speakRadio("Alpha-2: Night vision disengaged.");
1099
+ }
1100
+ }
1101
+
1102
+ function shootWeapon() {
1103
+ let wInfo = weapons[currentWeaponIndex];
1104
+ if (wInfo.ammo <= 0) {
1105
+ playReloadSound();
1106
+ return;
1107
+ }
1108
+ wInfo.ammo--;
1109
+ playGunshotSound();
1110
+ updateHUD();
1111
+
1112
+ const raycaster = new THREE.Raycaster();
1113
+ raycaster.setFromCamera(new THREE.Vector2(0, 0), camera);
1114
+
1115
+ let enemyMeshes = enemies.map(e => e.mesh);
1116
+ let intersects = raycaster.intersectObjects(enemyMeshes, true);
1117
+
1118
+ if (intersects.length > 0) {
1119
+ let hitMesh = intersects[0].object;
1120
+ let targetEnemy = enemies.find(e => e.mesh === hitMesh.parent || e.mesh === hitMesh.parent?.parent);
1121
+ if (targetEnemy) {
1122
+ spawnBloodSplatter(intersects[0].point);
1123
+ heartRate = Math.min(190, heartRate + 18); // Düşman kesince kalp ritmi bozulup hızlanır
1124
+
1125
+ targetEnemy.hp -= wInfo.damage;
1126
+ if (targetEnemy.hp <= 0) {
1127
+ spawnBloodPool(targetEnemy.mesh.position);
1128
+ spawnAmmoDrop(targetEnemy.mesh.position); // Düşman kesince mermi düşer
1129
+ scene.remove(targetEnemy.mesh);
1130
+ enemies = enemies.filter(e => e !== targetEnemy);
1131
+ player.money += 500;
1132
+ updateHUD();
1133
+
1134
+ if (enemies.length === 0) {
1135
+ advanceLevel();
1136
+ }
1137
+ }
1138
+ }
1139
+ }
1140
+ }
1141
+
1142
+ function spawnBloodSplatter(pos) {
1143
+ const geo = new THREE.CircleGeometry(0.35, 8);
1144
+ const mat = new THREE.MeshBasicMaterial({ color: 0x880000, transparent: true, opacity: 0.85 });
1145
+ const mesh = new THREE.Mesh(geo, mat);
1146
+ mesh.position.copy(pos);
1147
+ mesh.rotation.x = -Math.PI / 2;
1148
+ scene.add(mesh);
1149
+ bloodDecals.push(mesh);
1150
+ }
1151
+
1152
+ function spawnBloodPool(pos) {
1153
+ const geo = new THREE.CircleGeometry(2.2, 16);
1154
+ const mat = new THREE.MeshBasicMaterial({ color: 0x550000, transparent: true, opacity: 0.9 });
1155
+ const mesh = new THREE.Mesh(geo, mat);
1156
+ mesh.position.set(pos.x, 0.03, pos.z);
1157
+ mesh.rotation.x = -Math.PI / 2;
1158
+ scene.add(mesh);
1159
+ bloodDecals.push(mesh);
1160
+ }
1161
+
1162
+ function advanceLevel() {
1163
+ currentLevel++;
1164
+ if (currentLevel > maxLevel) {
1165
+ speakRadio("Alpha-2: All sectors successfully cleared! Victory!");
1166
+ instructionsEl.style.display = 'flex';
1167
+ instructionsEl.querySelector('h1').innerText = "MISSION COMPLETED [VICTORY]";
1168
+ instructionsEl.querySelector('p').innerText = "You have cleared all messy safehouse sectors.";
1169
+ startBtn.style.display = 'none';
1170
+ document.exitPointerLock();
1171
+ return;
1172
+ }
1173
+
1174
+ speakRadio(`Alpha-2: Sector ${currentLevel - 1} cleared! Advancing to Sector ${currentLevel}!`);
1175
+
1176
+ bloodOverlay.style.background = 'radial-gradient(circle, rgba(0,255,200,0.2) 20%, rgba(0,0,0,0.95) 95%)';
1177
+ bloodOverlay.style.opacity = '1';
1178
+
1179
+ setTimeout(() => {
1180
+ player.x = (Math.random() - 0.5) * 20;
1181
+ player.z = (Math.random() - 0.5) * 20;
1182
+ spawnKeycards(2);
1183
+ spawnEnemies(7 + currentLevel * 4);
1184
+ bloodOverlay.style.background = 'radial-gradient(circle, rgba(140,0,0,0) 25%, rgba(120,0,0,0.95) 95%)';
1185
+ bloodOverlay.style.opacity = '0';
1186
+ updateHUD();
1187
+ speakRadio(`Alpha-2: Sector ${currentLevel} active. Clean out the rooms!`);
1188
+ }, 1800);
1189
+ }
1190
+
1191
+ function reloadWeapon() {
1192
+ let wInfo = weapons[currentWeaponIndex];
1193
+ let maxAmmo = currentWeaponIndex === 2 ? 10 : 30;
1194
+ if (wInfo.reserve <= 0 || wInfo.ammo === maxAmmo) return;
1195
+ playReloadSound();
1196
+ let needed = maxAmmo - wInfo.ammo;
1197
+ let take = Math.min(needed, wInfo.reserve);
1198
+ wInfo.ammo += take;
1199
+ wInfo.reserve -= take;
1200
+ updateHUD();
1201
+ }
1202
+
1203
+ function throwGrenade() {
1204
+ const geo = new THREE.SphereGeometry(0.35, 16, 16);
1205
+ const mat = new THREE.MeshStandardMaterial({ color: 0x222222, metalness: 0.8 });
1206
+ const mesh = new THREE.Mesh(geo, mat);
1207
+
1208
+ let camDir = new THREE.Vector3();
1209
+ camera.getWorldDirection(camDir);
1210
+
1211
+ let startPos = new THREE.Vector3(player.x, 2.0, player.z);
1212
+ mesh.position.copy(startPos);
1213
+ scene.add(mesh);
1214
+
1215
+ let velocity = camDir.clone().multiplyScalar(0.55).add(new THREE.Vector3(0, 0.32, 0));
1216
+
1217
+ grenades.push({
1218
+ mesh: mesh,
1219
+ pos: startPos,
1220
+ velocity: velocity,
1221
+ life: 90
1222
+ });
1223
+ speakRadio("Alpha-2: Grenade deployed!");
1224
+ }
1225
+
1226
+ function takeDamage(amount) {
1227
+ if (player.isDead) return;
1228
+ player.hp -= amount;
1229
+ heartRate = Math.min(198, heartRate + 35); // Hasar alınca kalp ritmi bozulur
1230
+
1231
+ let missingHpRatio = (100 - player.hp) / 100;
1232
+ bloodOverlay.style.opacity = Math.min(0.95, 0.3 + missingHpRatio * 0.7);
1233
+ setTimeout(() => {
1234
+ if(!player.isDead) bloodOverlay.style.opacity = Math.max(0.15, missingHpRatio * 0.6);
1235
+ }, 400);
1236
+
1237
+ if (player.hp <= 0) {
1238
+ player.hp = 0;
1239
+ player.isDead = true;
1240
+ bloodOverlay.style.opacity = '1';
1241
+ playFlatlineSound();
1242
+ instructionsEl.style.display = 'flex';
1243
+ instructionsEl.querySelector('h1').innerText = "OPERATION FAILED [KIA]";
1244
+ instructionsEl.querySelector('p').innerText = "Refresh the page to retry.";
1245
+ startBtn.style.display = 'none';
1246
+ document.exitPointerLock();
1247
+ }
1248
+ updateHUD();
1249
+ }
1250
+
1251
+ function updateHUD() {
1252
+ hpDisplay.innerText = `HP: ${player.hp} HP`;
1253
+ let wInfo = weapons[currentWeaponIndex];
1254
+ ammoDisplay.innerText = `AMMO: ${wInfo.ammo} / ${wInfo.reserve}`;
1255
+ weaponDisplay.innerText = `WEAPON: ${wInfo.name}`;
1256
+ scoreDisplay.innerHTML = `CASH: $${player.money}<br>LEVEL: ${currentLevel} | ENEMIES: ${enemies.length} | KEYCARDS: ${player.keycards}/${keycards.length + player.keycards}`;
1257
+ }
1258
+
1259
+ function updateWaypoints() {
1260
+ const playerPos = new THREE.Vector3(player.x, 2.2, player.z);
1261
+
1262
+ let activeItem = keycards.find(k => !k.collected);
1263
+ if (activeItem) {
1264
+ let dItem = Math.round(playerPos.distanceTo(activeItem.mesh.position));
1265
+ markerItem.innerText = `KEYCARD [${dItem}m]`;
1266
+ updateWaypointPosition(activeItem.mesh.position, markerItem);
1267
+ markerItem.style.display = 'block';
1268
+ } else {
1269
+ markerItem.style.display = 'none';
1270
+ }
1271
+
1272
+ let activeAmmo = ammoDrops.find(a => !a.collected);
1273
+ if (activeAmmo) {
1274
+ let dAmmo = Math.round(playerPos.distanceTo(activeAmmo.mesh.position));
1275
+ markerAmmo.innerText = `AMMO DROP [${dAmmo}m]`;
1276
+ updateWaypointPosition(activeAmmo.mesh.position, markerAmmo);
1277
+ markerAmmo.style.display = 'block';
1278
+ } else {
1279
+ markerAmmo.style.display = 'none';
1280
+ }
1281
+
1282
+ let nearestEnemyPos = enemies.length > 0 ? enemies[0].mesh.position : new THREE.Vector3(0,0,0);
1283
+ let dEnemy = Math.round(playerPos.distanceTo(nearestEnemyPos));
1284
+ markerEnemy.innerText = `HOSTILE [${dEnemy}m]`;
1285
+ updateWaypointPosition(nearestEnemyPos, markerEnemy);
1286
+ }
1287
+
1288
+ function updateWaypointPosition(worldPos, element) {
1289
+ let tempVector = worldPos.clone();
1290
+ tempVector.project(camera);
1291
+
1292
+ if (tempVector.z > 1 || tempVector.x < -1 || tempVector.x > 1 || tempVector.y < -1 || tempVector.y > 1) {
1293
+ element.style.display = 'none';
1294
+ return;
1295
+ }
1296
+
1297
+ let x = (tempVector.x * .5 + .5) * window.innerWidth;
1298
+ let y = (tempVector.y * -.5 + .5) * window.innerHeight;
1299
+
1300
+ element.style.display = 'block';
1301
+ element.style.transform = `translate(-50%, -50%) translate(${x}px, ${y}px)`;
1302
+ }
1303
+
1304
+ function checkInteractions() {
1305
+ const playerPos = new THREE.Vector3(player.x, 2.2, player.z);
1306
+
1307
+ keycards.forEach(k => {
1308
+ if (!k.collected && playerPos.distanceTo(k.mesh.position) < 2.5) {
1309
+ k.collected = true;
1310
+ scene.remove(k.mesh);
1311
+ player.keycards++;
1312
+ playPillSound();
1313
+ speakRadio("Alpha-2: Keycard acquired!");
1314
+ updateHUD();
1315
+ }
1316
+ });
1317
+
1318
+ ammoDrops.forEach(a => {
1319
+ if (!a.collected && playerPos.distanceTo(a.mesh.position) < 2.5) {
1320
+ a.collected = true;
1321
+ scene.remove(a.mesh);
1322
+ weapons.forEach(w => w.reserve += 30);
1323
+ playPillSound();
1324
+ speakRadio("Alpha-2: Ammo pack secured!");
1325
+ updateHUD();
1326
+ }
1327
+ });
1328
+
1329
+ targetDoorToBreach = null;
1330
+ doors.forEach(d => {
1331
+ if (!d.isBreached && playerPos.distanceTo(new THREE.Vector3(d.x, 2, d.z)) < 3.5) {
1332
+ targetDoorToBreach = d;
1333
+ }
1334
+ });
1335
+
1336
+ if (targetDoorToBreach) {
1337
+ interactionPrompt.style.display = 'block';
1338
+ if (keys.u) {
1339
+ uKeyHoldTime += 0.016;
1340
+ interactionPrompt.innerText = `BREACHING DOOR... [${Math.min(100, Math.round(uKeyHoldTime * 100))}%]`;
1341
+ if (uKeyHoldTime >= 1.0) {
1342
+ targetDoorToBreach.isBreached = true;
1343
+ scene.remove(targetDoorToBreach.mesh);
1344
+ playBreachSound();
1345
+ speakRadio("Alpha-2: Door breached!");
1346
+ interactionPrompt.style.display = 'none';
1347
+ uKeyHoldTime = 0;
1348
+ }
1349
+ } else {
1350
+ uKeyHoldTime = 0;
1351
+ interactionPrompt.innerText = "HOLD [U] TO BREACH DOOR";
1352
+ }
1353
+ } else {
1354
+ interactionPrompt.style.display = 'none';
1355
+ uKeyHoldTime = 0;
1356
+ }
1357
+ }
1358
+
1359
+ function animate() {
1360
+ requestAnimationFrame(animate);
1361
+
1362
+ flashingLights.forEach(fl => {
1363
+ fl.light.intensity = Math.abs(Math.sin(Date.now() * fl.speed + fl.offset)) * 1.8;
1364
+ });
1365
+
1366
+ if (!player.isDead) {
1367
+ player.rotY += (player.targetRotY - player.rotY) * 0.15;
1368
+ player.rotX += (player.targetRotX - player.rotX) * 0.15;
1369
+
1370
+ let moveSpeed = 0.092;
1371
+ let dx = 0, dz = 0;
1372
+ if (keys.w) { dz -= Math.cos(player.rotY) * moveSpeed; dx -= Math.sin(player.rotY) * moveSpeed; }
1373
+ if (keys.s) { dz += Math.cos(player.rotY) * moveSpeed; dx += Math.sin(player.rotY) * moveSpeed; }
1374
+ if (keys.a) { dx -= Math.cos(player.rotY) * moveSpeed; dz += Math.sin(player.rotY) * moveSpeed; }
1375
+ if (keys.d) { dx += Math.cos(player.rotY) * moveSpeed; dz -= Math.sin(player.rotY) * moveSpeed; }
1376
+
1377
+ let nextX = player.x + dx;
1378
+ let nextZ = player.z + dz;
1379
+
1380
+ let collision = false;
1381
+ for (let w of walls) {
1382
+ if (nextX > w.x - w.w/2 - 1.2 && nextX < w.x + w.w/2 + 1.2 &&
1383
+ nextZ > w.z - w.d/2 - 1.2 && nextZ < w.z + w.d/2 + 1.2) {
1384
+ collision = true;
1385
+ break;
1386
+ }
1387
+ }
1388
+
1389
+ for (let d of doors) {
1390
+ if (!d.isBreached && nextX > d.x - 1.6 && nextX < d.x + 1.6 &&
1391
+ nextZ > d.z - 0.6 && nextZ < d.z + 0.6) {
1392
+ collision = true;
1393
+ break;
1394
+ }
1395
+ }
1396
+
1397
+ if (!collision) {
1398
+ player.x = nextX;
1399
+ player.z = nextZ;
1400
+ }
1401
+
1402
+ if (currentCamIndex === -1) {
1403
+ camera.position.x = player.x;
1404
+ camera.position.y = 2.2 + Math.sin(Date.now() * 0.008) * 0.03;
1405
+ camera.position.z = player.z;
1406
+ camera.rotation.y = player.rotY;
1407
+ camera.rotation.x = player.rotX;
1408
+ if(weaponModelGroup) weaponModelGroup.visible = true;
1409
+ } else {
1410
+ let cam = securityCameras[currentCamIndex];
1411
+ camera.position.copy(cam.position);
1412
+ camera.rotation.copy(cam.rotation);
1413
+ if(weaponModelGroup) weaponModelGroup.visible = false;
1414
+ }
1415
+
1416
+ enemies.forEach(en => {
1417
+ let enMesh = en.mesh;
1418
+ let targetDir = new THREE.Vector3(player.x - enMesh.position.x, 0, player.z - enMesh.position.z);
1419
+ let dist = targetDir.length();
1420
+ targetDir.normalize();
1421
+
1422
+ if (dist > 2.2) {
1423
+ enMesh.position.addScaledVector(targetDir, en.speed);
1424
+ enMesh.lookAt(player.x, enMesh.position.y, player.z);
1425
+ } else {
1426
+ if (Math.random() < 0.035) takeDamage(12);
1427
+ }
1428
+ });
1429
+
1430
+ grenades.forEach((g, index) => {
1431
+ g.velocity.y -= 0.022;
1432
+ g.pos.add(g.velocity);
1433
+
1434
+ if (g.pos.y <= 0.35) {
1435
+ g.pos.y = 0.35;
1436
+ g.velocity.y = -g.velocity.y * 0.35;
1437
+ g.velocity.x *= 0.75;
1438
+ g.velocity.z *= 0.75;
1439
+ }
1440
+
1441
+ g.mesh.position.copy(g.pos);
1442
+ g.life--;
1443
+
1444
+ if (g.life <= 0) {
1445
+ playExplosionSound();
1446
+ scene.remove(g.mesh);
1447
+ grenades.splice(index, 1);
1448
+
1449
+ enemies.forEach((en, eIdx) => {
1450
+ if (en.mesh.position.distanceTo(g.pos) < 10) {
1451
+ spawnBloodPool(en.mesh.position);
1452
+ spawnAmmoDrop(en.mesh.position);
1453
+ scene.remove(en.mesh);
1454
+ enemies.splice(eIdx, 1);
1455
+ player.money += 500;
1456
+ updateHUD();
1457
+
1458
+ if (enemies.length === 0) {
1459
+ advanceLevel();
1460
+ }
1461
+ }
1462
+ });
1463
+ }
1464
+ });
1465
+
1466
+ checkInteractions();
1467
+ updateWaypoints();
1468
+ }
1469
+
1470
+ drawECG();
1471
+ renderer.render(scene, camera);
1472
+ }
1473
+
1474
+ function drawECG() {
1475
+ ecgCtx.fillStyle = 'rgba(10, 10, 15, 0.25)';
1476
+ ecgCtx.fillRect(0, 0, ecgCanvas.width, ecgCanvas.height);
1477
+
1478
+ ecgCtx.strokeStyle = player.isDead ? '#ff0000' : '#00ffcc';
1479
+ ecgCtx.lineWidth = 2;
1480
+ ecgCtx.beginPath();
1481
+
1482
+ let x = ecgOffset;
1483
+ let y = ecgCanvas.height / 2;
1484
+
1485
+ ecgCtx.moveTo(x, y);
1486
+ if (player.isDead) {
1487
+ ecgCtx.lineTo(ecgCanvas.width, y);
1488
+ } else {
1489
+ for (let i = 0; i < 50; i++) {
1490
+ let px = (ecgOffset + i) % ecgCanvas.width;
1491
+ let py = y;
1492
+ if (i % 25 === 12) py -= Math.random() * 32 * (heartRate / 75);
1493
+ if (i % 25 === 14) py += Math.random() * 42 * (heartRate / 75);
1494
+ ecgCtx.lineTo(px, py);
1495
+ }
1496
+ }
1497
+ ecgCtx.stroke();
1498
+
1499
+ // Kalp ritmi bozulunca (hasar, ateş etme, çatışma) sağ alttaki ECG çizgisi ve hızı iyice hızlanır
1500
+ let ecgSpeed = Math.max(2, Math.round(heartRate / 22));
1501
+ ecgOffset = (ecgOffset + ecgSpeed) % ecgCanvas.width;
1502
+
1503
+ if (heartRate > 75 && !player.isDead) heartRate -= 0.032;
1504
+
1505
+ let now = Date.now();
1506
+ let interval = 60000 / heartRate;
1507
+ if (!player.isDead && now - lastHeartbeatTime > interval) {
1508
+ playHeartbeatThump();
1509
+ lastHeartbeatTime = now;
1510
+ }
1511
+ }
1512
+ </script>
1513
+ </body>
1514
+ </html>