Jonathan. Frech’s WebBlog

JSweeper (#170)

Jonathan Frech,

Adding to my col­lec­tion of clones of popular, well-known games, I created back in November of 2016 a Java-im­ple­men­ta­tion of the all-time Windows classic game, Minesweeper.

Minesweeper was pre-installed on every installation of Windows up to and including Windows 7 and has been ported to a variety of dif­fer­ent systems. Because of this, nearly everyone has at least once in their life played Minesweeper or at least heard of it.
In Minesweeper you are presented with a square grid of covered tiles containing ei­ther numbers or mines. Your task is it to uncover all tiles which are not mines in the least amount of time. When you uncover a mine, it explodes and the game is lost. To aid in figuring out which tiles are mines and which are not, every tile that is not a mine tells you how many mines are in the neighbouring eight tiles. Tiles which have no neighbouring mines are drawn gray and uncover neighbouring non-mine tiles once uncovered.
More on Minesweeper can be found in this Wiki­pe­dia article — I am linking to the German version, as the cur­rent English version has major flaws and lacks crucial in­for­ma­tion. If you are so inclined, feel free to fix the English Minesweeper Wiki­pe­dia article.

In my clone, there are three pre-defined difficulty levels, di­rect­ly ported from the original Minesweeper game, and an op­tion to freely adjust the board’s width and height as well as the num­ber of bombs which will be placed. Gameplay is nearly identical to the original, as my clone also uses a square grid and the tile’s numbers correspond to the num­ber of bombs in the eight tiles surrounding that tile.
The game has a purposefully cho­sen pixel-look using a self-made font to go along with the pixel-style.

Controls

To play the game, you can ei­ther download the .jar file or compile the source code for yourself. The source code is listed below and can be downloaded as a .java file.

Source code: Main.java