cutechicken commited on
Commit
527dc11
Β·
verified Β·
1 Parent(s): 2a955e1

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +25 -47
index.html CHANGED
@@ -835,69 +835,47 @@ const defaultPlayerStats = {
835
  //3μŠ€ν…Œμ΄μ§€ λ¨ΈμŠ€νƒ±
836
  class P51 {
837
  constructor(x) {
838
- this.x = x; // P51의 x μ’Œν‘œ (κ³ μ •)
839
- this.y = 0; // μ‹œμž‘ 높이 (ν™”λ©΄ μ΅œμƒλ‹¨)
840
- this.speed = 3; // ν•˜κ°• 속도
841
- this.width = 100; // 폭격기 이미지 λ„ˆλΉ„
842
- this.height = 100; // 폭격기 이미지 높이
843
- this.lastBombTime = 0; // λ§ˆμ§€λ§‰ 폭탄 νˆ¬ν•˜ μ‹œκ°„
844
- this.bombInterval = 500; // 폭탄 νˆ¬ν•˜ 간격 (0.5초)
845
  this.img = new Image();
846
- this.img.src = 'p51.png'; // 폭격기 이미지
847
  }
848
 
849
- // 폭탄 νˆ¬ν•˜ λ©”μ„œλ“œ
850
- dropBomb() {
851
- // 상점이 μ—΄λ €μžˆμœΌλ©΄ 폭탄을 νˆ¬ν•˜ν•˜μ§€ μ•ŠμŒ
852
- if (document.getElementById('shop').style.display === 'block') return;
853
-
854
- // 폭발 μ†Œλ¦¬ μž¬μƒ
855
- const bombSound = new Audio('bomb2.ogg');
856
- bombSound.volume = 0.5;
857
- bombSound.play();
858
 
859
- // 폭발 μ΄νŽ™νŠΈ 생성
860
- effects.push(new Effect(
861
- this.x,
862
- this.y,
863
- 500,
864
- 'bomb',
865
- 0
866
- ));
867
 
868
- // 폭발 λ²”μœ„ λ‚΄ ν”Œλ ˆμ΄μ–΄μ™€ μ•„κ΅° μœ λ‹›μ— 데미지
869
- const blastRadius = 100;
870
-
871
- // ν”Œλ ˆμ΄μ–΄ 데미지 체크
872
- const distToPlayer = Math.hypot(this.x - player.x, this.y - player.y);
873
- if (distToPlayer < blastRadius) {
874
- player.health -= 400;
875
- }
876
-
877
- // μ•„κ΅° μœ λ‹› 데미지 체크
878
- allyUnits.forEach(ally => {
879
- const distToAlly = Math.hypot(this.x - ally.x, this.y - ally.y);
880
- if (distToAlly < blastRadius) {
881
- ally.health -= 400;
882
- }
883
  });
884
  }
885
 
886
- // P51 μ—…λ°μ΄νŠΈ λ©”μ„œλ“œ
887
  update() {
888
  if (isCountingDown) return true;
889
 
890
- // μ•„λž˜λ‘œ 이동
891
  this.y += this.speed;
892
 
893
- // 폭탄 νˆ¬ν•˜ 타이밍 체크
894
  const now = Date.now();
895
- if (now - this.lastBombTime > this.bombInterval) {
896
- this.dropBomb();
897
- this.lastBombTime = now;
898
  }
899
 
900
- // ν™”λ©΄ ν•˜λ‹¨μ— λ„λ‹¬ν–ˆλŠ”μ§€ 체크
901
  return this.y < canvas.height;
902
  }
903
  }
 
835
  //3μŠ€ν…Œμ΄μ§€ λ¨ΈμŠ€νƒ±
836
  class P51 {
837
  constructor(x) {
838
+ this.x = x;
839
+ this.y = 0;
840
+ this.speed = 3;
841
+ this.width = 100;
842
+ this.height = 100;
843
+ this.lastShot = 0;
844
+ this.fireRate = 200;
845
  this.img = new Image();
846
+ this.img.src = 'p51.png';
847
  }
848
 
849
+ shoot() {
850
+ if (isCountingDown || document.getElementById('shop').style.display === 'block') return;
 
 
 
 
 
 
 
851
 
852
+ const mgSound = new Audio('firemg.ogg');
853
+ mgSound.volume = 0.5;
854
+ mgSound.play();
 
 
 
 
 
855
 
856
+ bullets.push({
857
+ x: this.x,
858
+ y: this.y,
859
+ angle: Math.PI / 2, // Shooting downward
860
+ speed: 10,
861
+ isEnemy: true,
862
+ damage: 100,
863
+ size: 2,
864
+ isP51Bullet: true
 
 
 
 
 
 
865
  });
866
  }
867
 
 
868
  update() {
869
  if (isCountingDown) return true;
870
 
 
871
  this.y += this.speed;
872
 
 
873
  const now = Date.now();
874
+ if (now - this.lastShot > this.fireRate) {
875
+ this.shoot();
876
+ this.lastShot = now;
877
  }
878
 
 
879
  return this.y < canvas.height;
880
  }
881
  }