i’m trying to create a code that display a grid with squares and when you put the mouse over a square it disappears, how ever in my code when I put the mouse over a square the row and the column disappear…
here is my code
int objX;
int objY;
int x, y, w, h;
int lastEnteredX = 100000000;
int lastEnteredY = 100000000;
int posX;
int posY;
void setup() {
size(1000, 1000);
x = 20;
y = 20;
h = 85;
w = 85;
}
void draw() {
background(#000000);
name();
objX = mouseX;
objY = mouseY;
}
void name() {
for (int i = 0; i < (10*w +10); i = i + w + 10) {
for (int j = 0; j < 5*h + 10; j += h + 10) {
posX = i;
posY = j;
if (objX < x + w + i && objX > x + i && objY < y + h + j && objY > y + j) {
println("entered, I: " + i + " J: "+ j + " lastEnteredX: " + lastEnteredX + ", lastEnteredY: " + lastEnteredY );
lastEnteredX = i;
lastEnteredY = j;
}
if (posX != lastEnteredX && posY != lastEnteredY) {
rect(x + i, y + j, w, h);
}
}
}
}
and also if you know a way to make them disappear for ever it would be great!