Aleksmorshen commited on
Commit
436fe15
·
verified ·
1 Parent(s): 420114b

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +169 -63
index.html CHANGED
@@ -1,87 +1,193 @@
 
1
  <!DOCTYPE html>
2
- <html lang="ru">
3
  <head>
4
  <meta charset="UTF-8">
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
- <title>360 Лесной Скайбокс</title>
7
-
8
- <!-- Стили Pannellum (загружаются из CDN) -->
9
- <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/build/pannellum.css"/>
10
-
11
  <style>
12
- /* Общие стили для страницы */
13
- body, html {
14
  margin: 0;
15
- padding: 0;
16
- height: 100%;
17
- width: 100%;
18
- overflow: hidden; /* Убираем полосы прокрутки */
19
- font-family: sans-serif;
20
- background-color: #f0f0f0;
21
- color: #333;
22
  }
23
-
24
- /* Контейнер для панорамы */
25
- #panorama {
26
- width: 100%;
27
- height: 100%;
28
  }
29
-
30
- /* Стили для инструкции (по желанию) */
31
- .instruction {
32
  position: absolute;
33
- top: 10px;
34
  left: 50%;
35
- transform: translateX(-50%);
36
- background-color: rgba(0, 0, 0, 0.6);
37
  color: white;
38
- padding: 8px 15px;
39
- border-radius: 5px;
40
- font-size: 14px;
41
- z-index: 1000;
42
- text-align: center;
43
  }
44
-
45
- @media (max-width: 600px) {
46
- .instruction {
47
- font-size: 12px;
48
- padding: 6px 10px;
49
- }
50
  }
51
  </style>
 
52
  </head>
53
  <body>
 
 
 
 
 
 
 
 
 
54
 
55
- <!-- Контейнер, куда будет загружена панорама -->
56
- <div id="panorama"></div>
 
 
 
 
57
 
58
- <!-- Инструкция для пользователя -->
59
- <div class="instruction">
60
- Перетащите мышью, чтобы вращать. Колесо мыши - масштабирование.
61
- </div>
 
 
 
62
 
63
- <!-- Скрипт Pannellum (загружается из CDN) -->
64
- <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/[email protected]/build/pannellum.js"></script>
 
 
 
 
 
 
 
 
 
 
 
 
65
 
66
- <script>
67
- // Инициализация Pannellum после полной загрузки DOM
68
- document.addEventListener('DOMContentLoaded', function() {
69
- pannellum.viewer('panorama', {
70
- "type": "equirectangular", // Тип панорамы (эквиректакулярная)
71
- "panorama": "forest_skybox.jpg", // *** ВАЖНО: Укажите здесь ПРАВИЛЬНОЕ ИМЯ ВАШЕГО ФАЙЛА С ИЗОБРАЖЕНИЕМ ***
72
- "autoLoad": true, // Автоматически загружать панораму
73
- "autoRotate": -2, // Автоматическое медленное вращение (-2 для вращения влево, 2 для вправо)
74
- "autoRotateInactivityDelay": 1000, // Задержка перед началом авто-вращения после неактивности пользователя
75
- "orientationOnByDefault": false, // Не использовать гироскоп по умолчанию (для мобильных)
76
- "showZoom": true, // Показывать кнопки масштабирования
77
- "showControls": true, // Показывать элементы управления (зум, полноэкранный режим)
78
- "mouseZoom": true, // Включить зум колесом мыши
79
- "hfov": 100, // Начальный горизонтальный угол обзора (Field of View)
80
- "minHfov": 50, // Минимальный горизонтальный угол обзора (максимальное увеличение)
81
- "maxHfov": 120 // Максимальный горизонтальный угол обзора (минимальное увеличение)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
82
  });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
83
  });
84
  </script>
85
-
86
  </body>
87
- </html>
 
1
+
2
  <!DOCTYPE html>
3
+ <html lang="en">
4
  <head>
5
  <meta charset="UTF-8">
6
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
7
+ <title>Doom-like FPS Game</title>
 
 
 
 
8
  <style>
9
+ body {
 
10
  margin: 0;
11
+ overflow: hidden;
 
 
 
 
 
 
12
  }
13
+ canvas {
14
+ display: block;
 
 
 
15
  }
16
+ #crosshair {
 
 
17
  position: absolute;
18
+ top: 50%;
19
  left: 50%;
20
+ transform: translate(-50%, -50%);
21
+ font-size: 24px;
22
  color: white;
23
+ pointer-events: none;
 
 
 
 
24
  }
25
+ #hud {
26
+ position: absolute;
27
+ bottom: 10px;
28
+ left: 10px;
29
+ color: white;
30
+ font-family: Arial, sans-serif;
31
  }
32
  </style>
33
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r128/three.min.js"></script>
34
  </head>
35
  <body>
36
+ <div id="crosshair">+</div>
37
+ <div id="hud">Health: <span id="health">100</span> | Kills: <span id="kills">0</span></div>
38
+ <script>
39
+ // Scene setup
40
+ const scene = new THREE.Scene();
41
+ const camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000);
42
+ const renderer = new THREE.WebGLRenderer();
43
+ renderer.setSize(window.innerWidth, window.innerHeight);
44
+ document.body.appendChild(renderer.domElement);
45
 
46
+ // Lighting
47
+ const ambientLight = new THREE.AmbientLight(0x404040);
48
+ scene.add(ambientLight);
49
+ const directionalLight = new THREE.DirectionalLight(0xffffff, 0.5);
50
+ directionalLight.position.set(1, 1, 1);
51
+ scene.add(directionalLight);
52
 
53
+ // Floor
54
+ const floorGeometry = new THREE.PlaneGeometry(100, 100);
55
+ const floorMaterial = new THREE.MeshBasicMaterial({ color: 0x555555, side: THREE.DoubleSide });
56
+ const floor = new THREE.Mesh(floorGeometry, floorMaterial);
57
+ floor.rotation.x = Math.PI / 2;
58
+ floor.position.y = -1;
59
+ scene.add(floor);
60
 
61
+ // Walls for a simple room
62
+ const wallMaterial = new THREE.MeshBasicMaterial({ color: 0x888888 });
63
+ const wall1 = new THREE.Mesh(new THREE.BoxGeometry(100, 10, 1), wallMaterial);
64
+ wall1.position.set(0, 4, -50);
65
+ scene.add(wall1);
66
+ const wall2 = new THREE.Mesh(new THREE.BoxGeometry(100, 10, 1), wallMaterial);
67
+ wall2.position.set(0, 4, 50);
68
+ scene.add(wall2);
69
+ const wall3 = new THREE.Mesh(new THREE.BoxGeometry(1, 10, 100), wallMaterial);
70
+ wall3.position.set(-50, 4, 0);
71
+ scene.add(wall3);
72
+ const wall4 = new THREE.Mesh(new THREE.BoxGeometry(1, 10, 100), wallMaterial);
73
+ wall4.position.set(50, 4, 0);
74
+ scene.add(wall4);
75
 
76
+ // Player setup
77
+ camera.position.y = 1; // Eye level
78
+ const playerVelocity = new THREE.Vector3();
79
+ const playerDirection = new THREE.Vector3();
80
+ const moveSpeed = 0.1;
81
+ let health = 100;
82
+ let kills = 0;
83
+
84
+ // Controls
85
+ const keys = {};
86
+ document.addEventListener('keydown', (e) => keys[e.key.toLowerCase()] = true);
87
+ document.addEventListener('keyup', (e) => keys[e.key.toLowerCase()] = false);
88
+
89
+ // Mouse look
90
+ let mouseX = 0, mouseY = 0;
91
+ document.addEventListener('mousemove', (e) => {
92
+ mouseX = e.movementX * 0.002;
93
+ mouseY = e.movementY * 0.002;
94
+ });
95
+
96
+ // Pointer lock
97
+ document.body.addEventListener('click', () => {
98
+ document.body.requestPointerLock();
99
+ });
100
+
101
+ // Shooting
102
+ const raycaster = new THREE.Raycaster();
103
+ const mouse = new THREE.Vector2(0, 0); // Center for crosshair
104
+ document.addEventListener('click', shoot);
105
+
106
+ function shoot() {
107
+ raycaster.setFromCamera(mouse, camera);
108
+ const intersects = raycaster.intersectObjects(demons);
109
+ if (intersects.length > 0) {
110
+ const demon = intersects[0].object;
111
+ scene.remove(demon);
112
+ demons = demons.filter(d => d !== demon);
113
+ kills++;
114
+ document.getElementById('kills').innerText = kills;
115
+ if (demons.length === 0) {
116
+ alert('You win! All demons killed.');
117
+ }
118
+ }
119
+ }
120
+
121
+ // Demons
122
+ const demonMaterial = new THREE.MeshBasicMaterial({ color: 0xff0000 });
123
+ const demons = [];
124
+ for (let i = 0; i < 5; i++) {
125
+ const demon = new THREE.Mesh(new THREE.SphereGeometry(1, 32, 32), demonMaterial);
126
+ demon.position.set(Math.random() * 80 - 40, 0, Math.random() * 80 - 40);
127
+ scene.add(demon);
128
+ demons.push(demon);
129
+ }
130
+
131
+ // Demon AI (simple chase)
132
+ function updateDemons() {
133
+ demons.forEach(demon => {
134
+ const direction = new THREE.Vector3();
135
+ direction.subVectors(camera.position, demon.position).normalize();
136
+ demon.position.add(direction.multiplyScalar(0.02));
137
+
138
+ // Check collision with player
139
+ if (demon.position.distanceTo(camera.position) < 1.5) {
140
+ health -= 1;
141
+ document.getElementById('health').innerText = health;
142
+ if (health <= 0) {
143
+ alert('Game Over! You died.');
144
+ health = 100;
145
+ kills = 0;
146
+ // Reset game if needed
147
+ }
148
+ }
149
  });
150
+ }
151
+
152
+ // Animation loop
153
+ function animate() {
154
+ requestAnimationFrame(animate);
155
+
156
+ // Rotation (mouse look)
157
+ camera.rotation.y -= mouseX;
158
+ camera.rotation.x -= mouseY;
159
+ camera.rotation.x = Math.max(-Math.PI / 2, Math.min(Math.PI / 2, camera.rotation.x));
160
+ mouseX = 0;
161
+ mouseY = 0;
162
+
163
+ // Movement
164
+ playerDirection.set(0, 0, 0);
165
+ if (keys['w']) playerDirection.z -= 1;
166
+ if (keys['s']) playerDirection.z += 1;
167
+ if (keys['a']) playerDirection.x -= 1;
168
+ if (keys['d']) playerDirection.x += 1;
169
+ playerDirection.normalize();
170
+ playerDirection.applyEuler(camera.rotation);
171
+ playerVelocity.add(playerDirection.multiplyScalar(moveSpeed));
172
+ playerVelocity.multiplyScalar(0.95); // Friction
173
+ camera.position.add(playerVelocity);
174
+
175
+ // Prevent going through walls (basic collision)
176
+ camera.position.x = Math.max(-49, Math.min(49, camera.position.x));
177
+ camera.position.z = Math.max(-49, Math.min(49, camera.position.z));
178
+
179
+ updateDemons();
180
+
181
+ renderer.render(scene, camera);
182
+ }
183
+ animate();
184
+
185
+ // Resize handler
186
+ window.addEventListener('resize', () => {
187
+ camera.aspect = window.innerWidth / window.innerHeight;
188
+ camera.updateProjectionMatrix();
189
+ renderer.setSize(window.innerWidth, window.innerHeight);
190
  });
191
  </script>
 
192
  </body>
193
+ </html>