title: How can i create a constant stream of bullets?
body: <p>I have recently started learning javascript with Codecademy. To extend my knowledge and just for fun, I followed HTML5 game tutorials by Gyrostorm: <a href="http://www.youtube.com/playlist?list=PL290A4D2398C97186/" rel="nofollow">http://www.youtube.com/playlist?list=PL290A4D2398C97186/</a>.</p>
  
  <p>Now I completed the tutorial to make my version of his game, but I want it to be so that when you hold the spacebar, bullets fire at a certain rate. Currently, you have to keep pressing the spacebar to fire. I have a Jet.shoot function and a Jet.checkShoot function but after trying many times to setIntervals and setTimeouts nothing would work! Please help!</p>
  
  <pre><code>Jet.prototype.checkShooting = function() {
      if(this.isSpacebar &amp;&amp; !this.isShooting) {
          this.isShooting = true;
          this.bullets[this.currentBullet].fire(this.noseX, this.noseY)
          this.currentBullet++;
          if(this.currentBullet &gt;= this.bullets.length) {
              this.currentBullet = 0;
          }
      } else if(!this.isSpacebar) {
          this.isShooting = false;
      }
  };
  
  Jet.prototype.shoot = function() {
      this.isShooting = true;
      this.bullets[this.currentBullet].fire(this.noseX, this.noseY);
      this.currentBullet++;
      if(this.currentBullet &gt;= this.bullets.length) {
          this.currentBullet = 0;
      }
  }
  </code></pre>
  
  <p>Here is a live version of what I have so far: <a href="https://googledrive.com/host/0B2Xb6VzofFX-OGxEcnV3OUNTdFU/index.html" rel="nofollow">https://googledrive.com/host/0B2Xb6VzofFX-OGxEcnV3OUNTdFU/index.html</a></p>
  
  <p>Thanks!</p>