Skip to content

Instantly share code, notes, and snippets.

View amysimmons's full-sized avatar

Amy Simmons amysimmons

View GitHub Profile
@amysimmons
amysimmons / ms.js
Last active August 29, 2015 14:20 — forked from lengarvey/ms.js
// 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.
// One key thing with programming (particularly for games or similar things)
// is to think about the "data structure" and have this data model separate
// from the logic.
MS = {
initialize: function(boardSize) {
MS.world = new Array(boardSize);
for(var i=0;i<boardSize;i++) {
MS.world[i] = MS.initRow(boardSize);
class FooController
def index
# The controller is responsible for gathering the things needed
# to make the response. This should be a single line of code
@things = Foo.things
# The controller is responsible for sending the view back to the user.
# the view uses our instance variable above to render @things
render :some_view
end