-
Notifications
You must be signed in to change notification settings - Fork 0
/
tetris-bundle.js
43 lines (29 loc) · 26.3 KB
/
tetris-bundle.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
"use strict";function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(exports,"__esModule",{value:!0});var _createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var a=t[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}return function(t,n,a){return n&&e(t.prototype,n),a&&e(t,a),t}}(),_game=require("./game"),_game2=_interopRequireDefault(_game),App=function(){function e(t){_classCallCheck(this,e),this.game_loop=this.start()}return _createClass(e,[{key:"start",value:function(){var e=this;this.game=new _game2.default;var t=function t(){window.requestAnimationFrame(e.game.draw.bind(e.game)),setTimeout(t,e.game.speediness),e.game.go&&e.game.currPiece.moveDown()};if(this.game.init())return setTimeout(t,this.game.speediness);alert("You lack a browser able to run HTML5")}}]),e}();exports.default=App,document.addEventListener("DOMContentLoaded",function(){return new App});
},{"./game":5}],2:[function(require,module,exports){
"use strict";function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(exports,"__esModule",{value:!0});var _createClass=function(){function e(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,r,i){return r&&e(t.prototype,r),i&&e(t,i),t}}(),_constants=require("./constants.js"),_piece=require("./piece.js"),_piece2=_interopRequireDefault(_piece),BorderSq=function(){function e(){_classCallCheck(this,e),this.width=_constants.SQWIDTH,this.color=_constants.CHARCOAL_GRAY,this.sqArray=[],this.ctx=document.querySelector("#mainCanvas").getContext("2d")}return _createClass(e,[{key:"draw",value:function(){this.ctx.fillStyle=this.color,this.ctx.fillRect(this.sqArray[0]*this.width,this.sqArray[1]*this.width,this.width,this.width)}},{key:"setLocation",value:function(e,t){this.sqArray=[e,t]}}]),e}();exports.default=BorderSq;
},{"./constants.js":3,"./piece.js":10}],3:[function(require,module,exports){
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var JKEY=exports.JKEY=74,KKEY=exports.KKEY=75,LKEY=exports.LKEY=76,PKEY=exports.PKEY=80,COMMAKEY=exports.COMMAKEY=188,SPACEBAR=exports.SPACEBAR=32,SQWIDTH=exports.SQWIDTH=20,NUM_PIECE_SQS=exports.NUM_PIECE_SQS=4,SCORE_PANEL_HEIGHT=exports.SCORE_PANEL_HEIGHT=60,DIALOG_WIDTH=exports.DIALOG_WIDTH=300,DIALOG_HEIGHT=exports.DIALOG_HEIGHT=150,DIALOG_X=exports.DIALOG_X=50,DIALOG_Y=exports.DIALOG_Y=175,INITIAL_SPEED=exports.INITIAL_SPEED=1e3,SPEED_UP_AMT=exports.SPEED_UP_AMT=50,TOP_SPEED=exports.TOP_SPEED=100,NORMAL_CLEAR_PTS=exports.NORMAL_CLEAR_PTS=10,NUM_FOR_TETRIS=exports.NUM_FOR_TETRIS=4,TETRIS_CLEAR_PTS=exports.TETRIS_CLEAR_PTS=100,DOUBLE_TETRIS_CLEAR_PTS=exports.DOUBLE_TETRIS_CLEAR_PTS=500,MAGENTA=exports.MAGENTA="#f39",RED=exports.RED="#f33",ORANGE=exports.ORANGE="#f80",GOLD=exports.GOLD="gold",LIME=exports.LIME="#cf0",TEAL=exports.TEAL="#0cc",TURQUOISE=exports.TURQUOISE="turquoise",PURPLE=exports.PURPLE="#b650ff",BLACK=exports.BLACK="#191919",CHARCOAL_GRAY=exports.CHARCOAL_GRAY="#333",NEW_PIECE_X=exports.NEW_PIECE_X=9,NEW_PIECE_Y=exports.NEW_PIECE_Y=1,LARGE_FONT_SIZE=exports.LARGE_FONT_SIZE="30px",MEDIUM_FONT_SIZE=exports.MEDIUM_FONT_SIZE="22px",SMALL_FONT_SIZE=exports.SMALL_FONT_SIZE="14px",FONT_FAMILY=exports.FONT_FAMILY="Avenir, Helvetica, Arial";
},{}],4:[function(require,module,exports){
"use strict";function _classCallCheck(t,s){if(!(t instanceof s))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(exports,"__esModule",{value:!0});var _constants=require("./constants.js"),Dialog=function t(){_classCallCheck(this,t),this.width=_constants.DIALOG_WIDTH,this.height=_constants.DIALOG_HEIGHT,this.x=_constants.DIALOG_X,this.y=_constants.DIALOG_Y,this.color=_constants.RED};exports.default=Dialog;
},{"./constants.js":3}],5:[function(require,module,exports){
"use strict";function _interopRequireDefault(t){return t&&t.__esModule?t:{default:t}}function _classCallCheck(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(exports,"__esModule",{value:!0});var _createClass=function(){function t(t,e){for(var i=0;i<e.length;i++){var s=e[i];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(t,s.key,s)}}return function(e,i,s){return i&&t(e.prototype,i),s&&t(e,s),e}}(),_ipiece=require("./ipiece.js"),_ipiece2=_interopRequireDefault(_ipiece),_jpiece=require("./jpiece.js"),_jpiece2=_interopRequireDefault(_jpiece),_lpiece=require("./lpiece.js"),_lpiece2=_interopRequireDefault(_lpiece),_opiece=require("./opiece.js"),_opiece2=_interopRequireDefault(_opiece),_spiece=require("./spiece.js"),_spiece2=_interopRequireDefault(_spiece),_tpiece=require("./tpiece.js"),_tpiece2=_interopRequireDefault(_tpiece),_zpiece=require("./zpiece.js"),_zpiece2=_interopRequireDefault(_zpiece),_bordersq=require("./bordersq.js"),_bordersq2=_interopRequireDefault(_bordersq),_dialog=require("./dialog.js"),_dialog2=_interopRequireDefault(_dialog),_constants=require("./constants.js"),Game=function(){function t(){_classCallCheck(this,t),this.scoreCounter=0,this.dialog=new _dialog2.default,this.go=!1,this.isLostGame=!1,this.isFreshGame=!0,this.tetris=!1,this.board=[],this.speediness=_constants.INITIAL_SPEED}return _createClass(t,[{key:"init",value:function(){var t=document.querySelector("#mainCanvas"),e=this.board;if(!t.getContext)return!1;this.ctx=t.getContext("2d"),this.panelWidth=t.width,this.gamePanelHeight=t.height-_constants.SCORE_PANEL_HEIGHT,this.rows=this.gamePanelHeight/_constants.SQWIDTH+1,this.cols=this.panelWidth/_constants.SQWIDTH,this.ctx.fillStyle=_constants.BLACK,this.ctx.fillRect(0,0,this.panelWidth,this.gamePanelHeight);for(var i=0;i<this.rows;i++)e[i]=[];for(var s=0;s<this.rows;s++)e[0][s]=new _bordersq2.default,e[0][s].setLocation(0,s),e[this.cols-1][s]=new _bordersq2.default,e[this.cols-1][s].setLocation(this.cols-1,s);for(var o=0;o<this.cols;o++)e[o][0]=new _bordersq2.default,e[o][this.rows-1]=new _bordersq2.default,e[o][0].setLocation(o,0),e[o][this.rows-1].setLocation(o,this.rows-1);return this.currPiece=this.pieceFactory(this),this.currPiece.setLocation(_constants.NEW_PIECE_X,_constants.NEW_PIECE_Y),this.drawBoard(),this.drawWelcomeDialog(),this.setupKeyListeners(),this.setupClickListeners(),!0}},{key:"drawWelcomeDialog",value:function(){this.ctx.fillStyle=this.dialog.color,this.ctx.fillRect(this.dialog.x,this.dialog.y,this.dialog.width,this.dialog.height),this.ctx.fillStyle=_constants.BLACK,this.ctx.font=_constants.MEDIUM_FONT_SIZE+" "+_constants.FONT_FAMILY,this.ctx.fillText("Click to Make it Rain Pieces!",this.dialog.x+10,this.dialog.y+40,280),this.ctx.font=_constants.SMALL_FONT_SIZE+" "+_constants.FONT_FAMILY,this.ctx.fillText("Left = J-Key, Right = L-key",this.dialog.x+35,this.dialog.y+70,230),this.ctx.fillText("Rotate = K-key, Down = Comma-key",this.dialog.x+35,this.dialog.y+90,230),this.ctx.fillText("Drop = Space",this.dialog.x+35,this.dialog.y+110,230),this.ctx.fillText("Pause = P-key",this.dialog.x+35,this.dialog.y+130,230)}},{key:"drawBoard",value:function(){for(var t=this.board,e=0;e<this.rows;e++)for(var i=0;i<this.cols;i++)t[i][e]&&t[i][e].draw();this.ctx.fillStyle=_constants.CHARCOAL_GRAY,this.ctx.fillRect(0,this.gamePanelHeight,this.panelWidth,_constants.SCORE_PANEL_HEIGHT),this.ctx.font=_constants.LARGE_FONT_SIZE+" "+_constants.FONT_FAMILY,this.ctx.fillStyle=_constants.RED,this.ctx.fillText("Score: "+this.scoreCounter,20,this.gamePanelHeight+40,this.panelWidth-20)}},{key:"setupKeyListeners",value:function(){var t=this;document.addEventListener("keydown",function(e){e.keyCode===_constants.JKEY&&t.go&&(e.preventDefault(),t.currPiece.moveLeft()),e.keyCode===_constants.LKEY&&t.go&&(e.preventDefault(),t.currPiece.moveRight()),e.keyCode===_constants.KKEY&&t.go&&(e.preventDefault(),t.currPiece.rotate()),e.keyCode===_constants.COMMAKEY&&t.go&&(e.preventDefault(),t.currPiece.moveDown()),e.keyCode===_constants.SPACEBAR&&t.go&&(e.preventDefault(),t.currPiece.drop()),e.keyCode===_constants.PKEY&&(e.preventDefault(),t.go=!t.go)})}},{key:"setupClickListeners",value:function(){var t=this;mainCanvas.addEventListener("click",function(e){t.isFreshGame&&(t.isFreshGame=!1),t.go||(t.go=!0),t.isLostGame&&(clearInterval(t.game_loop),t.game_loop=start(),t.isLostGame=!1,t.go=!1,t.isFreshGame=!0)})}},{key:"draw",value:function(){if(this.go)this.ctx.fillStyle=_constants.BLACK,this.ctx.fillRect(0,0,this.panelWidth,this.gamePanelHeight),this.drawBoard(),this.currPiece.draw();else if(this.isLostGame||this.isFreshGame){if(this.isLostGame&&!this.isFreshGame)return this.ctx.fillStyle=this.dialog.color,this.ctx.fillRect(this.dialog.x,this.dialog.y,this.dialog.width,this.dialog.height),this.ctx.fillStyle=_constants.BLACK,this.ctx.font=_constants.MEDIUM_FONT_SIZE+" "+_constants.FONT_FAMILY,this.ctx.fillText("Sorry! Game Over :(",this.dialog.x+30,this.dialog.y+70,280),this.ctx.font=_constants.SMALL_FONT_SIZE+" "+_constants.FONT_FAMILY,void this.ctx.fillText("Click to start a new game.",this.dialog.x+55,this.dialog.y+95,230)}else this.ctx.fillStyle=this.dialog.color,this.ctx.fillRect(this.dialog.x,this.dialog.y,this.dialog.width,this.dialog.height),this.ctx.fillStyle=_constants.BLACK,this.ctx.font=_constants.MEDIUM_FONT_SIZE+" "+_constants.FONT_FAMILY,this.ctx.fillText("Game Paused.",this.dialog.x+65,this.dialog.y+80,280)}},{key:"pieceFactory",value:function(t){switch(Math.floor(7*Math.random())){case 0:return new _ipiece2.default(t);case 1:return new _jpiece2.default(t);case 2:return new _lpiece2.default(t);case 3:return new _opiece2.default(t);case 4:return new _spiece2.default(t);case 5:return new _tpiece2.default(t);case 6:return new _zpiece2.default(t)}}},{key:"makeNewPiece",value:function(){this.currPiece=this.pieceFactory(this),this.isLostGame||this.currPiece.setLocation(_constants.NEW_PIECE_X,_constants.NEW_PIECE_Y)}},{key:"checkLines",value:function(){for(var t=this.board,e=0,i=1;i<this.rows-1;i++){for(var s=0,o=1;o<this.cols-1&&t[o][i];o++)s++;if(s===this.cols-2){e++;for(var a=i;a>2;a--)for(var n=1;n<this.cols-1;n++)t[n][a]=t[n][a-1],t[n][a]&&(t[n][a].setLocation(n,a),this.draw());this.speediness>_constants.TOP_SPEED&&(this.speediness=this.speediness-_constants.SPEED_UP_AMT),this.scoreCounter=this.scoreCounter+_constants.NORMAL_CLEAR_PTS,e!==_constants.NUM_FOR_TETRIS||this.tetris?e===_constants.NUM_FOR_TETRIS&&this.tetris?this.scoreCounter=this.scoreCounter+_constants.DOUBLE_TETRIS_CLEAR_PTS:this.tetris=!1:(this.scoreCounter=this.scoreCounter+_constants.TETRIS_CLEAR_PTS,this.tetris=!0)}}}},{key:"checkLoss",value:function(){for(var t=0;t<_constants.NUM_PIECE_SQS;t++)this.board[this.currPiece.sqArray[t][0]][this.currPiece.sqArray[t][1]]&&(this.go=!1,this.isLostGame=!0,this.draw())}}]),t}();exports.default=Game;
},{"./bordersq.js":2,"./constants.js":3,"./dialog.js":4,"./ipiece.js":6,"./jpiece.js":7,"./lpiece.js":8,"./opiece.js":9,"./spiece.js":11,"./tpiece.js":13,"./zpiece.js":14}],6:[function(require,module,exports){
"use strict";function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _possibleConstructorReturn(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function _inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(exports,"__esModule",{value:!0});var _constants=require("./constants.js"),_piece=require("./piece.js"),_piece2=_interopRequireDefault(_piece),IPiece=function(e){function t(e){_classCallCheck(this,t);var r=_possibleConstructorReturn(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return r.color=_constants.RED,r.sqArray[0][0]=0,r.sqArray[0][1]=0,r.sqArray[1][0]=1,r.sqArray[1][1]=0,r.sqArray[2][0]=2,r.sqArray[2][1]=0,r.sqArray[3][0]=3,r.sqArray[3][1]=0,r.cloneSqArrayToLayoutArray(),r}return _inherits(t,e),t}(_piece2.default);exports.default=IPiece;
},{"./constants.js":3,"./piece.js":10}],7:[function(require,module,exports){
"use strict";function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _possibleConstructorReturn(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function _inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(exports,"__esModule",{value:!0});var _constants=require("./constants.js"),_piece=require("./piece.js"),_piece2=_interopRequireDefault(_piece),JPiece=function(e){function t(e){_classCallCheck(this,t);var r=_possibleConstructorReturn(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return r.color=_constants.GOLD,r.sqArray[0][0]=0,r.sqArray[0][1]=0,r.sqArray[1][0]=1,r.sqArray[1][1]=0,r.sqArray[2][0]=2,r.sqArray[2][1]=0,r.sqArray[3][0]=2,r.sqArray[3][1]=1,r.cloneSqArrayToLayoutArray(),r}return _inherits(t,e),t}(_piece2.default);exports.default=JPiece;
},{"./constants.js":3,"./piece.js":10}],8:[function(require,module,exports){
"use strict";function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _possibleConstructorReturn(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function _inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(exports,"__esModule",{value:!0});var _constants=require("./constants.js"),_piece=require("./piece.js"),_piece2=_interopRequireDefault(_piece),LPiece=function(e){function t(e){_classCallCheck(this,t);var r=_possibleConstructorReturn(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return r.color=_constants.MAGENTA,r.sqArray[0][0]=0,r.sqArray[0][1]=0,r.sqArray[1][0]=1,r.sqArray[1][1]=0,r.sqArray[2][0]=2,r.sqArray[2][1]=0,r.sqArray[3][0]=0,r.sqArray[3][1]=1,r.cloneSqArrayToLayoutArray(),r}return _inherits(t,e),t}(_piece2.default);exports.default=LPiece;
},{"./constants.js":3,"./piece.js":10}],9:[function(require,module,exports){
"use strict";function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _possibleConstructorReturn(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function _inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(exports,"__esModule",{value:!0});var _constants=require("./constants.js"),_piece=require("./piece.js"),_piece2=_interopRequireDefault(_piece),OPiece=function(e){function t(e){_classCallCheck(this,t);var r=_possibleConstructorReturn(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return r.color=_constants.PURPLE,r.sqArray[0][0]=0,r.sqArray[0][1]=0,r.sqArray[1][0]=1,r.sqArray[1][1]=0,r.sqArray[2][0]=0,r.sqArray[2][1]=1,r.sqArray[3][0]=1,r.sqArray[3][1]=1,r.cloneSqArrayToLayoutArray(),r}return _inherits(t,e),t}(_piece2.default);exports.default=OPiece;
},{"./constants.js":3,"./piece.js":10}],10:[function(require,module,exports){
"use strict";function _interopRequireDefault(r){return r&&r.__esModule?r:{default:r}}function _classCallCheck(r,t){if(!(r instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(exports,"__esModule",{value:!0});var _createClass=function(){function r(r,t){for(var s=0;s<t.length;s++){var a=t[s];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(r,a.key,a)}}return function(t,s,a){return s&&r(t.prototype,s),a&&r(t,a),t}}(),_constants=require("./constants.js"),_stuckSquare=require("./stuckSquare.js"),_stuckSquare2=_interopRequireDefault(_stuckSquare),Piece=function(){function r(t){_classCallCheck(this,r),this.width=_constants.SQWIDTH,this.game=t,this.sqArray=[[],[],[],[]],this.layoutArray=[],this.color=_constants.CHARCOAL_GRAY,this.ctx=document.querySelector("#mainCanvas").getContext("2d")}return _createClass(r,[{key:"cloneSqArrayToLayoutArray",value:function(){this.layoutArray=JSON.parse(JSON.stringify(this.sqArray))}},{key:"draw",value:function(){this.ctx.strokeStyle=_constants.BLACK,this.ctx.lineWidth=2,this.ctx.fillStyle=this.color;for(var r=this.width,t=0;t<_constants.NUM_PIECE_SQS;t++)this.ctx.fillRect(this.sqArray[t][0]*r,this.sqArray[t][1]*r,r,r),this.ctx.strokeRect(this.sqArray[t][0]*r,this.sqArray[t][1]*r,r,r)}},{key:"checkValidDown",value:function(){for(var r=0;r<_constants.NUM_PIECE_SQS;r++)if(this.game.board[this.sqArray[r][0]][this.sqArray[r][1]+1])return!1;return!0}},{key:"checkValidLeft",value:function(){for(var r=0;r<_constants.NUM_PIECE_SQS;r++)if(this.game.board[this.sqArray[r][0]-1][this.sqArray[r][1]])return!1;return!0}},{key:"checkValidRight",value:function(){for(var r=0;r<_constants.NUM_PIECE_SQS;r++)if(this.game.board[this.sqArray[r][0]+1][this.sqArray[r][1]])return!1;return!0}},{key:"checkValidRotate",value:function(){return!this.game.board[this.sqArray[2][0]-this.sqArray[2][1]+this.sqArray[0][1]][this.sqArray[2][0]+this.sqArray[2][1]-this.sqArray[0][0]]&&!this.game.board[this.sqArray[2][0]-this.sqArray[2][1]+this.sqArray[1][1]][this.sqArray[2][0]+this.sqArray[2][1]-this.sqArray[1][0]]&&!this.game.board[this.sqArray[2][0]-this.sqArray[2][1]+this.sqArray[3][1]][this.sqArray[2][0]+this.sqArray[2][1]-this.sqArray[3][0]]}},{key:"moveDown",value:function(r){if(this.checkValidDown())for(var t=0;t<_constants.NUM_PIECE_SQS;t++)this.sqArray[t][1]++;else this.stick();this.game.draw(),this.game.checkLoss(),this.game.checkLines()}},{key:"moveLeft",value:function(){if(this.checkValidLeft())for(var r=0;r<_constants.NUM_PIECE_SQS;r++)this.sqArray[r][0]--;window.requestAnimationFrame(this.game.draw.bind(this.game))}},{key:"moveRight",value:function(){if(this.checkValidRight())for(var r=0;r<_constants.NUM_PIECE_SQS;r++)this.sqArray[r][0]++;window.requestAnimationFrame(this.game.draw.bind(this.game))}},{key:"drop",value:function(){for(;this.checkValidDown();)this.moveDown();window.requestAnimationFrame(this.game.draw.bind(this.game))}},{key:"rotate",value:function(){if(this.checkValidRotate()){var r=this.sqArray[0][0],t=this.sqArray[0][1],s=this.sqArray[1][0],a=this.sqArray[1][1],i=this.sqArray[3][0],e=this.sqArray[3][1];this.sqArray[0][0]=this.sqArray[2][0]-this.sqArray[2][1]+t,this.sqArray[0][1]=this.sqArray[2][0]+this.sqArray[2][1]-r,this.sqArray[1][0]=this.sqArray[2][0]-this.sqArray[2][1]+a,this.sqArray[1][1]=this.sqArray[2][0]+this.sqArray[2][1]-s,this.sqArray[3][0]=this.sqArray[2][0]-this.sqArray[2][1]+e,this.sqArray[3][1]=this.sqArray[2][0]+this.sqArray[2][1]-i}window.requestAnimationFrame(this.game.draw.bind(this.game))}},{key:"setLocation",value:function(r,t){for(var s=0;s<_constants.NUM_PIECE_SQS;s++)this.sqArray[s][0]=this.layoutArray[s][0]+r,this.sqArray[s][1]=this.layoutArray[s][1]+t;window.requestAnimationFrame(this.game.draw.bind(this.game))}},{key:"stick",value:function(){for(var r=0;r<_constants.NUM_PIECE_SQS;r++)this.game.board[this.sqArray[r][0]][this.sqArray[r][1]]=new _stuckSquare2.default(this.color),this.game.board[this.sqArray[r][0]][this.sqArray[r][1]].setLocation(this.sqArray[r][0],this.sqArray[r][1]);this.game.makeNewPiece()}}]),r}();exports.default=Piece;
},{"./constants.js":3,"./stuckSquare.js":12}],11:[function(require,module,exports){
"use strict";function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _possibleConstructorReturn(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function _inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(exports,"__esModule",{value:!0});var _constants=require("./constants.js"),_piece=require("./piece.js"),_piece2=_interopRequireDefault(_piece),SPiece=function(e){function t(e){_classCallCheck(this,t);var r=_possibleConstructorReturn(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return r.color=_constants.LIME,r.sqArray[0][0]=1,r.sqArray[0][1]=0,r.sqArray[1][0]=2,r.sqArray[1][1]=0,r.sqArray[2][0]=0,r.sqArray[2][1]=1,r.sqArray[3][0]=1,r.sqArray[3][1]=1,r.cloneSqArrayToLayoutArray(),r}return _inherits(t,e),t}(_piece2.default);exports.default=SPiece;
},{"./constants.js":3,"./piece.js":10}],12:[function(require,module,exports){
"use strict";function _interopRequireDefault(t){return t&&t.__esModule?t:{default:t}}function _classCallCheck(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(exports,"__esModule",{value:!0});var _createClass=function(){function t(t,e){for(var i=0;i<e.length;i++){var s=e[i];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(t,s.key,s)}}return function(e,i,s){return i&&t(e.prototype,i),s&&t(e,s),e}}(),_constants=require("./constants.js"),_piece=require("./piece.js"),_piece2=_interopRequireDefault(_piece),StuckSquare=function(){function t(e){_classCallCheck(this,t),this.width=_constants.SQWIDTH,this.color=e,this.sqArray=[],this.ctx=document.querySelector("#mainCanvas").getContext("2d")}return _createClass(t,[{key:"draw",value:function(){this.ctx.fillStyle=this.color,this.ctx.strokeStyle=_constants.BLACK,this.ctx.lineWidth=2,this.ctx.fillRect(this.sqArray[0]*this.width,this.sqArray[1]*this.width,this.width,this.width),this.ctx.strokeRect(this.sqArray[0]*this.width,this.sqArray[1]*this.width,this.width,this.width)}},{key:"setLocation",value:function(t,e){this.sqArray=[t,e]}}]),t}();exports.default=StuckSquare;
},{"./constants.js":3,"./piece.js":10}],13:[function(require,module,exports){
"use strict";function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _possibleConstructorReturn(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function _inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(exports,"__esModule",{value:!0});var _constants=require("./constants.js"),_piece=require("./piece.js"),_piece2=_interopRequireDefault(_piece),TPiece=function(e){function t(e){_classCallCheck(this,t);var r=_possibleConstructorReturn(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return r.color=_constants.TURQUOISE,r.sqArray[0][0]=0,r.sqArray[0][1]=0,r.sqArray[1][0]=1,r.sqArray[1][1]=0,r.sqArray[2][0]=2,r.sqArray[2][1]=0,r.sqArray[3][0]=1,r.sqArray[3][1]=1,r.cloneSqArrayToLayoutArray(),r}return _inherits(t,e),t}(_piece2.default);exports.default=TPiece;
},{"./constants.js":3,"./piece.js":10}],14:[function(require,module,exports){
"use strict";function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _possibleConstructorReturn(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function _inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(exports,"__esModule",{value:!0});var _constants=require("./constants.js"),_piece=require("./piece.js"),_piece2=_interopRequireDefault(_piece),ZPiece=function(e){function t(e){_classCallCheck(this,t);var r=_possibleConstructorReturn(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return r.color=_constants.ORANGE,r.sqArray[0][0]=0,r.sqArray[0][1]=0,r.sqArray[1][0]=1,r.sqArray[1][1]=0,r.sqArray[2][0]=1,r.sqArray[2][1]=1,r.sqArray[3][0]=2,r.sqArray[3][1]=1,r.cloneSqArrayToLayoutArray(),r}return _inherits(t,e),t}(_piece2.default);exports.default=ZPiece;
},{"./constants.js":3,"./piece.js":10}]},{},[1]);