THEZYZSTUDIO commited on
Commit
500ba0e
·
verified ·
1 Parent(s): b354fe3

Upload car come subway from the z ai agent.html

Browse files
car come subway from the z ai agent.html ADDED
@@ -0,0 +1,298 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="ar" dir="rtl">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
6
+ <title>سباق السيارات ثلاثي الأبعاد - The Z AI Agent</title>
7
+ <style>
8
+ body {
9
+ margin: 0;
10
+ overflow: hidden;
11
+ font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
12
+ background-color: #000;
13
+ user-select: none;
14
+ touch-action: none;
15
+ }
16
+ #ui-layer {
17
+ position: absolute;
18
+ top: 20px;
19
+ width: 100%;
20
+ display: flex;
21
+ justify-content: center;
22
+ pointer-events: none;
23
+ z-index: 10;
24
+ }
25
+ #score-board {
26
+ background: rgba(0, 0, 0, 0.7);
27
+ color: #fff;
28
+ padding: 10px 30px;
29
+ border-radius: 50px;
30
+ font-size: 24px;
31
+ font-weight: bold;
32
+ border: 2px solid #ffcc00;
33
+ box-shadow: 0 0 15px #ffcc00;
34
+ }
35
+ #game-over {
36
+ position: absolute;
37
+ top: 50%;
38
+ left: 50%;
39
+ transform: translate(-50%, -50%);
40
+ background: rgba(0, 0, 0, 0.9);
41
+ color: white;
42
+ padding: 40px;
43
+ text-align: center;
44
+ border-radius: 20px;
45
+ display: none;
46
+ z-index: 20;
47
+ border: 3px solid #ff0000;
48
+ }
49
+ #game-over h1 { font-size: 48px; color: #ff0000; margin-bottom: 10px; }
50
+ #game-over p { font-size: 20px; margin-bottom: 20px; }
51
+ #restart-btn {
52
+ padding: 15px 30px;
53
+ font-size: 20px;
54
+ background: #ffcc00;
55
+ border: none;
56
+ cursor: pointer;
57
+ border-radius: 10px;
58
+ font-weight: bold;
59
+ transition: 0.3s;
60
+ }
61
+ #restart-btn:hover { background: #fff; transform: scale(1.1); }
62
+ #instructions {
63
+ position: absolute;
64
+ bottom: 20px;
65
+ width: 100%;
66
+ text-align: center;
67
+ color: white;
68
+ font-size: 18px;
69
+ opacity: 0.7;
70
+ pointer-events: none;
71
+ }
72
+ </style>
73
+ </head>
74
+ <body>
75
+
76
+ <div id="ui-layer">
77
+ <div id="score-board">النقاط: <span id="score">0</span></div>
78
+ </div>
79
+
80
+ <div id="game-over">
81
+ <h1>لقد اصطدمت!</h1>
82
+ <p>مجموع نقاطك: <span id="final-score">0</span></p>
83
+ <button id="restart-btn">إعادة المحاولة</button>
84
+ </div>
85
+
86
+ <div id="instructions">اضغط على اليمين للذهاب يميناً | اضغط على اليسار للذهاب يساراً</div>
87
+
88
+ <!-- استدعاء مكتبة Three.js من مصدر خارجي موثوق -->
89
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r128/three.min.js"></script>
90
+
91
+ <script>
92
+ /**
93
+ * لعبة سباق السيارات ثلاثية الأبعاد
94
+ * تطوير: THE Z AI Agent
95
+ */
96
+
97
+ // --- الإعدادات الأساسية ---
98
+ let scene, camera, renderer, player;
99
+ let enemies = [];
100
+ let score = 0;
101
+ let gameActive = true;
102
+ let speed = 0.5;
103
+ let laneWidth = 3;
104
+ let playerTargetX = 0;
105
+
106
+ const scoreElement = document.getElementById('score');
107
+ const finalScoreElement = document.getElementById('final-score');
108
+ const gameOverScreen = document.getElementById('game-over');
109
+ const restartBtn = document.getElementById('restart-btn');
110
+
111
+ function init() {
112
+ // 1. إنشاء المشهد
113
+ scene = new THREE.Scene();
114
+ scene.background = new THREE.Color(0x111122);
115
+ scene.fog = new THREE.Fog(0x111122, 10, 50);
116
+
117
+ // 2. الكاميرا
118
+ camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000);
119
+ camera.position.set(0, 5, 10);
120
+ camera.lookAt(0, 0, 0);
121
+
122
+ // 3. الريندر (المصير)
123
+ renderer = new THREE.WebGLRenderer({ antialias: true });
124
+ renderer.setSize(window.innerWidth, window.innerHeight);
125
+ renderer.setPixelRatio(window.devicePixelRatio);
126
+ document.body.appendChild(renderer.domElement);
127
+
128
+ // 4. الإضاءة
129
+ const ambientLight = new THREE.AmbientLight(0xffffff, 0.6);
130
+ scene.add(ambientLight);
131
+
132
+ const dirLight = new THREE.DirectionalLight(0xffffff, 1);
133
+ dirLight.position.set(0, 10, 5);
134
+ scene.add(dirLight);
135
+
136
+ // 5. إنشاء الطريق
137
+ createRoad();
138
+
139
+ // 6. إنشاء سيارة اللاعب
140
+ createPlayer();
141
+
142
+ // 7. إدارة المدخلات
143
+ setupControls();
144
+
145
+ // 8. بدء حلقة اللعبة
146
+ animate();
147
+ }
148
+
149
+ function createRoad() {
150
+ const roadGeo = new THREE.PlaneGeometry(10, 1000);
151
+ const roadMat = new THREE.MeshPhongMaterial({
152
+ color: 0x333333,
153
+ side: THREE.DoubleSide
154
+ });
155
+ const road = new THREE.Mesh(roadGeo, roadMat);
156
+ road.rotation.x = -Math.PI / 2;
157
+ scene.add(road);
158
+
159
+ // إضافة خطوط الطريق البيضاء
160
+ for (let i = 0; i < 100; i++) {
161
+ const lineGeo = new THREE.PlaneGeometry(0.2, 2);
162
+ const lineMat = new THREE.MeshBasicMaterial({ color: 0xffffff });
163
+ const line = new THREE.Mesh(lineGeo, lineMat);
164
+ line.rotation.x = -Math.PI / 2;
165
+ line.position.y = 0.01;
166
+ line.position.z = -i * 10;
167
+ scene.add(line);
168
+ }
169
+ }
170
+
171
+ function createPlayer() {
172
+ // جسم السيارة
173
+ const bodyGeo = new THREE.BoxGeometry(1.2, 0.6, 2);
174
+ const bodyMat = new THREE.MeshPhongMaterial({ color: 0x00ff00 });
175
+ player = new THREE.Mesh(bodyGeo, bodyMat);
176
+ player.position.y = 0.3;
177
+
178
+ // إضافة سقف للسيارة لتبدو أجمل
179
+ const roofGeo = new THREE.BoxGeometry(1, 0.5, 1);
180
+ const roofMat = new THREE.MeshPhongMaterial({ color: 0x00cc00 });
181
+ const roof = new THREE.Mesh(roofGeo, roofMat);
182
+ roof.position.y = 0.5;
183
+ roof.position.z = -0.2;
184
+ player.add(roof);
185
+
186
+ scene.add(player);
187
+ }
188
+
189
+ function spawnEnemy() {
190
+ if (!gameActive) return;
191
+
192
+ const colors = [0xff0000, 0x0000ff, 0xffff00, 0xff00ff];
193
+ const randomColor = colors[Math.floor(Math.random() * colors.length)];
194
+
195
+ const enemyGeo = new THREE.BoxGeometry(1.2, 0.6, 2);
196
+ const enemyMat = new THREE.MeshPhongMaterial({ color: randomColor });
197
+ const enemy = new THREE.Mesh(enemyGeo, enemyMat);
198
+
199
+ // وضع السيارة في أحد المسارات الثلاثة (-3, 0, 3)
200
+ const lanes = [-laneWidth, 0, laneWidth];
201
+ enemy.position.x = lanes[Math.floor(Math.random() * lanes.length)];
202
+ enemy.position.y = 0.3;
203
+ enemy.position.z = -50; // تظهر بعيداً
204
+
205
+ scene.add(enemy);
206
+ enemies.push(enemy);
207
+ }
208
+
209
+ function setupControls() {
210
+ window.addEventListener('mousedown', (e) => {
211
+ if (e.clientX < window.innerWidth / 2) {
212
+ playerTargetX = -laneWidth; // يسار
213
+ } else {
214
+ playerTargetX = laneWidth; // يمين
215
+ }
216
+ });
217
+
218
+ // دعم اللمس للهواتف
219
+ window.addEventListener('touchstart', (e) => {
220
+ const touchX = e.touches[0].clientX;
221
+ if (touchX < window.innerWidth / 2) {
222
+ playerTargetX = -laneWidth;
223
+ } else {
224
+ playerTargetX = laneWidth;
225
+ }
226
+ });
227
+
228
+ // دعم لوحة المفاتيح
229
+ window.addEventListener('keydown', (e) => {
230
+ if (e.key === 'ArrowLeft') playerTargetX = -laneWidth;
231
+ if (e.key === 'ArrowRight') playerTargetX = laneWidth;
232
+ if (e.key === 'ArrowDown') playerTargetX = 0;
233
+ });
234
+ }
235
+
236
+ function checkCollision(obj1, obj2) {
237
+ const box1 = new THREE.Box3().setFromObject(obj1);
238
+ const box2 = new THREE.Box3().setFromObject(obj2);
239
+ return box1.intersectsBox(box2);
240
+ }
241
+
242
+ function animate() {
243
+ if (!gameActive) return;
244
+
245
+ requestAnimationFrame(animate);
246
+
247
+ // تحريك السيارة بسلاسة نحو الهدف
248
+ player.position.x += (playerTargetX - player.position.x) * 0.1;
249
+
250
+ // تحريك الأعداء نحو اللاعب
251
+ for (let i = enemies.length - 1; i >= 0; i--) {
252
+ enemies[i].position.z += speed;
253
+
254
+ // كشف التصادم
255
+ if (checkCollision(player, enemies[i])) {
256
+ endGame();
257
+ }
258
+
259
+ // زيادة النقاط عند تخطي السيارة
260
+ if (enemies[i].position.z > 5) {
261
+ scene.remove(enemies[i]);
262
+ enemies.splice(i, 1);
263
+ score++;
264
+ scoreElement.innerText = score;
265
+
266
+ // زيادة الصعوبة تدريجياً
267
+ speed += 0.005;
268
+ }
269
+ }
270
+
271
+ // توليد أعداء بشكل دوري
272
+ if (Math.random() < 0.02) {
273
+ spawnEnemy();
274
+ }
275
+
276
+ renderer.render(scene, camera);
277
+ }
278
+
279
+ function endGame() {
280
+ gameActive = false;
281
+ finalScoreElement.innerText = score;
282
+ gameOverScreen.style.display = 'block';
283
+ }
284
+
285
+ restartBtn.onclick = () => {
286
+ location.reload(); // إعادة تحميل الصفحة لبدء اللعبة من جديد
287
+ };
288
+
289
+ window.addEventListener('resize', () => {
290
+ camera.aspect = window.innerWidth / window.innerHeight;
291
+ camera.updateProjectionMatrix();
292
+ renderer.setSize(window.innerWidth, window.innerHeight);
293
+ });
294
+
295
+ init();
296
+ </script>
297
+ </body>
298
+ </html>