![Ghost type pokemon](https://loka.nahovitsyn.com/218.jpg)
![minesweeper java minesweeper java](https://i.ytimg.com/vi/S65j_nJq7Y8/maxresdefault.jpg)
Public static final int MINE_STATUS_OPEN_7 = 7 //There are 7 mines in the surrounding 8 grids Public static final int MINE_STATUS_OPEN_6 = 6 //There are 6 mines in the surrounding 8 grids Public static final int MINE_STATUS_OPEN_5 = 5 //There are 5 mines in the surrounding 8 grids Public static final int MINE_STATUS_OPEN_4 = 4 //There are 4 mines in the surrounding 8 grids Public static final int MINE_STATUS_OPEN_3 = 3 //There are 3 mines in the surrounding 8 grids Public static final int MINE_STATUS_OPEN_2 = 2 //There are 2 mines in the surrounding 8 grids Public static final int MINE_STATUS_OPEN_1 = 1 //There is 1 mine in the surrounding 8 grids
![minesweeper java minesweeper java](https://i.pinimg.com/originals/21/23/a1/2123a18fdb9882a029432eb57d4292aa.jpg)
Public static final int MINE_STATUS_OPEN_0 = 0 //There are no mines in the surrounding 8 grids Each element of the two-dimensional array of background data uses an object and needs to save several states of the current grid. Make a two-dimensional array first, and then randomly generate a certain number of random numbers (think it is a mine and assign it to the corresponding array position), which is required to be within the range of the two-dimensional array. In fact, it is the correspondence between two two-dimensional arrays, the interface grid two-dimensional array the program background grid state two-dimensional array.ġ. The above part is the main function description.
![minesweeper java minesweeper java](https://codezips.com/wp-content/uploads/2020/07/minesweeper.png)
When the game is over, click the little yellow face button at the top to restart the game. If a grid clicked is blank, it will recursively spread out all the grids around him that are not mine. Right-clicking on a grid that has already been clicked is invalid. When you right-click on a grid, it will be marked as a flag click the right button again to turn it into a question mark, and click again to restore it. When you click the left button on a grid, if it is a thunder, you lose. The middle part uses swing's GridLayout layout, which is the same as android's GridLayout, except for some usage differences. Mouse events are used to handle the picture effects when pressed, released, and clicked. Program structure and some important functions. The ideas of this article are explained in the following steps:ģ.
MINESWEEPER JAVA ANDROID
It doesn't matter if you look at the visitors, they are all apis in jdk, which are very similar to android and winform. All of these are currently used on the Internet. Few people have used swing for projects, and there are few learning materials. Considering that most of the visitors may be in android positions, so I focused on the functional structured processing to separate the core algorithm of the game from the UI, and use callback interaction to facilitate Migrate to the android environment. This rewrite is implemented using java swing (developed by eclipse). At the same time, it also expanded the functions and was closer to the minesweeper of windows. So while still on the road of programming for the past two years, I wrote it again while it was hot. It was a pity that I lost it due to many relocations. I wrote a simple minesweeping game many years ago that simulates windows.
![Ghost type pokemon](https://loka.nahovitsyn.com/218.jpg)