Fire bullets

click with the mouse to fire some bullets in random directions

HTML

<canvas id = "gameCanvas" width = 400 height = 400 />

JavaScript

// this object will hold our Game classes and methods
var Game = {};

(function(){
    // Bullet class
	function Bullet(x, y, speed, angle,  width, height, colors){
		this.x = x;
		this.y = y;
		this.speed = speed;
		this.angle = angle;
		this.width = width;
		this.height = height;
		this.colors = colors;		
		this.frameCounter = 0;
	}
	
	Bullet.prototype.update = function(){        
        // (!) here we calculate the vector (vx, vy) that represents the velocity
		var vx = this.speed * Math.cos(this.angle-(Math.PI/2));
		var vy = this.speed * Math.sin(this.angle-(Math.PI/2));
		
        // move the bullet 
		this.x += vx;
		this.y += vy;		
	}
	
	Bullet.prototype.draw = function(context, xScroll,  yScroll){		
		context.save();	
        
		if(this.angle != 0)	{
            // translate to the orign of system
			context.translate(this.x-xScroll, this.y-yScroll); 	
            // rotate
			context.rotate(this.angle);	
            // translate back to actual position
			context.translate(xScroll-this.x, yScroll-this.y); 
		}
        // animate the bullets (changing colors)
		context.fillStyle = this.colors[this.frameCounter % this.colors.length];	
        this.frameCounter++;
        
        // draw the bullet
		context.fillRect((this.x-this.width/2) - xScroll, (this.y-this.height/2) - yScroll, this.width, this.height);
        
		context.restore();			
	}
	
	Game.Bullet = Bullet; // add this class to the Game object
})();

(function(){
    // Boss class
	Boss = function(x, y, width, height){
		this.x = x;
		this.y = y;
		this.width = width;
		this.height = height;

		this.mov = 0;		
		this.bullets = [];
		this.bulletsColors = ["red", "orange", "white"];
	}
	
	Boss.prototype.update = function(){
		// move our boss
		this.mov += 0.01;		
		this.x += Math.sin(this.mov) * 1.6;
		
		// update boss bullets
		for(var i=0; i<this.bullets.length; i++){
			this.bullets[i].update();
		}
	}
	
	Boss.prototype.draw = function(context, xScroll, yScroll){		
        
        // draw...