We are about to switch to a new forum software. Until then we have removed the registration on this forum.
float dotx , dotx2 , dotx3;
float doty;
float dspeed, dspeed2, dspeed3;
void setup(){
size(600,600);
background(255);
frameRate(40);
dotx = 0;
dotx2 = 0;
dotx3 = 0;
dspeed = random(6, 10);
dspeed2 = random(7, 11);
dspeed3 = random(6, 10);
doty = height/2;
}
void draw(){
background(255);
fill(#FF56AA);
ellipse(dotx,doty+125, 50,50);
ellipse(dotx,doty, 50,50);
ellipse(dotx,doty-140, 50,50);
if (dotx >= width || dotx < 0){
dspeed = -dspeed;
}
if (dotx2 >= width || dotx <0){
dspeed2 = -dspeed2;
}
if (dotx3 >= width || dotx <0){
dspeed3 = -dspeed3;
}
dotx = dotx + dspeed;
}
How can I make these circles move as individual functions? I tried using different variables for each circle, and still no good!
Answers
You're using the same dotx and doty in all three of the ellipse() calls, rather than dotx2 and dotx3.
Ok I changed it, but now my first line of ellipse is working and the bottom two are not!
There are more places where you're using just dotx. Lines 25 and 28. Also, at the end you only update dotx. You need a couple more lines like line 31 for the other variables.
If you want to do very many more circles you'd benefit from looking at http://forum.processing.org/two/discussion/8082/from-several-variables-to-arrays