Minesweeper in Javascript

minesweeperIn this blog post we will work on the classic game of Minesweeper. Minesweeper is a single-player puzzle video game. The objective of the game is to clear a rectangular board containing hidden “mines” or bombs without detonating any of them, with help from clues about the number of neighbouring mines in each field. The game originates from the 1960s, and has been written for many computing platforms in use today.

We have created a fully working version of the game using HTML, CSS and JavaScript. Your task will be to reverse-engineer the code to be able to improve this game further.

Full Code

See the Pen Minesweeper by 101 Computing (@101Computing) on CodePen.

Your Challenge

Improve this code further to:

  • Calculate and display a score in real time (number of cells that have been visited).
  • Allow the user to add a cross to a cell (by right clicking?) to indicate the position of a mine.
  • Allow the user to choose a difficulty level or change some settings (e.g. Number of mines, size of the grid).
  • Add a timer to the game.

Did you like this challenge?

Click on a star to rate it!

Average rating 4.1 / 5. Vote count: 16

No votes so far! Be the first to rate this post.

As you found this challenge interesting...

Follow us on social media!