Skip to content

Instantly share code, notes, and snippets.

@lengarvey
Created May 4, 2015 14:16
Show Gist options
  • Save lengarvey/d62bf2df95dc81b8a8fa to your computer and use it in GitHub Desktop.
Save lengarvey/d62bf2df95dc81b8a8fa to your computer and use it in GitHub Desktop.
// init process
Minesweeper.initEvents(); // initialize events. Remember to listen on $(document).on('click', '.cell')
// etc...
Minesweeper.initializeBoard('M'); // create the board of the right size.
Minesweeper.placeMines(); // update Minesweeper.world to update the random cells with mine = true;
Minesweeper.calculateSurroundingMines(); // updates each cell to figure out the number of mines surrounding it.
Minesweeper.render(); // renders the game board.
// the structure of the board in the dom should allow you to figure out which cell is clicked on.
// something like:
// <div class="cell" data-id="1"></div>
//
// every time someone clicks on a cell it updates the cell in MS.world and calls Minesweeper.render();
// which would replace the entire board with new divs for every cell.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment