

We have already discussed a number of these classes (RoundBorder, SplashScreen, Fader and Twinkle) in previous tutorials so we won't be covering them here. The classes you need can be downloaded using the following links. We suggest that you use the same tab order as our project. The order of the tabs can be important, have a look at this article on inherited classes if you want to know why. If you are more interested in reusing the classes and understanding how it works then you are better off downloading the individual classes and pasting them into separate tabs. If you just want to run MineSweeper and play the game then the easiest approach is to download the entire code in one file and paste it into the Main tab of a new project. The game ends if you tap a mine (lose) or if you reveal all of the cells without mines (win). The game is harder if you don't use flags. You don't have to use flags to indicate suspected mine locations if you don't want to.

This can reveal quite large areas depending on the mine disposition. If you tap a blank cell in Show mode, the game will also reveal any other adjacent blank cells. This icon can be toggled on and off by tapping the same cell in Flag mode. Tapping any unrevealed cell while in Flag mode will place a flag icon on that cell. Tapping it again will return it to Show mode.

When in Flag mode this button text will change to "Flag". You enter Flag mode by tapping the Show Button. If you determine that a cell contains a mine you can flag it by using Flag mode.

You can use these numbers to deduce where the mines are located. If the cell contains a number, this represents the number of mines in adjacent cells. If the cell is blank it means that there are no mines in the neighbouring cells (each cell can have up to eight neighbours depending on its grid position). This will either be blank, a number or a mine. This indicates that you are in Show mode when you tap the grid. The button in the top right will initially have "Show" as its button text. Winning, losing or tapping the New or Menu buttons will stop the game timer. The game timer will start as soon as you tap a minefield cell. The number on the right is the elapsed time in seconds (approximately). The number on the left above the minefield is the number of cells left to clear. Once you select the game difficulty by tapping on the appropriate button, you will be presented by the main game screen. The variables effected by difficulty are shown in the following table. Game difficulty is tracked using a state machine and is used when the New button is tapped on the game screen to ensure we launch another game at the same difficulty level as the current game.
