Spaces:
Running
Running
gini1
commited on
Commit
β’
12d84a4
1
Parent(s):
a3d3e04
Update game.js
Browse files
game.js
CHANGED
@@ -9,7 +9,13 @@ const MAP_SIZE = 2000;
|
|
9 |
const HELICOPTER_HEIGHT = 50;
|
10 |
const ENEMY_SCALE = 3;
|
11 |
const MAX_HEALTH = 1000;
|
12 |
-
const ENEMY_MODELS = [
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
const ENEMY_CONFIG = {
|
14 |
ATTACK_RANGE: 100,
|
15 |
ATTACK_INTERVAL: 2000,
|
@@ -156,35 +162,44 @@ function loadEnemies() {
|
|
156 |
for (let i = 0; i < enemyCount; i++) {
|
157 |
const modelPath = ENEMY_MODELS[i % ENEMY_MODELS.length];
|
158 |
|
159 |
-
loader.load(modelPath,
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
node.
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
188 |
}
|
189 |
}
|
190 |
|
|
|
9 |
const HELICOPTER_HEIGHT = 50;
|
10 |
const ENEMY_SCALE = 3;
|
11 |
const MAX_HEALTH = 1000;
|
12 |
+
const ENEMY_MODELS = [
|
13 |
+
'./models/enemy1.glb', // μ€μ λͺ¨λΈ νμΌ κ²½λ‘λ‘ μμ
|
14 |
+
'./models/enemy2.glb',
|
15 |
+
'./models/enemy3.glb',
|
16 |
+
'./models/enemy4.glb'
|
17 |
+
];
|
18 |
+
|
19 |
const ENEMY_CONFIG = {
|
20 |
ATTACK_RANGE: 100,
|
21 |
ATTACK_INTERVAL: 2000,
|
|
|
162 |
for (let i = 0; i < enemyCount; i++) {
|
163 |
const modelPath = ENEMY_MODELS[i % ENEMY_MODELS.length];
|
164 |
|
165 |
+
loader.load(modelPath,
|
166 |
+
(gltf) => {
|
167 |
+
console.log('Enemy model loaded successfully:', modelPath);
|
168 |
+
const enemy = gltf.scene;
|
169 |
+
enemy.scale.set(ENEMY_SCALE, ENEMY_SCALE, ENEMY_SCALE);
|
170 |
+
|
171 |
+
const angle = (i / enemyCount) * Math.PI * 2;
|
172 |
+
const radius = 200;
|
173 |
+
enemy.position.set(
|
174 |
+
Math.cos(angle) * radius,
|
175 |
+
10,
|
176 |
+
Math.sin(angle) * radius
|
177 |
+
);
|
178 |
+
|
179 |
+
enemy.traverse((node) => {
|
180 |
+
if (node.isMesh) {
|
181 |
+
node.castShadow = true;
|
182 |
+
node.receiveShadow = true;
|
183 |
+
node.material.metalness = 0.2;
|
184 |
+
node.material.roughness = 0.8;
|
185 |
+
}
|
186 |
+
});
|
187 |
+
|
188 |
+
scene.add(enemy);
|
189 |
+
enemies.push({
|
190 |
+
model: enemy,
|
191 |
+
health: 100,
|
192 |
+
speed: 0.3 + (currentStage * 0.1),
|
193 |
+
lastAttackTime: 0
|
194 |
+
});
|
195 |
+
},
|
196 |
+
(xhr) => {
|
197 |
+
console.log((xhr.loaded / xhr.total * 100) + '% loaded');
|
198 |
+
},
|
199 |
+
(error) => {
|
200 |
+
console.error('Error loading enemy model:', error);
|
201 |
+
}
|
202 |
+
);
|
203 |
}
|
204 |
}
|
205 |
|