float xOffset = 0.0;
float yOffset = 0.0;
int rectSize = 30;
int ellipseX = 90;
int ellipseY = 320;
int ellipseSize = 30;
int boxPosX = 250;
int boxPosY = 130;
int spacingX = 45;
int spacingY = 45;
boolean ellipseHovering = false;
void setup () {
size (500, 350);
}
void draw() {
background (0);
for (int x = 10; x < width; x = x + spacingX) {
for (int y = 0; y < height-10; y = y + spacingY) {
// rectSize = 30;
rect (x, y, rectSize, rectSize);
if (ellipseRectDist < 10) {
rectSize = 0;
}
}
}
float ellipseRectDist = dist(x, y, ellipseX, ellipseY);
fill(200, 200, 100);
//rect (boxPosX, boxPosY, 50, 50);
fill(255, 100, 100);
ellipse(ellipseX, ellipseY, ellipseSize, ellipseSize);
xOffset = mouseX-ellipseX;
yOffset = mouseY-ellipseY;
//float boxRectDist = dist(rectX, rectY, boxPosX, boxPosY);
//if (boxRectDist < 20) {
//rectX = 90;
//rectY = 320;
// }
if (mouseX < ellipseX + 15 && mouseX > ellipseX-15 && mouseY < ellipseY + 15 && mouseY > ellipseY - 15) {
ellipseHovering = true;
} else {
ellipseHovering = false;
}
}
void mouseDragged() {
if (ellipseHovering) {
ellipseX = mouseX-xOffset;
ellipseY = mouseY-yOffset;
}
}
When I move the ellipses around, touching the rects I still don’t get a response. My goal is to make them disappear.