Spaces:
Running
Running
cutechicken
commited on
Update index.html
Browse files- index.html +59 -62
index.html
CHANGED
@@ -198,68 +198,65 @@
|
|
198 |
}, 1000);
|
199 |
}
|
200 |
class Enemy {
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
damage: this.isBoss ? 300 : 150 // 보스 데미지 유지
|
261 |
-
});
|
262 |
-
}
|
263 |
}
|
264 |
}
|
265 |
function showShop() {
|
|
|
198 |
}, 1000);
|
199 |
}
|
200 |
class Enemy {
|
201 |
+
constructor(isBoss = false) {
|
202 |
+
this.x = Math.random() * canvas.width;
|
203 |
+
this.y = Math.random() * canvas.height;
|
204 |
+
this.health = isBoss ? 20000 : 1000;
|
205 |
+
this.maxHealth = this.health;
|
206 |
+
this.speed = isBoss ? 1 : 2;
|
207 |
+
this.lastShot = 0;
|
208 |
+
this.shootInterval = isBoss ? 1000 : 1000;
|
209 |
+
this.angle = 0;
|
210 |
+
this.width = 100;
|
211 |
+
this.height = 45;
|
212 |
+
this.moveTimer = 0;
|
213 |
+
this.moveInterval = Math.random() * 2000 + 1000;
|
214 |
+
this.moveAngle = Math.random() * Math.PI * 2;
|
215 |
+
this.isBoss = isBoss;
|
216 |
+
|
217 |
+
if (isBoss) {
|
218 |
+
this.enemyImg = new Image();
|
219 |
+
this.enemyImg.src = 'boss.png';
|
220 |
+
} else if (currentRound >= 7) {
|
221 |
+
this.enemyImg = new Image();
|
222 |
+
this.enemyImg.src = 'enemy3.png';
|
223 |
+
} else if (currentRound >= 4) {
|
224 |
+
this.enemyImg = new Image();
|
225 |
+
this.enemyImg.src = 'enemy2.png';
|
226 |
+
}
|
227 |
+
}
|
228 |
+
update() {
|
229 |
+
if(isCountingDown) return;
|
230 |
+
const now = Date.now();
|
231 |
+
|
232 |
+
if (now - this.moveTimer > this.moveInterval) {
|
233 |
+
this.moveAngle = Math.random() * Math.PI * 2;
|
234 |
+
this.moveTimer = now;
|
235 |
+
}
|
236 |
+
this.x += Math.cos(this.moveAngle) * this.speed;
|
237 |
+
this.y += Math.sin(this.moveAngle) * this.speed;
|
238 |
+
this.x = Math.max(this.width/2, Math.min(canvas.width - this.width/2, this.x));
|
239 |
+
this.y = Math.max(this.height/2, Math.min(canvas.height - this.height/2, this.y));
|
240 |
+
this.angle = Math.atan2(player.y - this.y, player.x - this.x);
|
241 |
+
|
242 |
+
if (now - this.lastShot > this.shootInterval && !isCountingDown) {
|
243 |
+
this.shoot();
|
244 |
+
this.lastShot = now;
|
245 |
+
}
|
246 |
+
}
|
247 |
+
shoot() {
|
248 |
+
const sound = this.isBoss ? new Audio('firemn.ogg') : enemyFireSound.cloneNode();
|
249 |
+
sound.play();
|
250 |
+
|
251 |
+
bullets.push({
|
252 |
+
x: this.x + Math.cos(this.angle) * 30,
|
253 |
+
y: this.y + Math.sin(this.angle) * 30,
|
254 |
+
angle: this.angle,
|
255 |
+
speed: 5,
|
256 |
+
isEnemy: true,
|
257 |
+
size: this.isBoss ? 5 : 3,
|
258 |
+
damage: this.isBoss ? 300 : 150 // 보스 200 -> 300, 일반 적 100 -> 150으로 강화
|
259 |
+
});
|
|
|
|
|
|
|
260 |
}
|
261 |
}
|
262 |
function showShop() {
|