Thursday, 10 November 2011

Asteroid size

Today we added a small piece of code to our array file to make the size and rotation of the blocks random.

cube.scaleX=Math.random()*1.5+.1;
//This sets the x axis size to random anywhere between 1.5 and 0.1 (1 being the size of the original block)
cube.scaleY=Math.random()*1.5+.1;
//This does the same with the y axis size
cube.rotation=Math.random()*360;
//And this sets the rotation value to a random size between 0 and 360

No comments:

Post a Comment