package  
{
	
	import net.flashpunk.graphics.Image;
	import net.flashpunk.FP;
	
	/**
	 * ...
	 * @author Benn
	 */
	public class BlueWorldEnemyOne extends BaseEnemy 
	{
		
		private var wavey:Number = 10;
		private var direction:Boolean = true;
		private var movetype:int = 0;
		
		public function BlueWorldEnemyOne(posx:int, posy:int) 
		{
			
			EnemyImage = Image.createRect(20, 20, 0xFFFFFF);
			
			EnemyImage.color = FP.getColorRGB(150, 0, 0);
			
			EnemyImage.centerOrigin();
			
			graphic = EnemyImage;
			
			setHitboxTo(EnemyImage);
			
			type = "enemy";
			
			x = posx;
			y = posy;
			
			moveSpeed = 50;
		
			if (x < 0)
			{
				movetype = 0;
			}
			else
			{
				movetype = 1;
			}
			
		}
		
		override public function update():void 
		{
			
			if (SpawnDelay > 0)
			{
				SpawnDelay -= FP.elapsed;
			}
			else
			{
		
				y += (wavey * 20) * FP.elapsed;
				
				if (direction == true)
				{
					wavey -= 10 * FP.elapsed;
				}
				else
				{
					wavey += 10 * FP.elapsed;
				}
				
				if (wavey < -10)
				{
					wavey = -10;
					direction = false;
				}
				else if (wavey > 10)
				{
					wavey = 10
					direction = true;
				}
				
				if (movetype == 0)
				{
				
					x += moveSpeed * FP.elapsed;
					
					if (x > 660)
					{
						FP.world.remove(this);
					}
				
				}
				else if (movetype == 1)
				{
					
					x -= moveSpeed * FP.elapsed;
					
					if (x < -100)
					{
						FP.world.remove(this);
					}
					
				}
				
				EnemyImage.angle += 30 * FP.elapsed;
				
			}
			
			super.update();
		}
		
	}

}