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.