cutechicken commited on
Commit
9de7d6b
·
verified ·
1 Parent(s): 0c403ea

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +11 -1
index.html CHANGED
@@ -68,6 +68,7 @@
68
  Mouse - Aim<br>
69
  Space - Fire<br>
70
  C - Switch Weapon
 
71
  </div>
72
  <div id="weaponInfo">Current Weapon: Cannon</div>
73
  <div id="countdown">3</div>
@@ -94,6 +95,7 @@
94
  let lastShot = 0;
95
  let isCountingDown = true;
96
  let countdownTime = 3;
 
97
 
98
  // Load assets
99
  const backgroundImg = new Image();
@@ -219,12 +221,20 @@
219
  });
220
  const keys = {};
221
  document.addEventListener('keydown', e => keys[e.key] = true);
 
 
 
 
 
 
 
 
222
  document.addEventListener('keyup', e => keys[e.key] = false);
223
  function fireBullet() {
224
  if(isCountingDown) return;
225
  const weapon = weapons[currentWeapon];
226
  const now = Date.now();
227
- if (keys[' '] && now - lastShot > weapon.fireRate) {
228
  weapon.sound.cloneNode().play();
229
  bullets.push({
230
  x: player.x + Math.cos(player.angle) * 30,
 
68
  Mouse - Aim<br>
69
  Space - Fire<br>
70
  C - Switch Weapon
71
+ R - Toggle Auto-fire
72
  </div>
73
  <div id="weaponInfo">Current Weapon: Cannon</div>
74
  <div id="countdown">3</div>
 
95
  let lastShot = 0;
96
  let isCountingDown = true;
97
  let countdownTime = 3;
98
+ let autoFire = false;
99
 
100
  // Load assets
101
  const backgroundImg = new Image();
 
221
  });
222
  const keys = {};
223
  document.addEventListener('keydown', e => keys[e.key] = true);
224
+ document.addEventListener('keydown', (e) => {
225
+ if(e.key.toLowerCase() === 'c') {
226
+ currentWeapon = currentWeapon === 'cannon' ? 'machinegun' : 'cannon';
227
+ weaponInfo.textContent = `Current Weapon: ${currentWeapon.charAt(0).toUpperCase() + currentWeapon.slice(1)}`;
228
+ } else if(e.key.toLowerCase() === 'r') {
229
+ autoFire = !autoFire;
230
+ }
231
+ });
232
  document.addEventListener('keyup', e => keys[e.key] = false);
233
  function fireBullet() {
234
  if(isCountingDown) return;
235
  const weapon = weapons[currentWeapon];
236
  const now = Date.now();
237
+ if ((keys[' '] || autoFire) && now - lastShot > weapon.fireRate) {
238
  weapon.sound.cloneNode().play();
239
  bullets.push({
240
  x: player.x + Math.cos(player.angle) * 30,