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 & HelpPrograms › consecutive programs.
Page Index Toggle Pages: 1
consecutive programs. (Read 320 times)
consecutive programs.
Jun 2nd, 2008, 10:35am
 
Hi,

I have written a series of simple automated drawing programs   similar to the script below which finish drawing at a finite point. I'd like to be able to 'connect' a series of these  programs so that they run one after the other in a loop with a delay of say thirty seconds between each program (I hope this is clear!)

My programming knowledge is minimal and I'm having trouble understanding how to make this work. if someone could give me some advice, I'd be most appreciative.

thanks in advance.

------------------------------------------------------------
float a =0.0;
float b =0.0;
float c =50.0;
float d =50.0;
float e =1000;
float f =0;
float g = -50;
float h = 50;
float i =1000;
float j =1000;
float k =-50;
float l= -50;
float m= 0;
float n= 1000;
float o = 50;
float p = -50;
float s= 255;
float x=10;
float v=0;
float w=10;
float z=5;
float y=10;




float speed = 1;
float direction = 8;
float speed_s=1;
float direction_s=10;
float speed_v=1.0;
float direction_v=10;
float direction_w=20;
float direction_z=10;


void setup(){


 size (1000,1000);
 background(0);


}


void draw(){

 stroke (255);

 strokeWeight(1) ;



 fill(s);




 rect (a,b+z,c,d+w);
 rect (e,f+z,g,h+w);
 rect (i,j-z,k,l-w);
 rect (m,n-z,o,p-w);

 rect (a+z,b,c+w,d);
 rect (e+z,f,g+w,h);
 rect (i-z,j,k-w,l);
 rect (m-z,n,o-w,p);



  rect (a,b,c,d+z);
  rect (e,f,g,h+z);
  rect (i,j,k,l-z);
  rect (m,n,o,p-z);


 a=a+(speed*direction);
 b=b+(speed*direction);
 e=e-(speed*direction);
 f=f+(speed*direction);
 i=i-(speed*direction);
 j=j-(speed*direction);
 m=m+(speed*direction);
 n=n-(speed*direction);
 s=s-(speed_s*direction_s);
 v=v+(speed_v*direction_v);
 w=w+(speed*1*direction_w);
 z=z+(speed*3*direction_z);
 if (w<-0||w>1000){
   direction_w=(direction_w*-1);
 }
 if (z<-0||z>500){
   direction_z=(direction_z*-1);
 }


 if (v<0||v>250){
   direction_v=(direction_v*-1);
 }


 if (s<0||s>250){
   direction_s=(direction_s*-1);
 }

 if (a>500||a<0){
   direction = (direction*-1);
   c=c-x;
   d=d-x;
   g=g+x;
   h=h-x;
   k=k+x;
   l=l+x;
   o=o-x;
   p=p+x;
 }
 if (c<0){
   noLoop();
 
 }
 
}
Re: consecutive programs.
Reply #1 - Jun 3rd, 2008, 2:04pm
 
First advice: you should learn how to make and use an array. It is better than creating a bunch of variables with meaningless names and using them directly.
At least, you should be able to make a function to draw your figures, and pass it the array of parameters. This way you can reuse your code and merge your figure drawing in one place, passing the various parameters you use in your various sketches.
Later, you will learn to use a class to structure your data (distinguish coordinates, parameters, etc.), and so on.
Page Index Toggle Pages: 1