# Processing Project: falling circles

**URL:** <https://discourse.processing.org/t/processing-project-falling-circles/17712>\
**Category:** Coding Questions\
**Created:** [February 11, 2020, 2:22am UTC](https://discourse.processing.org/t/processing-project-falling-circles/17712 "2020-02-11T02:22:27Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![kandrews](https://avatars.discourse-cdn.com/v4/letter/k/8dc957/32.png) [@kandrews](https://discourse.processing.org/u/kandrews)\
**Post date:** [February 11, 2020, 2:22am UTC](https://discourse.processing.org/t/processing-project-falling-circles/17712/1 "2020-02-11T02:22:27Z")

</div>

so I’m working on code and I’ve created a falling circle code. right now the circle have random diameter, speed, color, and etc. I’m trying to make the circles interact for a project. every time the circles overlap they should either bounce our change color. I’m trying to make a code for either one, but I’m kinda stuck. any help?

code:

```auto
Circle [] circles = new Circle [10];    

class Circle
{
  float x;
  float y;
  float speed;
  float diam;
  color c;
  boolean valid;
 
  final int MAX_COLOR = 255;
  final int MIN_X = 50, MAX_X = 750;
  final int MIN_Y = -300, MAX_Y = -100;
  final int MIN_SPEED = 1, MAX_SPEED = 3;
  final int MIN_DIAM = 70, MAX_DIAM = 110;
 
  Circle()
  {
    initALL();
  }
 
  void initALL() {
    valid = true;
    c = color(random(255), random(255), random(255));
    x = random(MIN_X, MAX_X); 
    y = random(MIN_Y, MAX_Y);
    speed = random(MIN_SPEED, MAX_SPEED);
    diam = random(MIN_DIAM, MAX_DIAM);
  }
 
  void update() {
    if (!valid) {
      initALL();
      return;
    }
    move();
    draw_ellipse();
  }
  void draw_ellipse()
  {
    fill(c);
    ellipse (x, y, diam, diam);
  }
 
  void move()
  {
    if (y-diam <= height)
    {
      y += speed;
    } else if (y-diam > height )
    {
      valid = false;
      
    }
  }
 
    }
    
 void setup() {
  size (1000, 600);
  for (int i = 0; i < circles.length; i++)
  {
    circles[i] = new Circle();
  }
}
 
void draw() {
  background(100, 100);
  
 for (Circle s : circles ) {
    s.update();
    
  }
}

```

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [February 11, 2020, 10:12am UTC](https://discourse.processing.org/t/processing-project-falling-circles/17712/2 "2020-02-11T10:12:08Z")

</div>

for example

[https://www.processing.org/examples/bouncybubbles.html](https://www.processing.org/examples/bouncybubbles.html)
