Browse Source

Game End: Clicked on Mine

feature_Minesweeper_Playfield
kfkama 3 years ago
parent
commit
4cbfc45a3d
  1. 2
      src/main/java/Minesweeper/Cell.java
  2. 3
      src/main/java/Minesweeper/Playfield.java

2
src/main/java/Minesweeper/Cell.java

@ -37,6 +37,8 @@ public class Cell extends JButton {
protected void OnMouseClick() { protected void OnMouseClick() {
if (type != CellType.Bomb) { if (type != CellType.Bomb) {
flood(); flood();
} else {
playfield.reset();
} }
} }

3
src/main/java/Minesweeper/Playfield.java

@ -2,6 +2,8 @@ package Minesweeper;
import java.awt.Point; import java.awt.Point;
import javax.swing.JOptionPane;
public class Playfield { public class Playfield {
private static final int CELLSIZE = 50; private static final int CELLSIZE = 50;
@ -61,6 +63,7 @@ public class Playfield {
} }
public void reset() { public void reset() {
JOptionPane.showMessageDialog(MsG,"KABOOM! Try again!");
for (int i = 0; i < Size; i++) { for (int i = 0; i < Size; i++) {
for (int j = 0; j < Size; j++) { for (int j = 0; j < Size; j++) {
MsG.remove(cells[i][j]); MsG.remove(cells[i][j]);

Loading…
Cancel
Save