main.js
//function fires a bullet in the diretcion the player is facing
function fires a bullet in the diretcion the player is facing
function fires a bullet in the diretcion the player is facing
function playerShoot()
{
	var Bullet = 
	{
		image : document.createElement("img"),
		x : Player.x,
		y : Player.y,
		width : 5,
		height : 5,
		velocityX : 0,
		velocityY : 0
	}
	Bullet.image.src = "bullet.png"
	var dirX = 0;
	var dirY = 1;
	var s = Math.sin(Player.rotation);
	var c = Math.cos(Player.rotation);
	var xVel = (dirX * c) - (dirY * s);
	var yVel = (dirX * s) + (dirY * c);
	Bullet.velocityX = xVel * BULLET_SPEED;
	Bullet.velocityY = yVel * BULLET_SPEED;
	Bullet.x = Player.x;
	Bullet.y = Player.y; 
	Bullets.push(Bullet);
}
function playerShoot ( ) { var Bullet = { image : document . createElement ( "img" ) , x : Player . x , y : Player . y , width : 5 , height : 5 , velocityX : 0 , velocityY : 0 } Bullet . image . src = "bullet.png" var dirX = 0 ; var dirY = 1 ; var s = Math . sin ( Player . rotation ) ; var c = Math . cos ( Player . rotation ) ; var xVel = ( dirX * c ) - ( dirY * s ) ; var yVel = ( dirX * s ) + ( dirY * c ) ; Bullet . velocityX = xVel * BULLET_SPEED ; Bullet . velocityY = yVel * BULLET_SPEED ; Bullet . x = Player . x ; Bullet . y = Player . y ; Bullets . push ( Bullet ) ; }
function fires a bullet in the diretcion the player is facing
function fires a bullet in the diretcion the player is facing
//start off with a direction straight up //rotates said direction by player rotation //gives the bullet calculated velocity times it's speed //starts the bullet at the player coordinates