Java极致还原XP系统经典扫雷
前言
??最近疫情在家,没有工作上的996压迫着我,使我倍感无聊,不知道这满头秀发该如何消耗。 ??闲逛着游戏社区,常常回想起和朋友一起通宵玩游戏的那种快感,现在的我们都各奔东西,跟自己的生活对线,怕是很难再体会到了。。。 ??一款扫雷游戏使我眼前一亮,他用了关卡的模式,使我为了通关不断的尝试,不出意外,以我的脑力和运气,成功卡在了最后一关,无力感涌上心头,突然就有了写个外挂的想法。 ??但这是不对的,我们要尊重游戏制作者,所以我气不过,那就自己做一个扫雷玩,真?机智啊。 ??
实现功能
??鼠标左键单击,翻开方格 ??鼠标中键点击,标记问号 ??鼠标右键单击,标记旗子,旗子只能插和雷相同的数量 ??翻开不是雷的话,将连锁翻开周围不是雷的方格 ??翻开是雷的话,游戏结束,失败 ??翻开雷周围的方块,将显示该方块周围雷的数量 ??不能翻开标记了问号和旗子的方格 ??游戏界面显示雷的数量、剩余时间和经典小黄脸(时间默认为无限) ??点击小黄脸可重新开始游戏 ??
实战演示
??本来想从网上找点素材的,但…就是懒得找了,自己用PS随便画了几个图,感觉还行,勉强能看,需要的话,直接私聊我加Q就行。
失败
赢了
插旗
标记问号
??
下面是所有的代码
Test类
public class Test {
public static void main(String[] args) {
MyJFrame mj = new MyJFrame();
mj.myJFrame();
}
}
MyJFrame类
import javax.imageio.ImageIO;
import javax.swing.*;
import java.awt.*;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.Random;
public class MyJFrame extends JFrame implements MouseListener {
int window_width = 560, window_height = 640;
static int mine_crosswise = 10, mine_vertical = 10;
static int mine_mun = 10;
static int sign_mun = 0;
static int[][] mine = new int[mine_crosswise][mine_vertical];
static int[][] mine1 = new int[mine_crosswise][mine_vertical];
int[][] sign = new int[mine_crosswise][mine_vertical];
int[][] uncertainty = new int[mine_crosswise][mine_vertical];
static BufferedImage image = null;
static int judge = 0;
static boolean mine_place = false;
public void myJFrame() {
this.setTitle("扫雷");
this.setSize(window_width, window_height);
this.setResizable(false);
this.setDefaultCloseOperation(MyJFrame.EXIT_ON_CLOSE);
int width = Toolkit.getDefaultToolkit().getScreenSize().width;
int height = Toolkit.getDefaultToolkit().getScreenSize().height;
this.setLocation((width - window_width) / 2, (height - window_height) / 2);
this.addMouseListener(this);
this.setVisible(true);
}
public void paint(Graphics g) {
BufferedImage bi = new BufferedImage(window_width, window_height, BufferedImage.TYPE_INT_ARGB);
Graphics g2 = bi.createGraphics();
g2.setColor(Color.red);
g2.setFont(new Font("微软雅黑", 10, 30));
g2.drawString("雷数:" + mine_mun, 50, 80);
g2.setColor(Color.red);
g2.setFont(new Font("微软雅黑", 10, 30));
g2.drawString("时间:无限", window_width - 200, 80);
again();
g2.drawImage(image, (window_width - 50) / 2, 45, this);
for (int i = 0; i < mine_crosswise; i++) {
for (int j = 0; j < mine_vertical; j++) {
if (mine1[i][j] == -1) {
try {
image = ImageIO.read(new File("D:\\#Java\\个人项目\\MineSweeper\\img\\1.png"));
} catch (IOException e) {
e.printStackTrace();
}
g2.drawImage(image, 30 + i * 50, 110 + j * 50, this);
continue;
}
if (mine1[i][j] == 1) {
try {
image = ImageIO.read(new File("D:\\#Java\\个人项目\\MineSweeper\\img\\01.png"));
} catch (IOException e) {
e.printStackTrace();
}
g2.drawImage(image, 30 + i * 50, 110 + j * 50, this);
continue;
}
if (mine1[i][j] == 2) {
try {
image = ImageIO.read(new File("D:\\#Java\\个人项目\\MineSweeper\\img\\02.png"));
} catch (IOException e) {
e.printStackTrace();
}
g2.drawImage(image, 30 + i * 50, 110 + j * 50, this);
continue;
}
if (mine1[i][j] == 3) {
try {
image = ImageIO.read(new File("D:\\#Java\\个人项目\\MineSweeper\\img\\03.png"));
} catch (IOException e) {
e.printStackTrace();
}
g2.drawImage(image, 30 + i * 50, 110 + j * 50, this);
continue;
}
if (mine1[i][j] == 4) {
try {
image = ImageIO.read(new File("D:\\#Java\\个人项目\\MineSweeper\\img\\04.png"));
} catch (IOException e) {
e.printStackTrace();
}
g2.drawImage(image, 30 + i * 50, 110 + j * 50, this);
continue;
}
if (mine1[i][j] == 5) {
try {
image = ImageIO.read(new File("D:\\#Java\\个人项目\\MineSweeper\\img\\05.png"));
} catch (IOException e) {
e.printStackTrace();
}
g2.drawImage(image, 30 + i * 50, 110 + j * 50, this);
continue;
}
if (mine1[i][j] == 6) {
try {
image = ImageIO.read(new File("D:\\#Java\\个人项目\\MineSweeper\\img\\06.png"));
} catch (IOException e) {
e.printStackTrace();
}
g2.drawImage(image, 30 + i * 50, 110 + j * 50, this);
continue;
}
if (mine1[i][j] == 7) {
try {
image = ImageIO.read(new File("D:\\#Java\\个人项目\\MineSweeper\\img\\07.png"));
} catch (IOException e) {
e.printStackTrace();
}
g2.drawImage(image, 30 + i * 50, 110 + j * 50, this);
continue;
}
if (mine1[i][j] == 8) {
try {
image = ImageIO.read(new File("D:\\#Java\\个人项目\\MineSweeper\\img\\08.png"));
} catch (IOException e) {
e.printStackTrace();
}
g2.drawImage(image, 30 + i * 50, 110 + j * 50, this);
continue;
}
if (sign[i][j] == 1) {
try {
image = ImageIO.read(new File("D:\\#Java\\个人项目\\MineSweeper\\img\\sign.png"));
} catch (IOException e) {
e.printStackTrace();
}
g2.drawImage(image, 30 + i * 50, 110 + j * 50, this);
continue;
}
if (uncertainty[i][j] == 1) {
try {
image = ImageIO.read(new File("D:\\#Java\\个人项目\\MineSweeper\\img\\uncertainty.png"));
} catch (IOException e) {
e.printStackTrace();
}
g2.drawImage(image, 30 + i * 50, 110 + j * 50, this);
continue;
}
try {
image = ImageIO.read(new File("D:\\#Java\\个人项目\\MineSweeper\\img\\0.png"));
} catch (IOException e) {
e.printStackTrace();
}
g2.drawImage(image, 30 + i * 50, 110 + j * 50, this);
}
}
if (judge == 1 || judge == 2) {
for (int i = 0; i < mine_crosswise; i++) {
for (int j = 0; j < mine_vertical; j++) {
if (mine[i][j] == 9) {
try {
image = ImageIO.read(new File("D:\\#Java\\个人项目\\MineSweeper\\img\\mine.png"));
} catch (IOException e) {
e.printStackTrace();
}
g2.drawImage(image, 30 + i * 50, 110 + j * 50, this);
}
}
}
}
place();
g.drawImage(bi, 0, 0, this);
}
public static void scan(int x, int y) {
if (x - 1 >= 0 && x + 1 <= mine_crosswise - 1 && y - 1 < 0) {
if (mine[x - 1][y] == 0) {
mine1[x - 1][y] = mine[x - 1][y] = -1;
scan(x - 1, y);
} else {
mine1[x - 1][y] = mine[x - 1][y];
}
if (mine[x - 1][y + 1] == 0) {
mine1[x - 1][y + 1] = mine[x - 1][y + 1] = -1;
scan(x - 1, y + 1);
} else {
mine1[x - 1][y + 1] = mine[x - 1][y + 1];
}
if (mine[x][y + 1] == 0) {
mine1[x][y + 1] = mine[x][y + 1] = -1;
scan(x, y + 1);
} else {
mine1[x][y + 1] = mine[x][y + 1];
}
if (mine[x + 1][y + 1] == 0) {
mine1[x + 1][y + 1] = mine[x + 1][y + 1] = -1;
scan(x + 1, y + 1);
} else {
mine1[x + 1][y + 1] = mine[x + 1][y + 1];
}
if (mine[x + 1][y] == 0) {
mine1[x + 1][y] = mine[x + 1][y] = -1;
scan(x + 1, y);
} else {
mine1[x + 1][y] = mine[x + 1][y];
}
}
if (x - 1 >= 0 && x + 1 <= mine_crosswise - 1 && y + 1 > mine_vertical - 1) {
if (mine[x - 1][y] == 0) {
mine1[x - 1][y] = mine[x - 1][y] = -1;
scan(x - 1, y);
} else {
mine1[x - 1][y] = mine[x - 1][y];
}
if (mine[x - 1][y - 1] == 0) {
mine1[x - 1][y - 1] = mine[x - 1][y - 1] = -1;
scan(x - 1, y - 1);
} else {
mine1[x - 1][y - 1] = mine[x - 1][y - 1];
}
if (mine[x][y - 1] == 0) {
mine1[x][y - 1] = mine[x][y - 1] = -1;
scan(x, y - 1);
} else {
mine1[x][y - 1] = mine[x][y - 1];
}
if (mine[x + 1][y - 1] == 0) {
mine1[x + 1][y - 1] = mine[x + 1][y - 1] = -1;
scan(x + 1, y - 1);
} else {
mine1[x + 1][y - 1] = mine[x + 1][y - 1];
}
if (mine[x + 1][y] == 0) {
mine1[x + 1][y] = mine[x + 1][y] = -1;
scan(x + 1, y);
} else {
mine1[x + 1][y] = mine[x + 1][y];
}
}
if (y - 1 >= 0 && y + 1 <= mine_crosswise - 1 && x - 1 < 0) {
if (mine[x][y - 1] == 0) {
mine1[x][y - 1] = mine[x][y - 1] = -1;
scan(x, y - 1);
} else {
mine1[x][y - 1] = mine[x][y - 1];
}
if (mine[x + 1][y - 1] == 0) {
mine1[x + 1][y - 1] = mine[x + 1][y - 1] = -1;
scan(x + 1, y - 1);
} else {
mine1[x + 1][y - 1] = mine[x + 1][y - 1];
}
if (mine[x + 1][y] == 0) {
mine1[x + 1][y] = mine[x + 1][y] = -1;
scan(x + 1, y);
} else {
mine1[x + 1][y] = mine[x + 1][y];
}
if (mine[x + 1][y + 1] == 0) {
mine1[x + 1][y + 1] = mine[x + 1][y + 1] = -1;
scan(x + 1, y + 1);
} else {
mine1[x + 1][y + 1] = mine[x + 1][y + 1];
}
if (mine[x][y + 1] == 0) {
mine1[x][y + 1] = mine[x][y + 1] = -1;
scan(x, y + 1);
} else {
mine1[x][y + 1] = mine[x][y + 1];
}
}
if (y - 1 >= 0 && y + 1 <= mine_vertical - 1 && x + 1 > mine_crosswise - 1) {
if (mine[x][y - 1] == 0) {
mine1[x][y - 1] = mine[x][y - 1] = -1;
scan(x, y - 1);
} else {
mine1[x][y - 1] = mine[x][y - 1];
}
if (mine[x - 1][y - 1] == 0) {
mine1[x - 1][y - 1] = mine[x - 1][y - 1] = -1;
scan(x - 1, y - 1);
} else {
mine1[x - 1][y - 1] = mine[x - 1][y - 1];
}
if (mine[x - 1][y] == 0) {
mine1[x - 1][y] = mine[x - 1][y] = -1;
scan(x - 1, y);
} else {
mine1[x - 1][y] = mine[x - 1][y];
}
if (mine[x - 1][y + 1] == 0) {
mine1[x - 1][y + 1] = mine[x - 1][y + 1] = -1;
scan(x - 1, y + 1);
} else {
mine1[x - 1][y + 1] = mine[x - 1][y + 1];
}
if (mine[x][y + 1] == 0) {
mine1[x][y + 1] = mine[x][y + 1] = -1;
scan(x, y + 1);
} else {
mine1[x][y + 1] = mine[x][y + 1];
}
}
if (x - 1 < 0 && y - 1 < 0) {
if (mine[x + 1][y] == 0) {
mine1[x + 1][y] = mine[x + 1][y] = -1;
scan(x + 1, y);
} else {
mine1[x + 1][y] = mine[x + 1][y];
}
if (mine[x][y + 1] == 0) {
mine1[x][y + 1] = mine[x][y + 1] = -1;
scan(x, y + 1);
} else {
mine1[x][y + 1] = mine[x][y + 1];
}
if (mine[x + 1][y + 1] == 0) {
mine1[x + 1][y + 1] = mine[x + 1][y + 1] = -1;
scan(x + 1, y + 1);
} else {
mine1[x + 1][y + 1] = mine[x + 1][y + 1];
}
}
if (x + 1 >= mine_crosswise && y - 1 < 0) {
if (mine[x - 1][y] == 0) {
mine1[x - 1][y] = mine[x - 1][y] = -1;
scan(x - 1, y);
} else {
mine1[x - 1][y] = mine[x - 1][y];
}
if (mine[x][y + 1] == 0) {
mine1[x][y + 1] = mine[x][y + 1] = -1;
scan(x, y + 1);
} else {
mine1[x][y + 1] = mine[x][y + 1];
}
if (mine[x - 1][y + 1] == 0) {
mine1[x - 1][y + 1] = mine[x - 1][y + 1] = -1;
scan(x - 1, y + 1);
} else {
mine1[x - 1][y + 1] = mine[x - 1][y + 1];
}
}
if (x - 1 < 0 && y + 1 >= mine_vertical) {
if (mine[x + 1][y] == 0) {
mine1[x + 1][y] = mine[x + 1][y] = -1;
scan(x + 1, y);
} else {
mine1[x + 1][y] = mine[x + 1][y];
}
if (mine[x][y - 1] == 0) {
mine1[x][y - 1] = mine[x][y - 1] = -1;
scan(x, y - 1);
} else {
mine1[x][y - 1] = mine[x][y - 1];
}
if (mine[x + 1][y - 1] == 0) {
mine1[x + 1][y - 1] = mine[x + 1][y - 1] = -1;
scan(x + 1, y - 1);
} else {
mine1[x + 1][y - 1] = mine[x + 1][y - 1];
}
}
if (x + 1 >= mine_crosswise && y + 1 >= mine_vertical) {
if (mine[x - 1][y] == 0) {
mine1[x - 1][y] = mine[x - 1][y] = -1;
scan(x - 1, y);
} else {
mine1[x - 1][y] = mine[x - 1][y];
}
if (mine[x][y - 1] == 0) {
mine1[x][y - 1] = mine[x][y - 1] = -1;
scan(x, y - 1);
} else {
mine1[x][y - 1] = mine[x][y - 1];
}
if (mine[x - 1][y - 1] == 0) {
mine1[x - 1][y - 1] = mine[x - 1][y - 1] = -1;
scan(x - 1, y - 1);
} else {
mine1[x - 1][y - 1] = mine[x - 1][y - 1];
}
}
if (x - 1 >= 0 && y - 1 >= 0 && x + 1 < mine_crosswise && y + 1 < mine_vertical) {
if (mine[x - 1][y - 1] == 0) {
mine1[x - 1][y - 1] = mine[x - 1][y - 1] = -1;
scan(x - 1, y - 1);
} else {
mine1[x - 1][y - 1] = mine[x - 1][y - 1];
}
if (mine[x - 1][y] == 0) {
mine1[x - 1][y] = mine[x - 1][y] = -1;
scan(x - 1, y);
} else {
mine1[x - 1][y] = mine[x - 1][y];
}
if (mine[x - 1][y + 1] == 0) {
mine1[x][y - 1] = mine[x][y - 1] = -1;
scan(x - 1, y + 1);
} else {
mine1[x][y - 1] = mine[x][y - 1];
}
if (mine[x][y - 1] == 0) {
mine1[x][y - 1] = mine[x][y - 1] = -1;
scan(x, y - 1);
} else {
mine1[x][y - 1] = mine[x][y - 1];
}
if (mine[x][y + 1] == 0) {
mine1[x][y + 1] = mine[x][y + 1] = -1;
scan(x, y + 1);
} else {
mine1[x][y + 1] = mine[x][y + 1];
}
if (mine[x + 1][y - 1] == 0) {
mine1[x + 1][y - 1] = mine[x + 1][y - 1] = -1;
scan(x + 1, y - 1);
} else {
mine1[x + 1][y - 1] = mine[x + 1][y - 1];
}
if (mine[x + 1][y] == 0) {
mine1[x + 1][y] = mine[x + 1][y] = -1;
scan(x + 1, y);
} else {
mine1[x + 1][y] = mine[x + 1][y];
}
if (mine[x + 1][y + 1] == 0) {
mine1[x + 1][y + 1] = mine[x + 1][y + 1] = -1;
scan(x + 1, y + 1);
} else {
mine1[x + 1][y + 1] = mine[x + 1][y + 1];
}
}
}
public static void again() {
if (judge == 0) {
try {
image = ImageIO.read(new File("D:\\#Java\\个人项目\\MineSweeper\\img\\playing.png"));
} catch (IOException e) {
e.printStackTrace();
}
} else if (judge == 1) {
try {
image = ImageIO.read(new File("D:\\#Java\\个人项目\\MineSweeper\\img\\win.png"));
} catch (IOException e) {
e.printStackTrace();
}
} else if (judge == 2) {
try {
image = ImageIO.read(new File("D:\\#Java\\个人项目\\MineSweeper\\img\\lose.png"));
} catch (IOException e) {
e.printStackTrace();
}
}
}
public static void place() {
if (mine_place == false) {
Random r = new Random();
int x, y;
for (int i = 0; i < mine_mun; i++) {
x = r.nextInt(mine_mun);
y = r.nextInt(mine_mun);
if (mine[x][y] == 9) {
i--;
continue;
}
mine1[x][y] = mine[x][y] = 9;
if (x - 1 >= 0 && x + 1 <= mine_crosswise - 1 && y - 1 < 0) {
if (mine[x - 1][y] != 9) {
mine[x - 1][y]++;
}
if (mine[x - 1][y + 1] != 9) {
mine[x - 1][y + 1]++;
}
if (mine[x][y + 1] != 9) {
mine[x][y + 1]++;
}
if (mine[x + 1][y + 1] != 9) {
mine[x + 1][y + 1]++;
}
if (mine[x + 1][y] != 9) {
mine[x + 1][y]++;
}
}
if (x - 1 >= 0 && x + 1 <= mine_crosswise - 1 && y + 1 > mine_vertical - 1) {
if (mine[x - 1][y] != 9) {
mine[x - 1][y]++;
}
if (mine[x - 1][y - 1] != 9) {
mine[x - 1][y - 1]++;
}
if (mine[x][y - 1] != 9) {
mine[x][y - 1]++;
}
if (mine[x + 1][y - 1] != 9) {
mine[x + 1][y - 1]++;
}
if (mine[x + 1][y] != 9) {
mine[x + 1][y]++;
}
}
if (y - 1 >= 0 && y + 1 <= mine_crosswise - 1 && x - 1 < 0) {
if (mine[x][y - 1] != 9) {
mine[x][y - 1]++;
}
if (mine[x + 1][y - 1] != 9) {
mine[x + 1][y - 1]++;
}
if (mine[x + 1][y] != 9) {
mine[x + 1][y]++;
}
if (mine[x + 1][y + 1] != 9) {
mine[x + 1][y + 1]++;
}
if (mine[x][y + 1] != 9) {
mine[x][y + 1]++;
}
}
if (y - 1 >= 0 && y + 1 <= mine_vertical - 1 && x + 1 > mine_crosswise - 1) {
if (mine[x][y - 1] != 9) {
mine[x][y - 1]++;
}
if (mine[x - 1][y - 1] != 9) {
mine[x - 1][y - 1]++;
}
if (mine[x - 1][y] != 9) {
mine[x - 1][y]++;
}
if (mine[x - 1][y + 1] != 9) {
mine[x - 1][y + 1]++;
}
if (mine[x][y + 1] != 9) {
mine[x][y + 1]++;
}
}
if (x - 1 < 0 && y - 1 < 0) {
if (mine[x + 1][y] != 9) {
mine[x + 1][y]++;
}
if (mine[x][y + 1] != 9) {
mine[x][y + 1]++;
}
if (mine[x + 1][y + 1] != 9) {
mine[x + 1][y + 1]++;
}
}
if (x + 1 >= mine_crosswise && y - 1 < 0) {
if (mine[x - 1][y] != 9) {
mine[x - 1][y]++;
}
if (mine[x][y + 1] != 9) {
mine[x][y + 1]++;
}
if (mine[x - 1][y + 1] != 9) {
mine[x - 1][y + 1]++;
}
}
if (x - 1 < 0 && y + 1 >= mine_vertical) {
if (mine[x + 1][y] != 9) {
mine[x + 1][y]++;
}
if (mine[x][y - 1] != 9) {
mine[x][y - 1]++;
}
if (mine[x + 1][y - 1] != 9) {
mine[x + 1][y - 1]++;
}
}
if (x + 1 >= mine_crosswise && y + 1 >= mine_vertical) {
if (mine[x - 1][y] != 9) {
mine[x - 1][y]++;
}
if (mine[x][y - 1] != 9) {
mine[x][y - 1]++;
}
if (mine[x - 1][y - 1] != 9) {
mine[x - 1][y - 1]++;
}
}
if (x - 1 >= 0 && y - 1 >= 0 && x + 1 < mine_crosswise && y + 1 < mine_vertical) {
if (mine[x - 1][y - 1] != 9) {
mine[x - 1][y - 1]++;
}
if (mine[x - 1][y] != 9) {
mine[x - 1][y]++;
}
if (mine[x - 1][y + 1] != 9) {
mine[x - 1][y + 1]++;
}
if (mine[x][y - 1] != 9) {
mine[x][y - 1]++;
}
if (mine[x][y + 1] != 9) {
mine[x][y + 1]++;
}
if (mine[x + 1][y - 1] != 9) {
mine[x + 1][y - 1]++;
}
if (mine[x + 1][y] != 9) {
mine[x + 1][y]++;
}
if (mine[x + 1][y + 1] != 9) {
mine[x + 1][y + 1]++;
}
}
}
mine_place = true;
}
}
@Override
public void mouseClicked(MouseEvent e) {
int x = e.getX();
int y = e.getY();
if (judge == 0) {
if (x > 30 && x < 30 + mine_crosswise * 50 && y > 110 && y < 110 + mine_vertical * 50) {
x = (x - 30) / 50;
y = (y - 110) / 50;
if (e.getButton() == MouseEvent.BUTTON1) {
if (sign[x][y] == 0 && uncertainty[x][y] == 0) {
if (mine[x][y] != 9) {
scan(x, y);
mine1[x][y] = mine[x][y];
this.repaint();
} else if (mine[x][y] == 9) {
judge = 2;
this.repaint();
JOptionPane.showMessageDialog(this, "你被雷炸了个粉碎!");
}
int mun = 0;
for (int i = 0; i < mine_crosswise; i++) {
for (int j = 0; j < mine_vertical; j++) {
if (mine1[i][j] == 0) {
++mun;
}
}
}
if (mun == 0) {
judge = 1;
this.repaint();
JOptionPane.showMessageDialog(this, "你完整的活了下来!");
}
}
} else if (e.getButton() == MouseEvent.BUTTON2) {
if (uncertainty[x][y] == 0 && sign[x][y] == 0) {
uncertainty[x][y] = 1;
} else if (uncertainty[x][y] == 1) {
uncertainty[x][y] = 0;
}
this.repaint();
} else if (e.getButton() == MouseEvent.BUTTON3) {
if (sign[x][y] == 0 && sign_mun < mine_mun && uncertainty[x][y] == 0) {
sign[x][y] = 1;
sign_mun++;
} else if (sign[x][y] == 1) {
sign[x][y] = 0;
sign_mun--;
}
this.repaint();
}
}
if (x >= (window_width - 50) / 2 && y >= 45 && x <= (window_width - 50) / 2 + 50 && y <= 45 + 50) {
mine_mun = 10;
for (int i = 0; i < mine_crosswise; i++) {
for (int j = 0; j < mine_vertical; j++) {
mine[i][j] = 0;
mine1[i][j] = 0;
sign[i][j] = 0;
uncertainty[i][j] = 0;
}
}
mine_place = false;
again();
place();
judge = 0;
this.repaint();
}
}
}
@Override
public void mousePressed(MouseEvent e) {
}
@Override
public void mouseReleased(MouseEvent e) {
}
@Override
public void mouseEntered(MouseEvent e) {
}
@Override
public void mouseExited(MouseEvent e) {
}
}
结束语
??实现的功能比较基础,有时间的话我想再升级一下,比如加个调难度啥的,我也整个关卡,哈哈。 ??BUG不可避免,我自己玩了几遍,暂时还没发现什么严重的问题,如果有问题,欢迎到评论区指正。 ??往期Java小游戏还有: ??五子棋全代码 ??贪吃蛇全代码 ??最后还是老话:坚持分享知识的原则,保证代码公开透明,如果帮到了你,请顺手点个赞吧(#^.^#)
。
|