From 10338ccfea0a66189835a95eebe1fe4de8e15ae6 Mon Sep 17 00:00:00 2001 From: albertliangcode Date: Sun, 4 Jan 2015 20:10:04 -0800 Subject: [PATCH 1/2] Adjustable Game Board HTML dimensions --- AlbertMineSweeper.script.js | 8 ++++++- ams_board.css | 3 --- bower.json | 27 ++++++++++++++++++++++++ index.html | 42 ++----------------------------------- ui.js | 2 +- 5 files changed, 37 insertions(+), 45 deletions(-) create mode 100644 bower.json diff --git a/AlbertMineSweeper.script.js b/AlbertMineSweeper.script.js index 3877826..7803b47 100644 --- a/AlbertMineSweeper.script.js +++ b/AlbertMineSweeper.script.js @@ -37,10 +37,16 @@ function Grid(numRow, numCol, numMines) { this.cells = []; for(var i = 0; i < this.numRow; i++) { this.cells[i] = []; + $(".base").append("
"); for(var j = 0; j < this.numCol; j++) { this.cells[i][j] = new Cell(); + $("#row"+i.toString()).append("
"); } - } + } + // Adjust Dimensions of Base + var edgeThickness = 2 * (parseInt($(".cell").css("border-left-width")) + parseInt($(".cell").css("margin")) + parseInt($(".cell").css("padding"))); + $(".base").height(numRow * ($(".cell").height() + edgeThickness) + 10); + $(".base").width(numCol * ($(".cell").width() + edgeThickness) + 10); // Seed mines randomly in grid, adds them to minedCells[] and calculate each cell's risk for(var c = 0; c < numMines; c++) { diff --git a/ams_board.css b/ams_board.css index 1eaa956..a1dfc88 100644 --- a/ams_board.css +++ b/ams_board.css @@ -4,9 +4,6 @@ div { .base { background-color: gray; - height: 410px; - width: 410px; - /*for a 15*15 grid.*/ } .cell { diff --git a/bower.json b/bower.json new file mode 100644 index 0000000..22e6353 --- /dev/null +++ b/bower.json @@ -0,0 +1,27 @@ +{ + "name": "AlbertMineSweeper", + "version": "0.0.0", + "homepage": "https://github.com/albertliangcode/AlbertMineSweeper", + "authors": [ + "albertliangcode " + ], + "moduleType": [ + "amd", + "es6", + "globals", + "node", + "yui" + ], + "license": "MIT", + "private": true, + "ignore": [ + "**/.*", + "node_modules", + "bower_components", + "test", + "tests" + ], + "dependencies": { + "jquery": "~2.1.3" + } +} diff --git a/index.html b/index.html index 10628ed..2247bd4 100644 --- a/index.html +++ b/index.html @@ -11,14 +11,14 @@

Albert Mine Sweeper

Project Status:

    -
  • Current: End Conditions
  • -
  • Next: Adjustable Game
  • +
  • Current: Adjustable GameBoard
  • Next: User Interface for:
    1. Resetting Game
    2. Adjusting Game Settings
  • +
  • Next: End Conditions (UI Freeze)
  • Next: Clock
  • Next: Scoreboard?
  • Next: Match Graphics to MS Minesweeper?
  • @@ -33,44 +33,6 @@

    Project Status:

-
- -
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/ui.js b/ui.js index 27cd7d4..936e9a7 100644 --- a/ui.js +++ b/ui.js @@ -27,7 +27,7 @@ var stopGame = function () { $(document).ready(function() { //Must bind contextmenu event handler to each cell //document.oncontextmenu = function() {return false;}; - var grid = new Grid(5,5,2); + var grid = new Grid(7,7,5); var report = grid.print(); $('.cell').mousedown(function(event) { From 651262740ad259e26112d8d2e344b6f9d8ce9ddd Mon Sep 17 00:00:00 2001 From: albertliangcode Date: Sun, 4 Jan 2015 21:57:58 -0800 Subject: [PATCH 2/2] Attempt to set board dimensions with Form program quits after line 35, ui.js --- index.html | 9 +++++++++ ui.js | 14 +++++++++----- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/index.html b/index.html index 2247bd4..6acaca4 100644 --- a/index.html +++ b/index.html @@ -18,6 +18,7 @@

Project Status:

  • Adjusting Game Settings
  • +
  • Next: No First-Click Deaths
  • Next: End Conditions (UI Freeze)
  • Next: Clock
  • Next: Scoreboard?
  • @@ -32,6 +33,14 @@

    Project Status:

    + + +
    + Rows:
    + Columns:
    + Mines:

    +


    +
    diff --git a/ui.js b/ui.js index 936e9a7..ed6dc12 100644 --- a/ui.js +++ b/ui.js @@ -25,11 +25,15 @@ var stopGame = function () { $(document).ready(function() { - //Must bind contextmenu event handler to each cell - //document.oncontextmenu = function() {return false;}; - var grid = new Grid(7,7,5); - var report = grid.print(); - + var grid; + var report; + $('#gridSetup').submit(function(){ + var $values = $('#gridSetup').serializeArray(); + grid = new Grid(parseInt($values[0].value),parseInt($values[1].value),parseInt($values[2].value)); + // var grid = new Grid(7,7,5); + report = grid.print(); + }); // <<>> + $('.cell').mousedown(function(event) { var row = $(this).data('row'); var col = $(this).data('col');