cutechicken commited on
Commit
7218ae1
·
verified ·
1 Parent(s): 29b0de1

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +12 -12
index.html CHANGED
@@ -56,7 +56,7 @@
56
  WASD - Move tank<br>
57
  Mouse - Aim<br>
58
  Space - Fire<br>
59
- R - Switch Weapon
60
  </div>
61
  <div id="weaponInfo">Current Weapon: Cannon</div>
62
  <button id="nextRound" class="button">Next Round</button>
@@ -100,7 +100,7 @@
100
  const weapons = {
101
  cannon: {
102
  fireRate: 1000,
103
- damage: 0.50,
104
  bulletSize: 5,
105
  sound: cannonSound
106
  },
@@ -118,8 +118,8 @@
118
  y: canvas.height/2,
119
  speed: 5,
120
  angle: 0,
121
- width: 132,
122
- height: 72,
123
  health: 1000,
124
  maxHealth: 1000
125
  };
@@ -132,11 +132,11 @@
132
  this.maxHealth = 1000;
133
  this.speed = 2;
134
  this.lastShot = 0;
135
- this.shootInterval = 2000;
136
  this.angle = 0;
137
  this.moveAngle = Math.random() * Math.PI * 2;
138
- this.width = 132;
139
- this.height = 72;
140
  }
141
 
142
  update() {
@@ -189,7 +189,7 @@
189
  }
190
 
191
  document.addEventListener('keydown', (e) => {
192
- if(e.key.toLowerCase() === 'r') {
193
  currentWeapon = currentWeapon === 'cannon' ? 'machinegun' : 'cannon';
194
  weaponInfo.textContent = `Current Weapon: ${currentWeapon.charAt(0).toUpperCase() + currentWeapon.slice(1)}`;
195
  }
@@ -243,7 +243,7 @@
243
  if(!bullet.isEnemy) {
244
  enemies = enemies.filter(enemy => {
245
  const dist = Math.hypot(bullet.x - enemy.x, bullet.y - enemy.y);
246
- if(dist < 40) {
247
  enemy.health -= enemy.maxHealth * bullet.damage;
248
  if(enemy.health <= 0) {
249
  spawnHealthItem(enemy.x, enemy.y);
@@ -255,7 +255,7 @@
255
  });
256
  } else {
257
  const dist = Math.hypot(bullet.x - player.x, bullet.y - player.y);
258
- if(dist < 40) {
259
  player.health -= 100;
260
  if(player.health <= 0) {
261
  gameOver = true;
@@ -271,7 +271,7 @@
271
 
272
  items = items.filter(item => {
273
  const dist = Math.hypot(item.x - player.x, item.y - player.y);
274
- if(dist < 40) {
275
  player.health = Math.min(player.health + 200, player.maxHealth);
276
  return false;
277
  }
@@ -316,7 +316,7 @@
316
  ctx.rotate(enemy.angle);
317
  ctx.drawImage(enemyImg, -enemy.width/2, -enemy.height/2, enemy.width, enemy.height);
318
  ctx.restore();
319
- drawHealthBar(enemy.x, enemy.y - 50, enemy.health, enemy.maxHealth, 60, 5, 'red');
320
  });
321
 
322
  bullets.forEach(bullet => {
 
56
  WASD - Move tank<br>
57
  Mouse - Aim<br>
58
  Space - Fire<br>
59
+ C - Switch Weapon
60
  </div>
61
  <div id="weaponInfo">Current Weapon: Cannon</div>
62
  <button id="nextRound" class="button">Next Round</button>
 
100
  const weapons = {
101
  cannon: {
102
  fireRate: 1000,
103
+ damage: 0.25,
104
  bulletSize: 5,
105
  sound: cannonSound
106
  },
 
118
  y: canvas.height/2,
119
  speed: 5,
120
  angle: 0,
121
+ width: 100,
122
+ height: 45,
123
  health: 1000,
124
  maxHealth: 1000
125
  };
 
132
  this.maxHealth = 1000;
133
  this.speed = 2;
134
  this.lastShot = 0;
135
+ this.shootInterval = 333; // 1초에 3발
136
  this.angle = 0;
137
  this.moveAngle = Math.random() * Math.PI * 2;
138
+ this.width = 100;
139
+ this.height = 45;
140
  }
141
 
142
  update() {
 
189
  }
190
 
191
  document.addEventListener('keydown', (e) => {
192
+ if(e.key.toLowerCase() === 'c') {
193
  currentWeapon = currentWeapon === 'cannon' ? 'machinegun' : 'cannon';
194
  weaponInfo.textContent = `Current Weapon: ${currentWeapon.charAt(0).toUpperCase() + currentWeapon.slice(1)}`;
195
  }
 
243
  if(!bullet.isEnemy) {
244
  enemies = enemies.filter(enemy => {
245
  const dist = Math.hypot(bullet.x - enemy.x, bullet.y - enemy.y);
246
+ if(dist < 30) {
247
  enemy.health -= enemy.maxHealth * bullet.damage;
248
  if(enemy.health <= 0) {
249
  spawnHealthItem(enemy.x, enemy.y);
 
255
  });
256
  } else {
257
  const dist = Math.hypot(bullet.x - player.x, bullet.y - player.y);
258
+ if(dist < 30) {
259
  player.health -= 100;
260
  if(player.health <= 0) {
261
  gameOver = true;
 
271
 
272
  items = items.filter(item => {
273
  const dist = Math.hypot(item.x - player.x, item.y - player.y);
274
+ if(dist < 30) {
275
  player.health = Math.min(player.health + 200, player.maxHealth);
276
  return false;
277
  }
 
316
  ctx.rotate(enemy.angle);
317
  ctx.drawImage(enemyImg, -enemy.width/2, -enemy.height/2, enemy.width, enemy.height);
318
  ctx.restore();
319
+ drawHealthBar(enemy.x, enemy.y - 40, enemy.health, enemy.maxHealth, 60, 5, 'red');
320
  });
321
 
322
  bullets.forEach(bullet => {