Spaces:
Running
Running
Update index.html
Browse files- index.html +14 -19
index.html
CHANGED
|
@@ -320,25 +320,20 @@ if (enemiesRemaining <= 0 && enemies.length === 0) {
|
|
| 320 |
if (player.x < canvas.width - player.width) player.x += player.speed;
|
| 321 |
break;
|
| 322 |
case ' ':
|
| 323 |
-
|
| 324 |
-
|
| 325 |
-
|
| 326 |
-
|
| 327 |
-
|
| 328 |
-
|
| 329 |
-
|
| 330 |
-
|
| 331 |
-
|
| 332 |
-
|
| 333 |
-
|
| 334 |
-
|
| 335 |
-
|
| 336 |
-
|
| 337 |
-
player.bullets--;
|
| 338 |
-
bulletCount.textContent = player.bullets;
|
| 339 |
-
playerShootSound.play();
|
| 340 |
-
}
|
| 341 |
-
break;
|
| 342 |
}
|
| 343 |
}
|
| 344 |
});
|
|
|
|
| 320 |
if (player.x < canvas.width - player.width) player.x += player.speed;
|
| 321 |
break;
|
| 322 |
case ' ':
|
| 323 |
+
if (player.bullets > 0) {
|
| 324 |
+
player.image.src = player.direction === 1 ? player.imageShootRight : player.imageShootLeft;
|
| 325 |
+
bullets.push({
|
| 326 |
+
x: player.x + player.width / 2,
|
| 327 |
+
y: player.y + player.height / 2.5,
|
| 328 |
+
width: 10,
|
| 329 |
+
height: 5,
|
| 330 |
+
speed: player.direction * 10
|
| 331 |
+
});
|
| 332 |
+
player.bullets--;
|
| 333 |
+
bulletCount.textContent = player.bullets;
|
| 334 |
+
playerShootSound.play();
|
| 335 |
+
}
|
| 336 |
+
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 337 |
}
|
| 338 |
}
|
| 339 |
});
|