MineSweeper in React Native

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.

If you like the video, please subscribe to the channel.

TL;DR: Just want to grab the code? Here it is: https://github.com/lepunk/react-native-videos/tree/master/MineSweeper

Written by

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store