We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › Need advice on randomly drawing lines.
Page Index Toggle Pages: 1
Need advice on randomly drawing lines. (Read 506 times)
Need advice on randomly drawing lines.
Sep 18th, 2008, 4:08pm
 
This is some of the first programming work I have done, the following is not pretty.

I have two places where I would like a line to randomly appear, A and B. So to have the line either draw at A, A and B, B, or neither.

So far to try to have this happen I have tried using a random(3); and turning that into an integer. Then using the values of that integer (0, 1, 2, or 3) to choose between the four different possibilities (A, A and B, B, or neither).

This is where I run into problems. I'm not looking for a free ride, just a kick in the right direction. I have a feeling I'm not even going about it the proper way in the first place (like maybe I would be better off just drawing them all and using a random alpha value to make some not appear).

Thanks in advance!
Re: Need advice on randomly drawing lines.
Reply #1 - Sep 18th, 2008, 5:30pm
 
use switch?
http://processing.org/reference/switch_.html
Re: Need advice on randomly drawing lines.
Reply #2 - Sep 20th, 2008, 2:38am
 
glenn wrote on Sep 18th, 2008, 5:30pm:
use switch
http://processing.org/reference/switch_.html


Ahh, thankyou very much.
Page Index Toggle Pages: 1