package  
{
	import flash.display.Sprite;
	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 Fireball extends Projectile
	{
		[Embed(source = 'gfx/fireball.png')]
		private const FIREBALL:Class;
		
		public var ball:Spritemap;
		//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 var csin:Number=0;
		
		public function Fireball(accuracy:Number = 0,velocity:Number = 20)
		{
			vy = (1-2*Math.random())*accuracy;
			vx = velocity;
			if (Bazaar.player.pedd.flipped) vx *= -1;
			ball = new Spritemap(FIREBALL, 16, 16);
			graphic = ball;
			ball.add("burn", [0, 1], 20, true);
			ball.flipped += Bazaar.player.pedd.flipped;
			ball.play("burn");
			setHitbox(16, 16, 0, 0);
			type = "bullet";
			damage = 20;
		}
		
		override public function update():void
		{
			csin += vx * vx + vy * vy;
			ball.scale = (Math.sin(csin) * .5) + 1;
			ball.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();
		}
		
	}
}