when intersected n times, do something
in
Programming Questions
•
7 months ago
hi!now every time circles intersect background color is changed
i wonder how to make the same happen but after n times circles touch
say when circles has intersected 3 times, change background colour
any ideas?
best, k
i wonder how to make the same happen but after n times circles touch
say when circles has intersected 3 times, change background colour
any ideas?
best, k
- float diam = 100;
boolean currentlyTouching;
color bgColor = color(255);
void setup() {
size(500, 400);
strokeWeight(5);
noFill();
smooth();
}
void draw() {
background(bgColor);
float x = width/2;
float y = height/2;
float d = dist(x, y, mouseX, mouseY);
if (d < diam) {
if (currentlyTouching == false) {
bgColor = color(random(255), random(255), random(255));
}
currentlyTouching = true;
} else {
currentlyTouching = false;
}
stroke(255, 255, 0);
ellipse(x, y, diam, diam);
stroke(0, 255, 0);
ellipse(mouseX, mouseY, diam, diam);
}
1