package  
{
	import net.flashpunk.Entity;
	import net.flashpunk.graphics.Spritemap;
	import net.flashpunk.graphics.Image;
	import net.flashpunk.utils.Input;
	import net.flashpunk.utils.Key;
	import net.flashpunk.FP;
	
	public class Bullet extends Projectile
	{
		[Embed(source = 'gfx/bullet.png')]
		private const BULLET:Class;
		
		//public var damage:Number = 0;
		public var range:Number = 0;
		public var blast_radius:Number = 0;
		public var wallbreak:uint = 0;
		public var vx:Number;
		public var vy:Number;
		
		public function Bullet(accuracy:Number = 0,velocity:Number = 20)
		{
			vy = (1-2*Math.random())*accuracy;
			vx = velocity;
			if (Bazaar.player.pedd.flipped) vx *= -1;
			graphic = new Image(BULLET);
			(graphic as Image).flipped+=Bazaar.player.pedd.flipped;
			setHitbox(8, 8, 0, 0);
			type = "bullet";
			
		}
		
		override public function update():void
		{
			//(graphic as Image).angle+=vx+vy;
			//vy += Bazaar.player.vfall;
			y += vy;
			x += vx;
			if (collide("level", x, y) ||
				x < 0 || y < 0 || 
				x > Bazaar.level.tilemap.sw || y > Bazaar.level.tilemap.sh) FP.world.remove(this);
				
			kill();
			
		}
		
	}
}