Treating each circle separate

    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

Sign In or Register to comment.