package util
{
	import org.flixel.*;

	public class Fx extends FlxGroup
	{
		private var pixels:FlxGroup;
		private var pixels2:FlxGroup;
		public function Fx() 
		{
			super();
			
			pixels = new FlxGroup();
			pixels2 = new FlxGroup();
			//	Here we create an FlxGroup containing 40 FlxEmitters, all the same, used when the aliens are shot/explode
			for (var i:int = 0; i < 1; i++)
			{
				var tempPixel:FlxEmitter = new FlxEmitter(0,0,4);
				tempPixel.setSize(4, 4);
				tempPixel.gravity = 200;
				tempPixel.setXSpeed(-50, 50);
				tempPixel.setYSpeed( -30, -60);
				tempPixel.setRotation(0, 0);	// VITAL!!!
				tempPixel.makeParticles(Pixel, 10, 0, true, 0);
				pixels.add(tempPixel);
			}
			
			add(pixels);
			
			for (var y:int = 0; y < 10; y++)
			{
				var tempPixel2:FlxEmitter = new FlxEmitter(0,0,100);
				tempPixel2.setSize(16, 16);
				tempPixel2.gravity = 100;
				tempPixel2.setXSpeed(-50, 50);
				tempPixel2.setYSpeed( -30, -60);
				tempPixel2.setRotation(0, 0);	// VITAL!!!
				tempPixel2.makeParticles(Pixel, 10, 0, true, 0);
				pixels2.add(tempPixel2);
			}
			
			add(pixels2);

		}
		
		public function explodeBlock(ax:int, ay:int):void
		{
			var pixel:FlxEmitter = FlxEmitter(pixels.getRandom());
			
			if (pixel)
			{
				pixel.x = ax+8;
				pixel.y = ay+8;
				pixel.start(true,1,0.3,10);
			}
		}
		
		public function explodeBlockKill(ax:int, ay:int):void
		{
			var pixel2:FlxEmitter = FlxEmitter(pixels2.getRandom());
			
			if (pixel2)
			{
				pixel2.x = ax+8;
				pixel2.y = ay+8;
				pixel2.start(true,1,0.3,30);
			}

		}
		
	}


}