/*******************************************************
ballBounceRand.mel 
Creates a line of bouncing balls.

USAGE: ballBounceRand <int numberOfBalls>
********************************************************/
global proc ballBounceRand(int $num)
{
	string $allBalls[];

	for ($x=0;$x<$num;$x++)
	{
		float $freq = rand(3,5); // random frequency
		float $height = rand(5,20); // random height
		string $ball[] = `polySphere -r 1 -sx 20 -sy 20 -ax 0 1 0 -cuv 2 -ch 1`;
		xform -t ($x*3) 0 0 $ball[0]; // use counter to spread the ball out on the X axis 
		expression -s ($ball[0]+".translateY = abs(sin(time*"+$freq+")*"+$height+");\n"
					  +$ball[0]+".translateZ = time*4;")  -o $ball[0] -ae 1 -uc all ;
		$allBalls[$x] = $ball[0];	
	}

	select -r $allBalls;
	group;
}