cutechicken
commited on
Update index.html
Browse files- 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 |
-
|
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.
|
104 |
bulletSize: 5,
|
105 |
sound: cannonSound
|
106 |
},
|
@@ -118,8 +118,8 @@
|
|
118 |
y: canvas.height/2,
|
119 |
speed: 5,
|
120 |
angle: 0,
|
121 |
-
width:
|
122 |
-
height:
|
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 =
|
136 |
this.angle = 0;
|
137 |
this.moveAngle = Math.random() * Math.PI * 2;
|
138 |
-
this.width =
|
139 |
-
this.height =
|
140 |
}
|
141 |
|
142 |
update() {
|
@@ -189,7 +189,7 @@
|
|
189 |
}
|
190 |
|
191 |
document.addEventListener('keydown', (e) => {
|
192 |
-
if(e.key.toLowerCase() === '
|
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 <
|
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 <
|
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 <
|
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 -
|
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 => {
|