I have fixed another part of the problem. The mouse's x and y were used as the x and y in the clearBlockers method. So when I was detecting whether a neighboring cell had 0 mines, it would always be true because the x and y were not changed to the top left corner of its cell which is required for detecting other mines. What I had to do was change each x for c*40 and y for d*40. What this change did was when I clicked on an empty cell, it revealed all the empty cells to its right and stopped on a number cell. However, the stuff it prints out at the bottom is the same, alternating between line 121 and 127.
--- Update ---
I fixed another problem and I'm getting close to fixing the whole thing. I made it only reveal the squares if they were already not revealed, so the method isn't doing a whole bunch of unnecessary work. But now there are still a few small bugs. In some spots it reveals too much and others not enough. It also prints out this:
Exception in thread "AWT-EventQueue-1" java.lang.ArrayIndexOutOfBoundsException: -1
at GameClass.clearBlockers(GameClass.java:124)
at GameClass.clearBlockers(GameClass.java:163)
at GameClass.clearBlockers(GameClass.java:121)
at GameClass.clearBlockers(GameClass.java:139)
at GameClass.clearBlockers(GameClass.java:127)
at GameClass.clearBlockers(GameClass.java:139)
at GameClass.clearBlockers(GameClass.java:121)
at GameClass.clearBlockers(GameClass.java:121)
at GameClass.clearBlockers(GameClass.java:121)
at GameClass.mouseReleased(GameClass.java:201)
at java.awt.Component.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$000(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPri vilege(Unknown Source)
at java.security.ProtectionDomain$1.doIntersectionPri vilege(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPri vilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilter s(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(U nknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarch y(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
--- Update ---
Maybe the problem is that when I type something like blockers[(d*10)+c+10] and the position of the cell is at the very bottom, it is trying to get part of the array that doesn't exist.
--- Update ---
SOLVED! My final error was in the last two big if statements of the method. I confused the places of the conditions. Since I changed the method so much in the whole process, here is the updated code:
public void clearBlockers(int x, int y){
int c = (int) Math.floor(x/40);
int d = (int) Math.floor(y/40);
if(c < 9){
if(blockers[(d*10)+c+1] == true){
blockers[(d*10)+c+1] = false;
if(mines((c*40)+40, d*40) == 0 && checkMine((c*40)+40, d*40) == false){
clearBlockers((c*40)+40, d*40);
}
}
}
if(c > 0){
if(blockers[(d*10)+c-1] == true){
blockers[(d*10)+c-1] = false;
if(mines((c*40)-40, d*40) == 0 && checkMine((c*40)-40, d*40) == false){
clearBlockers((c*40)-40, y);
}
}
}
if(d < 9){
if(blockers[(d*10)+c+10] == true){
blockers[(d*10)+c+10] = false;
if(mines(c*40, (d*40)+40) == 0 && checkMine(c*40, (d*40)+40) == false){
clearBlockers(c*40, (d*40)+40);
}
}
}
if(d > 0){
if(blockers[(d*10)+c-10] == true){
blockers[(d*10)+c-10] = false;
if(mines(c*40, (d*40)-40) == 0 && checkMine(c*40, (d*40)-40) == false){
clearBlockers(c*40, (d*40)-40);
}
}
}
if(c < 9 && d < 9){
if(blockers[(d*10)+c+11] == true){
blockers[(d*10)+c+11] = false;
if(mines((c*40)+40, (d*40)+40) == 0 && checkMine((c*40)+40, (d*40)+40) == false){
clearBlockers((c*40)+40, (d*40)+40);
}
}
}
if(c > 0 && d > 0){
if(blockers[(d*10)+c-11] == true){
blockers[(d*10)+c-11] = false;
if(mines((c*40)-40, (d*40)-40) == 0 && checkMine((c*40)-40, (d*40)-40) == false){
clearBlockers((c*40)-40, (d*40)-40);
}
}
}
if(c > 0 && d < 9){
if(blockers[(d*10)+c+9] == true){
blockers[(d*10)+c+9] = false;
if(mines((c*40)-40, (d*40)+40) == 0 && checkMine((c*40)-40, (d*40)+40) == false){
clearBlockers((c*40)-40, (d*40)+40);
}
}
}
}