title: How to create a bullet animation? (Shooter Game)
body: <p>I am trying to make a shooter game, but I have got some troubles with bullet animation. Each time I click, a new bullet object created and animation starts, but after each click the created bullet disappears and same bullet starts over again which is faster than previous bullet. So I am trying to create new bullet after each click. A basic shooter game logic. Here is my code: </p>
  
  <pre><code>    function newBullet(x,y,angle,speed,id,type) {
      this.x = x;
      this.y = y;
      this.speed = speed;
      this.angle = angle;
      this.radians = this.angle * Math.PI / 180;
      this.id = id;
      this.type = type;
      this.drawBullet = drawBullet;
      this.moveBullet = moveBullet;
      }
  
      function moveBullet() {
      this.x = this.x + Math.cos(this.radians) * this.speed ;
      this.y = this.y + Math.sin(this.radians) * this.speed;
      ctx.drawImage( bulletImg, this.x, this.y);
      }
  
      function drawBullet() {
          bullet = new newBullet(playerX,playerY,getAngle(),2,1,1);
          bullets[bullets.length] = bullet;
          setInterval("bullets[bullets.length - 1].moveBullet()", 25);
      }
  
  canvas.addEventListener("mousedown",drawBullet,false);  
  </code></pre>