int $i; int $j; // holds random value assigned each time a cube is created float $randSize; for ($i=0; $i<5; $i++) { for ($j=0; $j<5; $j++) { // generate a random float number between 0.0 and 2.0 $randSize = rand(2); // use the random number to set the cube dimensions polyCube -w $randSize -h $randSize -d $randSize; move -r (2*$j)0(2*$i); } }
// function that creates a 5x5 grid of randomly sized cubes proc generateVariedCubes() { int $i; int $j; // holds random value assigned each time a cube is created float $randSize; for ($i=0;$i<5;$i++){ for ($j=0;$j<5;$j++){ // generate a random float number between 0.0 and 2.0 $randSize = rand(2); // use the random number to set the cube dimensions polyCube -w $randSize -h $randSize -d $randSize; move -r (2*$j)0(2*$i); } } } // call the function generateVariedCubes();