package  
{
	import flash.display.BitmapData;
	import flash.geom.Point;
	import net.flashpunk.Entity;
	import net.flashpunk.graphics.Image;
	import net.flashpunk.utils.Input;
	import net.flashpunk.utils.Key;
	import net.flashpunk.FP;
	import net.flashpunk.Sfx;
	import net.flashpunk.graphics.Spritemap
	
	public class HealthP1 extends Entity
	{
		/*healthP1 graphic*/
		[Embed(source = '../assets/gfx/healthspritesforleft.png')]
		private const HEALTHL:Class;
			
		public var healthSprite:Spritemap = new Spritemap(HEALTHL, 172, 20);
		
		public function HealthP1() 
		{
			x = 24;
			y = FP.screen.height - 24;
			
			healthSprite.add("12", [0], 20, false);
			healthSprite.add("11", [1], 20, false);
			healthSprite.add("10", [2], 20, false);
			healthSprite.add("9", [3], 20, false);
			healthSprite.add("8", [4], 20, false);
			healthSprite.add("7", [5], 20, false);
			healthSprite.add("6", [6], 20, false);
			healthSprite.add("5", [7], 20, false);
			healthSprite.add("4", [8], 20, false);
			healthSprite.add("3", [9], 20, false);
			healthSprite.add("2", [10], 20, false);
			healthSprite.add("1", [11], 20, false);
			healthSprite.add("0", [12], 20, false);
			
			graphic = healthSprite;
		}
		
		override public function update():void 
		{
			if (GameWorld.hit1)
			{
				GameWorld.hit1 = false;
				//if fish or robot remove projectile from count
				if (GameWorld.player2Type == "F")
				{
					GameWorld.haloNum--;
				}
				else
				{
					if (GameWorld.player2Type == "R")
					{
						GameWorld.laserNum--;
					}
				}
				//attack power
				if (GameWorld.player2Type == "B")
				{
					GameWorld.hitNum1 += 2;
				}
				else
				{
					if (GameWorld.player2Type == "R")
					{
						GameWorld.hitNum1 += 3;
					}
					else
					{
						GameWorld.hitNum1++;
					}
				}
				//determine which health sprite to display	
				switch(GameWorld.hitNum1)
				{
				case(1):
					healthSprite.play("11", true);
					break;
				case(2):
					healthSprite.play("10", true);
					break;
				case(3):
					healthSprite.play("9", true);
					break;
				case(4):
					healthSprite.play("8", true);
					break;
				case(5):
					healthSprite.play("7", true);
					break;
				case(6):
					healthSprite.play("6", true);
					break;
				case(7):
					healthSprite.play("5", true);
					break;
				case(8):
					healthSprite.play("4", true);
					break;
				case(9):
					healthSprite.play("3", true);
					break;
				case(10):
					healthSprite.play("2", true);
					break;
				case(11):
					healthSprite.play("1", true);
					break;
				case(12):
					healthSprite.play("0", true);
					break;
				}
				
			}
			super.update();
		}
	}

}