Hey, I am attempting to create a Minesweeper game with a chemistry twist to it on processing. In my code, the if statement to unveil what is hidden under the square (bomb or number) did not work. I attempted to println with Mouse X and MouseY to see what the computer was computing at different positions. Whenever I pressed the mouse anywhere on the screen, the print line provided the text “object is in an invalid state.” Help?!
int square = 50;
int T = 260;
void setup() {
size(1080, 800);
}
void draw() {
background(240, 230, 220);
for(int a = 140; a<460; a+= 50){
rectMode(CENTER);
rect(80,a,50,50);
}
for(int b = 190; b<460; b+= 50){
rectMode(CENTER);
rect(130,b,50,50);
}
for(int c = 290; c<460; c+= 50){
rectMode(CENTER);
rect(180,c,50,50);
}
for(int d = 290; d<460; d+= 50){
rectMode(CENTER);
rect(230,d,50,50);
}
for(int e = 290; e<460; e+= 50){
rectMode(CENTER);
rect(280,e,50,50);
}
for(int f = 290; f<460; f+= 50){
rectMode(CENTER);
rect(f, 640, square, square);
}
for(int X = 290; X<460; X+=square){
rectMode(CENTER);
rect(530, X, square, square);
}
for(int XI = 290; XI<460; XI+=square){
rectMode(CENTER);
rect(580, XI, square, square);
}
for(int XII = 290; XII<460; XII+=square){
rectMode(CENTER);
rect(630, XII, square, square);
}
for(int XIII = 290; XIII<460; XIII+=square){
rectMode(CENTER);
rect(680, XIII, square, square);
}
for(int XIV = 290; XIV<460; XIV+=square){
rectMode(CENTER);
rect(730, XIV, square, square);
}
for(int XV=290; XV<460; XV+=square){
rectMode(CENTER);
rect(780, XV, square, square);
}
for(int XVI=290; XVI<460; XVI+=square){
rectMode(CENTER);
rect(830, XVI, square, square);
}
for(int XVII=190; XVII<460; XVII+=square){
rectMode(CENTER);
rect(880, XVII, square, square);
}
for(int XVIII = 140; XVIII<460; XVIII+=square){
rectMode(CENTER);
rect(930, XVIII, square, square);
}
fill(0);
ellipse(80,140,30,30);
noLoop();
textSize(32);
text("He", 62, 200);
fill(0);
ellipse(130,190,30,30);
noLoop();
fill(240,243,242,T);
rect(80,140,50,50);
rect(80,190,50,50);
rect(130,190,50,50);
noLoop();
println(mouseX, mouseY);
}
void mousePressed() {
if(mouseX > 80 && mouseX < 130 && mouseY > 140 && mouseY <190) {
T = 0;
}
else {
T = 260;
}
}