cutechicken commited on
Commit
895f9d2
·
verified ·
1 Parent(s): a1af420

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +90 -59
index.html CHANGED
@@ -190,69 +190,100 @@
190
  }, 1000);
191
  }
192
 
193
- class Enemy {
194
- constructor(isBoss = false) {
195
- this.x = Math.random() * canvas.width;
196
- this.y = Math.random() * canvas.height;
197
- this.health = isBoss ? 5000 : 1000;
198
- this.maxHealth = this.health;
199
- this.speed = isBoss ? 1 : 2;
200
- this.lastShot = 0;
201
- this.shootInterval = isBoss ? 1000 : 1000;
202
- this.angle = 0;
203
- this.width = 100;
204
- this.height = 45;
205
- this.moveTimer = 0;
206
- this.moveInterval = Math.random() * 2000 + 1000;
207
- this.moveAngle = Math.random() * Math.PI * 2;
208
- this.isBoss = isBoss;
209
-
210
- if (isBoss) {
211
- this.enemyImg = new Image();
212
- this.enemyImg.src = 'boss.png';
213
- } else if (currentRound >= 7) {
214
- this.enemyImg = new Image();
215
- this.enemyImg.src = 'enemy3.png';
216
- } else if (currentRound >= 4) {
217
- this.enemyImg = new Image();
218
- this.enemyImg.src = 'enemy2.png';
219
- }
220
- }
221
 
222
- update() {
223
- if(isCountingDown) return;
224
- const now = Date.now();
225
-
226
- if (now - this.moveTimer > this.moveInterval) {
227
- this.moveAngle = Math.random() * Math.PI * 2;
228
- this.moveTimer = now;
229
- }
230
- this.x += Math.cos(this.moveAngle) * this.speed;
231
- this.y += Math.sin(this.moveAngle) * this.speed;
232
- this.x = Math.max(this.width/2, Math.min(canvas.width - this.width/2, this.x));
233
- this.y = Math.max(this.height/2, Math.min(canvas.height - this.height/2, this.y));
234
- this.angle = Math.atan2(player.y - this.y, player.x - this.x);
235
-
236
- if (now - this.lastShot > this.shootInterval && !isCountingDown) {
237
- this.shoot();
238
- this.lastShot = now;
239
- }
240
- }
241
 
242
- shoot() {
243
- enemyFireSound.cloneNode().play();
244
- bullets.push({
245
- x: this.x + Math.cos(this.angle) * 30,
246
- y: this.y + Math.sin(this.angle) * 30,
247
- angle: this.angle,
248
- speed: 5,
249
- isEnemy: true,
250
- size: this.isBoss ? 5 : 3,
251
- damage: this.isBoss ? 200 : 100
252
- });
253
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
254
  }
 
 
 
 
 
255
 
 
 
 
 
 
 
 
 
 
 
 
256
  function showShop() {
257
  document.getElementById('shop').style.display = 'block';
258
  }
 
190
  }, 1000);
191
  }
192
 
193
+ class Enemy {
194
+ constructor(isBoss = false) {
195
+ this.x = Math.random() * canvas.width;
196
+ this.y = Math.random() * canvas.height;
197
+ this.health = isBoss ? 5000 : 1000;
198
+ this.maxHealth = this.health;
199
+ this.speed = isBoss ? 1 : 2;
200
+ this.lastShot = 0;
201
+ this.shootInterval = isBoss ? 1000 : 1000;
202
+ this.angle = 0;
203
+ this.width = 100;
204
+ this.height = 45;
205
+ this.moveTimer = 0;
206
+ this.moveInterval = Math.random() * 2000 + 1000;
207
+ this.moveAngle = Math.random() * Math.PI * 2;
208
+ this.isBoss = isBoss;
209
+ this.lastMachineGunShot = 0; // 기관총 발사 시점 추가
210
+ if (isBoss) {
211
+ this.enemyImg = new Image();
212
+ this.enemyImg.src = 'boss.png';
213
+ } else if (currentRound >= 7) {
214
+ this.enemyImg = new Image();
215
+ this.enemyImg.src = 'enemy3.png';
216
+ } else if (currentRound >= 4) {
217
+ this.enemyImg = new Image();
218
+ this.enemyImg.src = 'enemy2.png';
219
+ }
220
+ }
221
 
222
+ update() {
223
+ if (isCountingDown) return;
224
+ const now = Date.now();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
225
 
226
+ if (now - this.moveTimer > this.moveInterval) {
227
+ this.moveAngle = Math.random() * Math.PI * 2;
228
+ this.moveTimer = now;
229
+ }
230
+ this.x += Math.cos(this.moveAngle) * this.speed;
231
+ this.y += Math.sin(this.moveAngle) * this.speed;
232
+ this.x = Math.max(this.width / 2, Math.min(canvas.width - this.width / 2, this.x));
233
+ this.y = Math.max(this.height / 2, Math.min(canvas.height - this.height / 2, this.y));
234
+ this.angle = Math.atan2(player.y - this.y, player.x - this.x);
235
+
236
+ if (now - this.lastShot > this.shootInterval && !isCountingDown) {
237
+ this.shoot();
238
+ this.lastShot = now;
239
+ }
240
+ }
241
+
242
+ shoot() {
243
+ const now = Date.now();
244
+
245
+ // 기관총 발사 조건
246
+ if (this.isBoss && now - this.lastMachineGunShot > 3000) { // 3초 간격
247
+ this.lastMachineGunShot = now;
248
+ this.fireMachineGun();
249
+ } else {
250
+ this.fireCannon();
251
+ }
252
+ }
253
+
254
+ fireMachineGun() {
255
+ const sound = machinegunSound;
256
+ sound.play();
257
+
258
+ for (let i = -2; i <= 2; i++) {
259
+ const spreadAngle = this.angle + i * 0.1;
260
+ bullets.push({
261
+ x: this.x + Math.cos(spreadAngle) * 30,
262
+ y: this.y + Math.sin(spreadAngle) * 30,
263
+ angle: spreadAngle,
264
+ speed: 8,
265
+ isEnemy: true,
266
+ size: 2,
267
+ damage: 50,
268
+ });
269
  }
270
+ }
271
+
272
+ fireCannon() {
273
+ const sound = this.isBoss ? cannonSound : enemyFireSound.cloneNode();
274
+ sound.play();
275
 
276
+ bullets.push({
277
+ x: this.x + Math.cos(this.angle) * 30,
278
+ y: this.y + Math.sin(this.angle) * 30,
279
+ angle: this.angle,
280
+ speed: 5,
281
+ isEnemy: true,
282
+ size: this.isBoss ? 5 : 3,
283
+ damage: this.isBoss ? 300 : 150,
284
+ });
285
+ }
286
+ }
287
  function showShop() {
288
  document.getElementById('shop').style.display = 'block';
289
  }