/JSMinesweeper

Just another Minesweeper implementation in JavaScript.

Primary LanguageJavaScriptMIT LicenseMIT

JSMinesweeper

I was bored. So I scribbled Minesweeper in JavaScript while there are already more than enough implementations. Has everything but highscores because who needs highscores.

See a live demo here.

Usage

<script>
  var options = {
    width: 20,
    height: 30
  };
  var minesweeper = new Minesweeper(options);
</script>

You can pass options as a JavaScript object, if you like:

  • width: number of cells per row (default: 30, minimum: 10)
  • height: number of cells per column (default: 16, minimum: 10)
  • numMines: number of mines to hide on the board (default: 18% of cell total)
  • cellSize: width and height of cells in pixels (default: 30)
  • canvas: pass a HTML5 canvas element as reference (default: automatically creates a new element)
  • spritePath: path to a custom sprite. see code and example for layout.

Disclaimer

Uses OpenSans.