Minesweeper

One day in some forum someone asked what would be the simplest game that could be launched in a new platform without apps which was always a success. Some other guy said minesweeper, the rules are simple, the implementation also, there is no need for any special art and the game is always funny and challenging.

After reading that, I decided to try to implement it using lua. At this time I had used the Love2D game engine for one game I made for the Ludum Dare game jam.

Implementation

The first and main part to implement was the map. I started by making a matrix where each position has three variables:

With this data I generated a random value for each position of the map and tested the rendering.

With this I could flag mines and press each place, but the pressed places are not very visible, the numbers don’t have colours se we just see a grey place in the numbers and the numbers are not really the mines around. So The next step was implementing this things.

Minesweeper First

The first two points were mostly changing colours according to the number and changing spacing. For the mines in the neighborhood was creating a method which checks the 8 positions around the current point and using that to set the count of mines of each position.

For the mines placing was just some random placing in map until the pre-defined number of mines are placed.

Minesweeper Improved

Now only expanding was missing. Implementing it was just question of checking the neighborhood again and if a block with 0 mines is in the neighborhood just open it and check its neighborhood.

After this some effect was added when the player loses to display where the missing mines where. And a text saying “You've won!” after flagging all the mines and opening all the blocks.

Result

With all the game implemented the result was:

Some improvements could be done, but the game turned really fun while also being simple to implement. With some small tailoring could be a great choice to do on a store on a new platform.

Repository

If you want to checkout the code of the project check the repository.

Other

If you want to receive updates when there are new games or development stories join the mailing list