# How can I light up separate circles instead of them all

**URL:** <https://discourse.processing.org/t/how-can-i-light-up-separate-circles-instead-of-them-all/32468>\
**Category:** Coding Questions\
**Tags:** homework\
**Created:** [September 28, 2021, 8:41am UTC](https://discourse.processing.org/t/how-can-i-light-up-separate-circles-instead-of-them-all/32468 "2021-09-28T08:41:28Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Caprisunny](https://avatars.discourse-cdn.com/v4/letter/c/b2d939/32.png) [@Caprisunny](https://discourse.processing.org/u/Caprisunny)\
**Post date:** [September 28, 2021, 8:41am UTC](https://discourse.processing.org/t/how-can-i-light-up-separate-circles-instead-of-them-all/32468/1 "2021-09-28T08:41:28Z")

</div>

```auto
int[][] cirkels = { {10, 15}, {100, 130}, {77, 43}, {30, 145}, {185, 17}, {99, 76} };
final int DIAMETER = 20;
final int STRAAL = 10;
final int GEEL = #FFFF00;
final int ROOD = #FF0000;
int kleur;

void setup() {
  size(200, 200);
}
void draw() {
  background(#000000);
  tekenCirkels(cirkels, kleur);
  muisKleuren();
}

void tekenCirkels(int[][] array,int kleur) {
  for (int i = 0; i < array.length; i++) {
    fill(kleur);
    circle(array[i][0], array[i][1], DIAMETER);
  }
}

void muisKleuren() {
  if ( positiecheck()) {
    kleur = ROOD;
  } else {
    kleur = GEEL;
  }
}

boolean positiecheck() {
  for (int i = 0; i < cirkels.length; i++) {
    if (dist(cirkels[i][0], cirkels[i][1], mouseX, mouseY) < STRAAL) {
      return true;
    }
  }
  return false;
}

```

I’m trying to light up only one circle if you hover over it,  
right now it only activates if you have the circle that’s last in the array, and then they all light up red.

---

<div class="post-metadata">

**Author:** ![Caprisunny](https://avatars.discourse-cdn.com/v4/letter/c/b2d939/32.png) [@Caprisunny](https://discourse.processing.org/u/Caprisunny)\
**Post date:** [September 28, 2021, 9:29am UTC](https://discourse.processing.org/t/how-can-i-light-up-separate-circles-instead-of-them-all/32468/2 "2021-09-28T09:29:35Z")

</div>

```auto
int[][] cirkels = { {10, 15}, {100, 130}, {77, 43}, {30, 145}, {185, 17}, {99, 76} };
final int DIAMETER = 20;
final int STRAAL = 10;
final int GEEL = #FFFF00;
final int ROOD = #FF0000;
int kleur;

void setup() {
  size(200, 200);
}
void draw() {
  background(#000000);
  tekenCirkels(cirkels, kleur);
  muisKleuren();
}

void tekenCirkels(int[][] array,int kleur) {
  for (int i = 0; i < array.length; i++) {
    fill(kleur);
    circle(array[i][0], array[i][1], DIAMETER);
  }
}

void muisKleuren() {
  if ( positiecheck()) {
    kleur = ROOD;
  } else {
    kleur = GEEL;
  }
}

boolean positiecheck() {
  for (int i = 0; i < cirkels.length; i++) {
    if (dist(cirkels[i][0], cirkels[i][1], mouseX, mouseY) < STRAAL) {
      return true;
    }
  }
  return false;
}

```

my current code, still lights them all up.

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [September 28, 2021, 10:08am UTC](https://discourse.processing.org/t/how-can-i-light-up-separate-circles-instead-of-them-all/32468/3 "2021-09-28T10:08:14Z")

</div>

Hello,

Add another array to keep track of circle that you are “over” in another array.

```auto
boolean over [] = new boolean[6];

if (over[i])
  fill(ROOD);
else
 fill(GEEL)

```

![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/0/03a0d7e97d7f82eadfff7d0122de3b94c29ea341.png)

Once you start studying objects and work with them it gets easier!

> **[Objects](https://processing.org/tutorials/objects/)**
>
> The basics of object-oriented programming.

`:)`
