gini1 commited on
Commit
12d84a4
β€’
1 Parent(s): a3d3e04

Update game.js

Browse files
Files changed (1) hide show
  1. game.js +45 -30
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 = ['1.GLB', '2.GLB', '3.GLB', '4.GLB'];
 
 
 
 
 
 
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, (gltf) => {
160
- const enemy = gltf.scene;
161
- enemy.scale.set(ENEMY_SCALE, ENEMY_SCALE, ENEMY_SCALE);
162
-
163
- const angle = (i / enemyCount) * Math.PI * 2;
164
- const radius = 200;
165
- enemy.position.set(
166
- Math.cos(angle) * radius,
167
- 10,
168
- Math.sin(angle) * radius
169
- );
170
-
171
- enemy.traverse((node) => {
172
- if (node.isMesh) {
173
- node.castShadow = true;
174
- node.receiveShadow = true;
175
- node.material.metalness = 0.2;
176
- node.material.roughness = 0.8;
177
- }
178
- });
179
-
180
- scene.add(enemy);
181
- enemies.push({
182
- model: enemy,
183
- health: 100,
184
- speed: 0.3 + (currentStage * 0.1),
185
- lastAttackTime: 0
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