THEZYZSTUDIO commited on
Commit
56adaed
·
verified ·
1 Parent(s): dbdfbec

Create car crash simulator by the z plus model

Browse files
car crash simulator by the z plus model ADDED
@@ -0,0 +1,430 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="ar" dir="rtl">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <title>THE Z AI - محاكاة الاصطدام السينمائي الفائق</title>
6
+ <style>
7
+ body {
8
+ margin: 0;
9
+ overflow: hidden;
10
+ background: #020205;
11
+ font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
12
+ color: white;
13
+ }
14
+ canvas { display: block; }
15
+ #ui {
16
+ position: absolute;
17
+ top: 30px;
18
+ right: 30px;
19
+ pointer-events: none;
20
+ text-align: right;
21
+ }
22
+ .speed-box {
23
+ background: rgba(0, 0, 0, 0.85);
24
+ padding: 20px 40px;
25
+ border-radius: 20px;
26
+ border: 4px solid #ff0000;
27
+ box-shadow: 0 0 40px rgba(255, 0, 0, 0.4);
28
+ backdrop-filter: blur(10px);
29
+ }
30
+ .label { font-size: 20px; color: #aaa; text-transform: uppercase; letter-spacing: 2px; }
31
+ .value {
32
+ font-size: 85px;
33
+ font-weight: 900;
34
+ color: #ff0000;
35
+ display: block;
36
+ font-family: 'Courier New', monospace;
37
+ text-shadow: 0 0 20px rgba(255, 0, 0, 0.8);
38
+ }
39
+ #instructions {
40
+ position: absolute;
41
+ bottom: 30px;
42
+ left: 50%;
43
+ transform: translateX(-50%);
44
+ background: rgba(255,255,255,0.1);
45
+ padding: 10px 20px;
46
+ border-radius: 50px;
47
+ font-size: 18px;
48
+ backdrop-filter: blur(5px);
49
+ }
50
+ </style>
51
+ </head>
52
+ <body>
53
+
54
+ <div id="ui">
55
+ <div class="speed-box">
56
+ <span class="label">السرعة الحالية</span>
57
+ <span id="speed-value" class="value">0</span>
58
+ <span class="label">كم / ساعة</span>
59
+ </div>
60
+ </div>
61
+
62
+ <div id="instructions">انقر في أي مكان لبدء المحاكاة وتفعيل الصوت 🚀</div>
63
+
64
+ <canvas id="simCanvas"></canvas>
65
+
66
+ <script>
67
+ /**
68
+ * THE Z AI Agent - Ultra Crash Simulation
69
+ * نظام فيزيائي متكامل: تسارع أسي، بارالاكس، تفتيت جزيئي، وصوت توليدي.
70
+ */
71
+
72
+ const canvas = document.getElementById('simCanvas');
73
+ const ctx = canvas.getContext('2d');
74
+ const speedDisplay = document.getElementById('speed-value');
75
+
76
+ canvas.width = window.innerWidth;
77
+ canvas.height = window.innerHeight;
78
+
79
+ // --- الإعدادات الفيزيائية والبيئية ---
80
+ let worldX = 0;
81
+ let cameraX = 0;
82
+ let zoom = 1;
83
+ let shake = 0;
84
+ let isStarted = false;
85
+ let isCrashed = false;
86
+
87
+ const CONFIG = {
88
+ startSpeed: 0,
89
+ targetSpeed: 220, // السرعة القصوى قبل الاصطدام
90
+ accelBase: 0.05,
91
+ turboMultiplier: 1.002, // تسارع أسي
92
+ houseDistance: 8000, // مسافة بعيدة جداً للوصول للسرعة القصوى
93
+ gravity: 0.25
94
+ };
95
+
96
+ let car = {
97
+ x: 300,
98
+ y: canvas.height / 2,
99
+ w: 140,
100
+ h: 60,
101
+ speed: 0,
102
+ accel: CONFIG.accelBase,
103
+ color: '#ff0000',
104
+ parts: [] // لتخزين قطع السيارة عند التحطم
105
+ };
106
+
107
+ let house = {
108
+ x: CONFIG.houseDistance,
109
+ y: 0,
110
+ w: 400,
111
+ h: 500
112
+ };
113
+
114
+ let cityLayers = []; // طبقات المدينة (Parallax)
115
+ let particles = []; // انفجارات وشرارات
116
+ let debris = []; // قطع السيارة والمنزل
117
+
118
+ // --- نظام الصوت (Web Audio API) ---
119
+ let audioCtx, engineOsc, windOsc, gainNode;
120
+
121
+ function initAudio() {
122
+ audioCtx = new (window.AudioContext || window.webkitAudioContext)();
123
+ gainNode = audioCtx.createGain();
124
+ gainNode.gain.value = 0.1;
125
+ gainNode.connect(audioCtx.destination);
126
+
127
+ // صوت المحرك
128
+ engineOsc = audioCtx.createOscillator();
129
+ engineOsc.type = 'sawtooth';
130
+ engineOsc.frequency.setValueAtTime(50, audioCtx.currentTime);
131
+ engineOsc.connect(gainNode);
132
+ engineOsc.start();
133
+
134
+ // صوت الرياح
135
+ windOsc = audioCtx.createOscillator();
136
+ windOsc.type = 'brownian'; // محاكاة ضوضاء
137
+ windOsc.connect(gainNode);
138
+ }
139
+
140
+ function updateAudio() {
141
+ if(!audioCtx) return;
142
+ // ربط التردد بالسرعة
143
+ let freq = 50 + (car.speed * 2);
144
+ engineOsc.frequency.setTargetAtTime(freq, audioCtx.currentTime, 0.1);
145
+ gainNode.gain.setTargetAtTime(0.1 + (car.speed/500), audioCtx.currentTime, 0.1);
146
+ }
147
+
148
+ function playCrashSound() {
149
+ if(!audioCtx) return;
150
+ const noise = audioCtx.createBufferSource();
151
+ const buffer = audioCtx.createBuffer(1, audioCtx.sampleRate * 2, audioCtx.sampleRate);
152
+ const data = buffer.getChannelData(0);
153
+ for(let i=0; i<buffer.length; i++) data[i] = Math.random() * 2 - 1;
154
+
155
+ noise.buffer = buffer;
156
+ const filter = audioCtx.createBiquadFilter();
157
+ filter.type = 'lowpass';
158
+ filter.frequency.value = 1000;
159
+
160
+ noise.connect(filter);
161
+ filter.connect(gainNode);
162
+ noise.start();
163
+ noise.stop(audioCtx.currentTime + 2);
164
+ }
165
+
166
+ // --- بن��ء العالم ---
167
+ function createCity() {
168
+ // 3 طبقات من المباني للبارالاكس
169
+ for(let layer = 1; layer <= 3; layer++) {
170
+ let layerBuildings = [];
171
+ for(let i=0; i<100; i++) {
172
+ layerBuildings.push({
173
+ x: i * 400 + Math.random() * 200,
174
+ w: 150 + Math.random() * 200,
175
+ h: 200 + Math.random() * 600,
176
+ color: `rgb(${20*layer}, ${20*layer}, ${30*layer})`,
177
+ speedMod: layer * 0.1 // الطبقة البعيدة تتحرك أبطأ
178
+ });
179
+ }
180
+ cityLayers.push(layerBuildings);
181
+ }
182
+ }
183
+
184
+ function drawCity() {
185
+ cityLayers.forEach((layer, index) => {
186
+ ctx.fillStyle = layer[0].color;
187
+ layer.forEach(b => {
188
+ // حساب موقع المبنى بناءً على سرعة الطبقة (Parallax)
189
+ let relX = (b.x - worldX * b.speedMod);
190
+ ctx.fillRect(relX, canvas.height - b.h, b.w, b.h);
191
+ });
192
+ });
193
+ }
194
+
195
+ function drawRoad() {
196
+ ctx.fillStyle = '#111';
197
+ ctx.fillRect(0, canvas.height/2 + 30, canvas.width, canvas.height/2);
198
+
199
+ // خطوط الطريق المتحركة
200
+ ctx.strokeStyle = '#fff';
201
+ ctx.setLineDash([40, 60]);
202
+ ctx.lineWidth = 4;
203
+ ctx.beginPath();
204
+ ctx.moveTo(0, canvas.height/2 + 35);
205
+ ctx.lineTo(canvas.width, canvas.height/2 + 35);
206
+ ctx.stroke();
207
+ ctx.setLineDash([]);
208
+ }
209
+
210
+ function drawHouse() {
211
+ let relX = house.x - cameraX;
212
+ if(relX > canvas.width + 500 || relX < -500) return;
213
+
214
+ // الجسم الرئيسي
215
+ ctx.fillStyle = '#444';
216
+ ctx.fillRect(relX, house.y, house.w, house.h);
217
+
218
+ // السقف
219
+ ctx.fillStyle = '#222';
220
+ ctx.beginPath();
221
+ ctx.moveTo(relX - 20, house.y);
222
+ ctx.lineTo(relX + house.w/2, house.y - 100);
223
+ ctx.lineTo(relX + house.w + 20, house.y);
224
+ ctx.fill();
225
+
226
+ // النوافذ
227
+ ctx.fillStyle = '#88ccff';
228
+ for(let i=0; i<3; i++) {
229
+ for(let j=0; j<3; j++) {
230
+ ctx.fillRect(relX + 40 + i*100, house.y + 50 + j*100, 50, 60);
231
+ }
232
+ }
233
+
234
+ // الباب
235
+ ctx.fillStyle = '#5d3a1a';
236
+ ctx.fillRect(relX + 150, house.y + 300, 100, 100);
237
+ }
238
+
239
+ function drawCar() {
240
+ if(isCrashed) return;
241
+
242
+ let relX = car.x - cameraX;
243
+
244
+ // ظل السيارة
245
+ ctx.fillStyle = 'rgba(0,0,0,0.5)';
246
+ ctx.fillRect(relX, car.y + car.h - 10, car.w, 20);
247
+
248
+ // جسم السيارة (تصميم عصري)
249
+ ctx.fillStyle = car.color;
250
+ ctx.beginPath();
251
+ ctx.roundRect(relX, car.y, car.w, car.h, [20, 50, 10, 10]);
252
+ ctx.fill();
253
+
254
+ // السقف والزجاج
255
+ ctx.fillStyle = '#222';
256
+ ctx.beginPath();
257
+ ctx.roundRect(relX + 30, car.y - 20, 60, 30, [20, 20, 0, 0]);
258
+ ctx.fill();
259
+ ctx.fillStyle = '#88ccff';
260
+ ctx.fillRect(relX + 40, car.y - 15, 40, 15);
261
+
262
+ // العجلات
263
+ ctx.fillStyle = '#000';
264
+ ctx.beginPath();
265
+ ctx.arc(relX + 30, car.y + car.h, 15, 0, Math.PI*2);
266
+ ctx.arc(relX + car.w - 30, car.y + car.h, 15, 0, Math.PI*2);
267
+ ctx.fill();
268
+
269
+ // أضواء خلفية
270
+ ctx.fillStyle = '#ffaa00';
271
+ ctx.fillRect(relX, car.y + 10, 5, 15);
272
+ }
273
+
274
+ // --- نظام التدمير ---
275
+ function explode() {
276
+ isCrashed = true;
277
+ shake = 50;
278
+ playCrashSound();
279
+
280
+ // 1. تفتيت السيارة إلى قطع
281
+ for(let i=0; i<200; i++) {
282
+ debris.push({
283
+ x: car.x + car.w,
284
+ y: car.y + car.h/2,
285
+ vx: (Math.random() - 0.3) * (car.speed / 2),
286
+ vy: (Math.random() - 0.5) * 20,
287
+ size: Math.random() * 15 + 5,
288
+ color: Math.random() > 0.5 ? car.color : '#333',
289
+ rot: Math.random() * Math.PI * 2,
290
+ vRot: (Math.random() - 0.5) * 0.2
291
+ });
292
+ }
293
+
294
+ // 2. شرارات كهربائية
295
+ for(let i=0; i<300; i++) {
296
+ particles.push({
297
+ x: car.x + car.w,
298
+ y: car.y + car.h/2,
299
+ vx: (Math.random() - 0.1) * 40,
300
+ vy: (Math.random() - 0.5) * 40,
301
+ life: 1.0,
302
+ color: '#fff700'
303
+ });
304
+ }
305
+
306
+ // 3. كرات نارية ودخان
307
+ for(let i=0; i<100; i++) {
308
+ particles.push({
309
+ x: car.x + car.w,
310
+ y: car.y + car.h/2,
311
+ vx: (Math.random() - 0.5) * 10,
312
+ vy: (Math.random() - 0.8) * 15,
313
+ life: 2.0,
314
+ size: Math.random() * 40 + 20,
315
+ color: Math.random() > 0.5 ? '#ff4400' : '#555'
316
+ });
317
+ }
318
+ }
319
+
320
+ function update() {
321
+ if(!isStarted) return;
322
+
323
+ if(!isCrashed) {
324
+ // تسارع أسي
325
+ car.speed += car.accel;
326
+ car.accel *= CONFIG.turboMultiplier;
327
+ if(car.speed > CONFIG.targetSpeed) car.speed = CONFIG.targetSpeed;
328
+
329
+ worldX += car.speed * 0.1;
330
+ car.x += car.speed * 0.1;
331
+
332
+ // كاميرا سينمائية (Drag & Zoom)
333
+ let targetCamX = car.x - 300;
334
+ cameraX += (targetCamX - cameraX) * 0.1;
335
+ zoom = 1 - (car.speed / 1000); // ز��م ديناميكي
336
+
337
+ // التحقق من الاصطدام
338
+ if(car.x + car.w >= house.x) {
339
+ explode();
340
+ }
341
+ } else {
342
+ // تحديث الحطام والجزيئات بعد الاصطدام
343
+ debris.forEach(d => {
344
+ d.x += d.vx;
345
+ d.y += d.vy;
346
+ d.vy += CONFIG.gravity;
347
+ d.rot += d.vRot;
348
+ });
349
+ particles.forEach(p => {
350
+ p.x += p.vx;
351
+ p.y += p.vy;
352
+ p.life -= 0.02;
353
+ });
354
+ particles = particles.filter(p => p.life > 0);
355
+ if(shake > 0) shake *= 0.9;
356
+ }
357
+
358
+ updateAudio();
359
+ speedDisplay.innerText = Math.floor(car.speed);
360
+ }
361
+
362
+ function render() {
363
+ ctx.save();
364
+
365
+ // تطبيق اهتزاز الشاشة
366
+ if(shake > 0) {
367
+ ctx.translate(Math.random()*shake - shake/2, Math.random()*shake - shake/2);
368
+ }
369
+
370
+ // تطبيق الزوم
371
+ ctx.scale(zoom, zoom);
372
+
373
+ ctx.clearRect(0, 0, canvas.width, canvas.height);
374
+
375
+ drawCity();
376
+ drawRoad();
377
+ drawHouse();
378
+ drawCar();
379
+
380
+ // رسم الحطام
381
+ debris.forEach(d => {
382
+ ctx.save();
383
+ ctx.translate(d.x - cameraX, d.y);
384
+ ctx.rotate(d.rot);
385
+ ctx.fillStyle = d.color;
386
+ ctx.fillRect(-d.size/2, -d.size/2, d.size, d.size);
387
+ ctx.restore();
388
+ });
389
+
390
+ // رسم الجزيئات
391
+ particles.forEach(p => {
392
+ ctx.globalAlpha = p.life;
393
+ ctx.fillStyle = p.color;
394
+ ctx.beginPath();
395
+ ctx.arc(p.x - cameraX, p.y, p.size || 3, 0, Math.PI*2);
396
+ ctx.fill();
397
+ });
398
+ ctx.globalAlpha = 1;
399
+
400
+ ctx.restore();
401
+ }
402
+
403
+ function loop() {
404
+ update();
405
+ render();
406
+ requestAnimationFrame(loop);
407
+ }
408
+
409
+ window.addEventListener('mousedown', () => {
410
+ if(!isStarted) {
411
+ isStarted = true;
412
+ initAudio();
413
+ document.getElementById('instructions').style.display = 'none';
414
+ }
415
+ });
416
+
417
+ init();
418
+ function init() {
419
+ createCity();
420
+ loop();
421
+ }
422
+
423
+ window.addEventListener('resize', () => {
424
+ canvas.width = window.innerWidth;
425
+ canvas.height = window.innerHeight;
426
+ });
427
+
428
+ </script>
429
+ </body>
430
+ </html>