cutechicken commited on
Commit
ddba75e
·
verified ·
1 Parent(s): 0c1357b

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +59 -62
index.html CHANGED
@@ -198,68 +198,65 @@
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 ? 4000 : 1000; // 보스 체력 4배 강화
205
- this.maxHealth = this.health;
206
- this.speed = isBoss ? 1 : 2;
207
- this.lastShot = 0;
208
- this.shootInterval = isBoss ? 500 : 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
-
229
- update() {
230
- if (isCountingDown) return;
231
- const now = Date.now();
232
-
233
- if (now - this.moveTimer > this.moveInterval) {
234
- this.moveAngle = Math.random() * Math.PI * 2;
235
- this.moveTimer = now;
236
- }
237
- this.x += Math.cos(this.moveAngle) * this.speed;
238
- this.y += Math.sin(this.moveAngle) * this.speed;
239
- this.x = Math.max(this.width / 2, Math.min(canvas.width - this.width / 2, this.x));
240
- this.y = Math.max(this.height / 2, Math.min(canvas.height - this.height / 2, this.y));
241
- this.angle = Math.atan2(player.y - this.y, player.x - this.x);
242
-
243
- if (now - this.lastShot > this.shootInterval && !isCountingDown) {
244
- this.shoot();
245
- this.lastShot = now;
246
- }
247
- }
248
-
249
- shoot() {
250
- const sound = this.isBoss ? new Audio('firemn.ogg') : enemyFireSound.cloneNode();
251
- sound.play();
252
-
253
- bullets.push({
254
- x: this.x + Math.cos(this.angle) * 30,
255
- y: this.y + Math.sin(this.angle) * 30,
256
- angle: this.angle,
257
- speed: this.isBoss ? 10 : 5, // 보스 탄환 속도 증가
258
- isEnemy: true,
259
- size: this.isBoss ? 5 : 3,
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() {