cutechicken commited on
Commit
9016cf0
·
verified ·
1 Parent(s): 46e5238

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +50 -22
index.html CHANGED
@@ -110,6 +110,13 @@
110
  <p style="color: #ff6b6b;">-30% Speed</p>
111
  <button onclick="buyTank('player3.png', 500, 'tank2')">Buy</button>
112
  </div>
 
 
 
 
 
 
 
113
  </div>
114
  </div>
115
  <button id="bossButton" class="button">Fight Boss!</button>
@@ -140,6 +147,7 @@
140
  let gold = 0;
141
  let isBossStage = false;
142
  let effects = [];
 
143
  // Load assets
144
  const backgroundImg = new Image();
145
  backgroundImg.src = 'city.png';
@@ -147,6 +155,8 @@
147
  playerImg.src = 'player.png';
148
  const enemyImg = new Image();
149
  enemyImg.src = 'enemy.png';
 
 
150
  // Audio setup
151
  const cannonSound = new Audio('firemn.ogg');
152
  const machinegunSound = new Audio('firemg.ogg');
@@ -330,6 +340,14 @@ function buyTank(tankImg, cost, tankId) {
330
 
331
  player.health = player.maxHealth;
332
  }
 
 
 
 
 
 
 
 
333
  }
334
  function initRound() {
335
  enemies = [];
@@ -367,30 +385,30 @@ function buyTank(tankImg, cost, tankId) {
367
  });
368
 
369
  document.addEventListener('keyup', e => keys[e.key] = false);
370
- function fireBullet() {
371
  if(isCountingDown) return;
372
  const weapon = weapons[currentWeapon];
373
  const now = Date.now();
374
  if ((keys[' '] || autoFire) && now - lastShot > weapon.fireRate) {
375
  weapon.sound.cloneNode().play();
376
- // 발사 이펙트 추가
377
- effects.push(new Effect(
378
- player.x + Math.cos(player.angle) * 30,
379
- player.y + Math.sin(player.angle) * 30,
380
- 500,
381
- 'fire',
382
- player.angle,
383
- player // player를 부모로 전달
384
- ));
385
-
386
  bullets.push({
387
  x: player.x + Math.cos(player.angle) * 30,
388
  y: player.y + Math.sin(player.angle) * 30,
389
  angle: player.angle,
390
- speed: 10,
391
  isEnemy: false,
392
  damage: weapon.damage,
393
- size: weapon.bulletSize
 
394
  });
395
  lastShot = now;
396
  }
@@ -513,14 +531,22 @@ function buyTank(tankImg, cost, tankId) {
513
  drawHealthBar(enemy.x, enemy.y - 40, enemy.health, enemy.maxHealth, 60, 5, 'red');
514
  });
515
 
516
- // 총알 그리기
517
- bullets.forEach(bullet => {
518
- ctx.beginPath();
519
- ctx.fillStyle = bullet.isEnemy ? 'red' : 'blue';
520
- ctx.arc(bullet.x, bullet.y, bullet.size, 0, Math.PI * 2);
521
- ctx.fill();
522
- });
523
-
 
 
 
 
 
 
 
 
524
  // 아이템 그리기
525
  items.forEach(item => {
526
  ctx.beginPath();
@@ -575,12 +601,14 @@ restartBtn.addEventListener('click', () => {
575
  gameOver = false;
576
  isBossStage = false;
577
  gold = 0;
 
578
  restartBtn.style.display = 'none';
579
  document.getElementById('winMessage').style.display = 'none';
580
  document.getElementById('tank1').style.display = 'block';
581
  document.getElementById('tank2').style.display = 'block';
 
582
  playerImg.src = 'player.png';
583
- bgm.src = 'BGM2.ogg'; // 기본 BGM으로 복귀
584
  bgm.play();
585
  initRound();
586
  });
 
110
  <p style="color: #ff6b6b;">-30% Speed</p>
111
  <button onclick="buyTank('player3.png', 500, 'tank2')">Buy</button>
112
  </div>
113
+ <div id="apcr" style="text-align:center;">
114
+ <h3>APCR</h3>
115
+ <img src="apcr.png" width="50" height="50">
116
+ <p>1000 Gold</p>
117
+ <p style="color: #4CAF50;">+50% Bullet Speed</p>
118
+ <button onclick="buyAPCR()">Buy</button>
119
+ </div>
120
  </div>
121
  </div>
122
  <button id="bossButton" class="button">Fight Boss!</button>
 
147
  let gold = 0;
148
  let isBossStage = false;
149
  let effects = [];
150
+ let hasAPCR = false; // APCR 구매 여부
151
  // Load assets
152
  const backgroundImg = new Image();
153
  backgroundImg.src = 'city.png';
 
155
  playerImg.src = 'player.png';
156
  const enemyImg = new Image();
157
  enemyImg.src = 'enemy.png';
158
+ const bulletImg = new Image(); // APCR 총알 이미지
159
+ bulletImg.src = 'apcr2.png';
160
  // Audio setup
161
  const cannonSound = new Audio('firemn.ogg');
162
  const machinegunSound = new Audio('firemg.ogg');
 
340
 
341
  player.health = player.maxHealth;
342
  }
343
+ }
344
+ function buyAPCR() {
345
+ if (gold >= 1000 && !hasAPCR) {
346
+ gold -= 1000;
347
+ hasAPCR = true;
348
+ document.getElementById('apcr').style.display = 'none';
349
+ document.getElementById('shop').style.display = 'none';
350
+ }
351
  }
352
  function initRound() {
353
  enemies = [];
 
385
  });
386
 
387
  document.addEventListener('keyup', e => keys[e.key] = false);
388
+ function fireBullet() {
389
  if(isCountingDown) return;
390
  const weapon = weapons[currentWeapon];
391
  const now = Date.now();
392
  if ((keys[' '] || autoFire) && now - lastShot > weapon.fireRate) {
393
  weapon.sound.cloneNode().play();
394
+ effects.push(new Effect(
395
+ player.x + Math.cos(player.angle) * 30,
396
+ player.y + Math.sin(player.angle) * 30,
397
+ 500,
398
+ 'fire',
399
+ player.angle,
400
+ player
401
+ ));
402
+
 
403
  bullets.push({
404
  x: player.x + Math.cos(player.angle) * 30,
405
  y: player.y + Math.sin(player.angle) * 30,
406
  angle: player.angle,
407
+ speed: hasAPCR ? 15 : 10, // APCR 적용 시 50% 증가
408
  isEnemy: false,
409
  damage: weapon.damage,
410
+ size: weapon.bulletSize,
411
+ isAPCR: hasAPCR
412
  });
413
  lastShot = now;
414
  }
 
531
  drawHealthBar(enemy.x, enemy.y - 40, enemy.health, enemy.maxHealth, 60, 5, 'red');
532
  });
533
 
534
+ // 총알 그리기
535
+ bullets.forEach(bullet => {
536
+ if (bullet.isEnemy || !bullet.isAPCR) {
537
+ ctx.beginPath();
538
+ ctx.fillStyle = bullet.isEnemy ? 'red' : 'blue';
539
+ ctx.arc(bullet.x, bullet.y, bullet.size, 0, Math.PI * 2);
540
+ ctx.fill();
541
+ } else {
542
+ ctx.save();
543
+ ctx.translate(bullet.x, bullet.y);
544
+ ctx.rotate(bullet.angle);
545
+ const size = currentWeapon === 'machinegun' ? 25 : 50; // 기관총일 때 크기 절반
546
+ ctx.drawImage(bulletImg, -size/2, -size/2, size, size);
547
+ ctx.restore();
548
+ }
549
+ });
550
  // 아이템 그리기
551
  items.forEach(item => {
552
  ctx.beginPath();
 
601
  gameOver = false;
602
  isBossStage = false;
603
  gold = 0;
604
+ hasAPCR = false; // APCR 초기화
605
  restartBtn.style.display = 'none';
606
  document.getElementById('winMessage').style.display = 'none';
607
  document.getElementById('tank1').style.display = 'block';
608
  document.getElementById('tank2').style.display = 'block';
609
+ document.getElementById('apcr').style.display = 'block'; // APCR 상점 아이템 다�� 표시
610
  playerImg.src = 'player.png';
611
+ bgm.src = 'BGM2.ogg';
612
  bgm.play();
613
  initRound();
614
  });