cutechicken commited on
Commit
a1af420
·
verified ·
1 Parent(s): 462f002

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +45 -71
index.html CHANGED
@@ -190,36 +190,34 @@
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 ? 20000 : 1000; // 보스 체력 4배로 증가
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
- }
211
-
212
- if (isBoss) {
213
- this.enemyImg = new Image();
214
- this.enemyImg.src = 'boss.png';
215
- } else if (currentRound >= 7) {
216
- this.enemyImg = new Image();
217
- this.enemyImg.src = 'enemy3.png';
218
- } else if (currentRound >= 4) {
219
- this.enemyImg = new Image();
220
- this.enemyImg.src = 'enemy2.png';
221
- }
222
- }
223
 
224
  update() {
225
  if(isCountingDown) return;
@@ -241,43 +239,19 @@
241
  }
242
  }
243
 
244
- shoot() {
245
- const now = Date.now();
246
-
247
- // 기관총을 특정 간격마다 섞어서 발사
248
- if (this.isBoss && Math.floor(now / 1000) % 3 === 0) {
249
- const sound = new Audio('firemg.ogg'); // 기관총 소리
250
- sound.play();
251
-
252
- // 기관총 탄환 5 발사
253
- for (let i = -2; i <= 2; i++) { // 총 5발: -2, -1, 0, 1, 2
254
- const spreadAngle = this.angle + i * 0.1; // 각도 차이를 적용
255
- bullets.push({
256
- x: this.x + Math.cos(spreadAngle) * 30,
257
- y: this.y + Math.sin(spreadAngle) * 30,
258
- angle: spreadAngle,
259
- speed: 8, // 기관총 탄환 속도
260
- isEnemy: true,
261
- size: 2, // 작은 크기의 탄환
262
- damage: 50 // 기관총 탄환 피해량
263
- });
264
  }
265
- } else {
266
- // 기존의 기본 공격
267
- const sound = this.isBoss ? new Audio('firemn.ogg') : enemyFireSound.cloneNode();
268
- sound.play();
269
-
270
- bullets.push({
271
- x: this.x + Math.cos(this.angle) * 30,
272
- y: this.y + Math.sin(this.angle) * 30,
273
- angle: this.angle,
274
- speed: 5,
275
- isEnemy: true,
276
- size: this.isBoss ? 5 : 3,
277
- damage: this.isBoss ? 300 : 150 // 기본 공격 피해량
278
- });
279
- }
280
- }
281
 
282
  function showShop() {
283
  document.getElementById('shop').style.display = 'block';
@@ -300,8 +274,8 @@ function buyTank(tankImg, cost, tankId) {
300
  if (tankId === 'tank1') { // PZ.IV
301
  player.maxHealth = 1500;
302
  player.speed = defaultPlayerStats.speed; // 기본 이동속도로 복구
303
- player.width = 95; // PZ.IV의 크기 설정
304
- player.height = 50; // PZ.IV의 크기 설정
305
  }
306
  else if (tankId === 'tank2') { // TIGER
307
  player.maxHealth = 2000;
@@ -345,7 +319,7 @@ function buyTank(tankImg, cost, tankId) {
345
  keys[e.key] = true;
346
  if(e.key.toLowerCase() === 'c') {
347
  currentWeapon = currentWeapon === 'cannon' ? 'machinegun' : 'cannon';
348
- weaponInfo.textContent = `Current Weapon: ${currentWeapon.charAt(0).toUpperCase() + currentWeapon.slice(1)}`;
349
  } else if(e.key.toLowerCase() === 'r') {
350
  autoFire = !autoFire;
351
  }
@@ -502,8 +476,8 @@ function buyTank(tankImg, cost, tankId) {
502
  // UI 그리기
503
  ctx.fillStyle = 'white';
504
  ctx.font = '24px Arial';
505
- ctx.fillText(`Round ${currentRound}/10`, 10, 30);
506
- ctx.fillText(`Gold: ${gold}`, 10, 60);
507
 
508
  if(isCountingDown) {
509
  ctx.fillStyle = 'rgba(0, 0, 0, 0.5)';
 
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;
 
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';
 
274
  if (tankId === 'tank1') { // PZ.IV
275
  player.maxHealth = 1500;
276
  player.speed = defaultPlayerStats.speed; // 기본 이동속도로 복구
277
+ player.width = 100; // PZ.IV의 크기 설정
278
+ player.height = 55; // PZ.IV의 크기 설정
279
  }
280
  else if (tankId === 'tank2') { // TIGER
281
  player.maxHealth = 2000;
 
319
  keys[e.key] = true;
320
  if(e.key.toLowerCase() === 'c') {
321
  currentWeapon = currentWeapon === 'cannon' ? 'machinegun' : 'cannon';
322
+ weaponInfo.textContent = Current Weapon: ${currentWeapon.charAt(0).toUpperCase() + currentWeapon.slice(1)};
323
  } else if(e.key.toLowerCase() === 'r') {
324
  autoFire = !autoFire;
325
  }
 
476
  // UI 그리기
477
  ctx.fillStyle = 'white';
478
  ctx.font = '24px Arial';
479
+ ctx.fillText(Round ${currentRound}/10, 10, 30);
480
+ ctx.fillText(Gold: ${gold}, 10, 60);
481
 
482
  if(isCountingDown) {
483
  ctx.fillStyle = 'rgba(0, 0, 0, 0.5)';