MineSweeper in React Native
1 min readAug 27, 2019
Yesterday I made a (more or less) fully functional MineSweeper game in React Native.
MineSweeper is responsible for endless hours of productivity loss since the 1960s, and there is a reason for that: it’s extremely addictive and very easy to understand.
The rules of the game
- You start with a board of a fixed size, let’s say 10x10, giving you a minefield of 100 cells
- A set amount of cells contain mines
- If you click on a cell that is a mine, it’s the end of the game and you lost
- If you click on a cell that is not a mine, but one or more of it’s neighbours contain a mine the game will show you the count of such cells
- If you click on a cell that is not a mine, nor any of it’s neighbours are a mine, the game will reveal all of the surrounding cells
As you can tell it’s not exactly rocket science to play, nor to implement. It took me about 50 minutes to code and I’m in no way an expert on React Native.
TL;DR: Just want to grab the code? Here it is: https://github.com/lepunk/react-native-videos/tree/master/MineSweeper