This Minesweeper game is a simulation of the one made by Microsoft. The playing field and the mine- and time counter are an exact copy of the one made by Microsoft. I've not copied the smiley thing, I don't like it.
Since I am using Microsoft Windows Vista or Microsoft Windows 7, I really dislike the Minesweeper game. I think the one shipped with Microsoft Windows XP is the best. Except the use of left and right button simultaneously for opening fields after setting some flags. Why should I want to use two buttons while using only the left button is much more useful? Especially since it's not taken by any other function.
Using the Code
This JPanel creates the playing field based on the difficulty. There are three levels of difficulty: beginner, intermediate and expert. It contains a 2 dimensional array of fields.
A field knows its x and y coordinates for painting at the right spot, how many neighbour fields contain a mine, if it is clicked, if it is a mine, if the user made it a flag and if the user clicked it while it is a flag.
The numbers, flag and mine are painted by hand so they will look the same on any OS. At least, I hope so.
setGameOver is used for setting up the playing field after the user has clicked a mine. The method
setWon is used for setting up the playing field after the user has removed all non mine fields.
Display & Digit
Displays are the mine counter and the time display. A display consists of three digits.
English isn't my main language, so it can be unreadable. I'm sorry. I don't use comments in my coding, it scares me and I think comments makes the code unreadable. After all, methods should do what they are called.
- 28th January, 2009: Initial post