Page 1 of 1
Random choice from 4 values
Posted: June 23rd, 2008, 11:39 am
by vjair
hello
ok, what id like to do is set an expression for rotation, so that the amount is determined from a selection of four - 0,90,180,270
if i can make each random choice occur at an equaly spaced amount of time it would be great, but its not essential.
thanks
Arran.
Re: Random choice from 4 values
Posted: June 23rd, 2008, 12:13 pm
by lloydalvarez
Code: Select all
fps=5; //interval of change in frames per second
choices = [0,90,180,270]; // enter the values to choose from, you can add more values as long as they are separated by comma
posterizeTime(fps);
r=Math.round(random (0,choices.length-1));
choices[r]
-Lloyd
Re: Random choice from 4 values
Posted: June 23rd, 2008, 12:32 pm
by vjair
thanks very much for such a quick reply, that did exactly what i wanted
i had a feeling it needed an array ( right term ? ) but couldnt get it to work... at last i know i was looking along the right area though
Arran.
Re: Random choice from 4 values
Posted: June 23rd, 2008, 12:55 pm
by lloydalvarez
This is one of those problems that you can actually solve many different ways, but I think this is an efficient and scalable (ie, you can add more values and the expression won't break) solution.
And yes, that's an array
-Lloyd