package  
{
	import net.flashpunk.Entity;
	import net.flashpunk.graphics.Image;
	import net.flashpunk.FP;
	
	/**
	 * ...
	 * @author Benn
	 */
	public class Block extends Entity 
	{
		
		[Embed(source = '../assets/graphics/block.png')] private static const BLOCK_GRAPHIC:Class;
		
		private var BlockImage:Image = new Image(BLOCK_GRAPHIC);
		
		private var BlockMoveSpeed:Number = 128;
		
		private var MoveDirection:Boolean = true;
		
		public function Block() 
		{
			graphic = BlockImage;
			setHitboxTo(BlockImage);
			type = "block";
		}
		
		override public function update():void 
		{
			
			if (MoveDirection == true)
			{
				y += BlockMoveSpeed * FP.elapsed;
				
				if (collide("level", x, y))
				{
					y -= BlockMoveSpeed * FP.elapsed;
					MoveDirection = false;
				}
			}
			else
			{
				y -= BlockMoveSpeed * FP.elapsed;
				
				if (collide("level", x, y))
				{
					y += BlockMoveSpeed * FP.elapsed;
					MoveDirection = true;
				}
			}
			
			super.update();
		}
		
	}

}