diff --git a/LICENSE.md b/LICENSE.md index 16d89e0..7af3c57 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -553,31 +553,31 @@ to the start of each source file to most effectively state the exclusion of warr and each file should have at least the “copyright” line and a pointer to where the full notice is found. - - Copyright (C) + + Copyright (C) - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. - You should have received a copy of the GNU General Public License - along with this program. If not, see . + You should have received a copy of the GNU General Public License + along with this program. If not, see . Also add information on how to contact you by electronic and paper mail. If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: - Copyright (C) - This program comes with ABSOLUTELY NO WARRANTY; for details type 'show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type 'show c' for details. + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type 'show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type 'show c' for details. The hypothetical commands 'show w' and 'show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; diff --git a/images/btn_back.svg b/images/btn_back.svg index 97db82e..b0f77f0 100644 --- a/images/btn_back.svg +++ b/images/btn_back.svg @@ -1,15 +1,15 @@ - - Back button - Created with Sketch. - - - - - - - - - + + Back button + Created with Sketch. + + + + + + + + + \ No newline at end of file diff --git a/images/btn_facebook.svg b/images/btn_facebook.svg index 42421cc..7e68661 100644 --- a/images/btn_facebook.svg +++ b/images/btn_facebook.svg @@ -1,19 +1,19 @@ - - Facebook - Created with Sketch. - - - - - - - - - - - - - + + Facebook + Created with Sketch. + + + + + + + + + + + + + \ No newline at end of file diff --git a/images/btn_help.svg b/images/btn_help.svg index 6859881..26a452f 100644 --- a/images/btn_help.svg +++ b/images/btn_help.svg @@ -1,17 +1,17 @@ - - Help - Created with Sketch. - - - - - - - - - - - + + Help + Created with Sketch. + + + + + + + + + + + \ No newline at end of file diff --git a/images/btn_pause.svg b/images/btn_pause.svg index 08d6e56..dd9470a 100644 --- a/images/btn_pause.svg +++ b/images/btn_pause.svg @@ -1,15 +1,15 @@ - - Pause button - Created with Sketch. - - - - - - - - - + + Pause button + Created with Sketch. + + + + + + + + + \ No newline at end of file diff --git a/images/btn_restart.svg b/images/btn_restart.svg index 0c5246a..efc6b01 100644 --- a/images/btn_restart.svg +++ b/images/btn_restart.svg @@ -1,15 +1,15 @@ - - Restart button - Created with Sketch. - - - - - - - - - + + Restart button + Created with Sketch. + + + + + + + + + \ No newline at end of file diff --git a/images/btn_resume.svg b/images/btn_resume.svg index bb963f2..2fdb66e 100644 --- a/images/btn_resume.svg +++ b/images/btn_resume.svg @@ -1,15 +1,15 @@ - - Resume button - Created with Sketch. - - - - - - - - - + + Resume button + Created with Sketch. + + + + + + + + + \ No newline at end of file diff --git a/images/btn_share.svg b/images/btn_share.svg index 9607e85..72ff6ae 100644 --- a/images/btn_share.svg +++ b/images/btn_share.svg @@ -1,17 +1,17 @@ - - Share button - Created with Sketch. - - - - - - - SHARE MY SCORE! - - - - + + Share button + Created with Sketch. + + + + + + + SHARE MY SCORE! + + + + \ No newline at end of file diff --git a/images/btn_twitter.svg b/images/btn_twitter.svg index 868cfab..96db720 100644 --- a/images/btn_twitter.svg +++ b/images/btn_twitter.svg @@ -1,19 +1,19 @@ - - Twitter - Created with Sketch. - - - - - - - - - - - - - + + Twitter + Created with Sketch. + + + + + + + + + + + + + \ No newline at end of file diff --git a/images/icon_arrows.svg b/images/icon_arrows.svg index 11d6530..88341d8 100644 --- a/images/icon_arrows.svg +++ b/images/icon_arrows.svg @@ -1,14 +1,14 @@ - - Arrows icon - Created with Sketch. - - - - - - - - + + Arrows icon + Created with Sketch. + + + + + + + + \ No newline at end of file diff --git a/index.html b/index.html index f85d8fc..97375de 100644 --- a/index.html +++ b/index.html @@ -73,8 +73,8 @@
@@ -97,5 +97,5 @@ Fork me on GitHub - + diff --git a/js_v9/Block.js b/js_v9/Block.js index c710f31..a7f21c9 100644 --- a/js_v9/Block.js +++ b/js_v9/Block.js @@ -5,7 +5,7 @@ function Block(fallingLane, color, iter, distFromHex, settled) { //the lane which the block was shot from this.fallingLane = fallingLane; - this.checked=0; + this.checked=0; //the angle at which the block falls this.angle = 90 - (30 + 60 * fallingLane); //for calculating the rotation of blocks attached to the center hex @@ -92,7 +92,7 @@ function Block(fallingLane, color, iter, distFromHex, settled) { else { this.angle += this.angularVelocity; } - + this.width = 2 * this.distFromHex / Math.sqrt(3); this.widthWide = 2 * (this.distFromHex + this.height) / Math.sqrt(3); //this.widthWide = this.width + this.height + 3; diff --git a/js_v9/Hex.js b/js_v9/Hex.js index 9a52e87..64f917b 100644 --- a/js_v9/Hex.js +++ b/js_v9/Hex.js @@ -17,10 +17,10 @@ function Hex(sideLength) { this.y = trueCanvas.height / 2; this.ct = 0; this.lastCombo = this.ct - settings.comboTime; - this.lastColorScored = "#000"; + this.lastColorScored = "#000"; this.comboTime = 1; this.texts = []; - this.lastRotate = Date.now(); + this.lastRotate = Date.now(); for (var i = 0; i < this.sides; i++) { this.blocks.push([]); } @@ -53,7 +53,7 @@ function Hex(sideLength) { block.distFromHex = MainHex.sideLength / 2 * Math.sqrt(3) + block.height * this.blocks[lane].length; this.blocks[lane].push(block); block.attachedLane = lane; - block.checked = 1; + block.checked = 1; }; this.doesBlockCollide = function(block, position, tArr) { @@ -67,7 +67,7 @@ function Hex(sideLength) { if (block.distFromHex - block.iter * this.dt * settings.scale - (this.sideLength / 2) * Math.sqrt(3) <= 0) { block.distFromHex = (this.sideLength / 2) * Math.sqrt(3); block.settled = 1; - block.checked = 1; + block.checked = 1; } else { block.settled = 0; block.iter = 1.5 + (waveone.difficulty/15) * 3; @@ -105,7 +105,7 @@ function Hex(sideLength) { }; this.rotate = function(steps) { - if(Date.now()-this.lastRotate<75 && !(/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) ) return; + if(Date.now()-this.lastRotate<75 && !(/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) ) return; if (!(gameState === 1 || gameState === 0)) return; this.position += steps; if (!history[this.ct]) { @@ -131,7 +131,7 @@ function Hex(sideLength) { }); this.targetAngle = this.targetAngle - steps * 60; - this.lastRotate = Date.now(); + this.lastRotate = Date.now(); }; this.draw = function() { @@ -166,5 +166,5 @@ function Hex(sideLength) { } function arrayToColor(arr){ - return 'rgb(' + arr[0]+ ','+arr[1]+','+arr[2]+')'; + return 'rgb(' + arr[0]+ ','+arr[1]+','+arr[2]+')'; } diff --git a/js_v9/checking.js b/js_v9/checking.js index b405b2a..8000137 100644 --- a/js_v9/checking.js +++ b/js_v9/checking.js @@ -79,6 +79,6 @@ function consolidateBlocks(hex,side,index){ } var adder = deleting.length * deleting.length * hex.comboMultiplier; hex.texts.push(new Text(hex.x,hex.y,"+ "+adder.toString(),"bold Q ",deletedBlocks[0].color,fadeUpAndOut)); - hex.lastColorScored = deletedBlocks[0].color; + hex.lastColorScored = deletedBlocks[0].color; score += adder; } diff --git a/js_v9/comboTimer.js b/js_v9/comboTimer.js index 56ec7a9..b514906 100644 --- a/js_v9/comboTimer.js +++ b/js_v9/comboTimer.js @@ -1,13 +1,13 @@ function drawTimer() { if(gameState==1){ - var leftVertexes = []; - var rightVertexes = []; + var leftVertexes = []; + var rightVertexes = []; if(MainHex.ct - MainHex.lastCombo < settings.comboTime){ for(var i=0;i<6;i++){ var done = (MainHex.ct -MainHex.lastCombo); if(done<(settings.comboTime)*(5-i)*(1/6)){ leftVertexes.push(calcSide(i,i+1,1,1)); - rightVertexes.push(calcSide(12-i,11-i,1,1)); + rightVertexes.push(calcSide(12-i,11-i,1,1)); } else{ leftVertexes.push(calcSide(i,i+1,1-((done*6)/settings.comboTime)%(1),1)); @@ -16,8 +16,8 @@ function drawTimer() { } } } - if(rightVertexes.length !== 0) drawSide(rightVertexes); - if(leftVertexes.length !== 0) drawSide(leftVertexes); + if(rightVertexes.length !== 0) drawSide(rightVertexes); + if(leftVertexes.length !== 0) drawSide(leftVertexes); } } @@ -49,7 +49,7 @@ function calcSide(startVertex,endVertex,fraction,offset){ var startY =trueCanvas.height/2 + Vertexes[startVertex][1]; var endX = trueCanvas.width/2 + Vertexes[endVertex][0]; var endY = trueCanvas.height/2 + Vertexes[endVertex][1]; - return [[startX,startY],[((endX-startX)*fraction)+startX,((endY-startY)*fraction)+startY]]; + return [[startX,startY],[((endX-startX)*fraction)+startX,((endY-startY)*fraction)+startY]]; } function drawSide(vertexes){ if (gameState === 0) { @@ -58,12 +58,12 @@ function drawSide(vertexes){ ctx.strokeStyle = MainHex.lastColorScored; } ctx.lineWidth =4*settings.scale; - ctx.moveTo(vertexes[0][0][0],vertexes[0][0][1]); + ctx.moveTo(vertexes[0][0][0],vertexes[0][0][1]); ctx.lineTo(vertexes[0][1][0],vertexes[0][1][1]); - for(var i=1;i
" + (settings.platform != 'mobile' ? 'Press the right and left arrow keys' : 'tap the left and right sides of the screen') + " to rotate the Hexagon

Clear blocks and get points by making 3 or more blocks of the same color touch

Time left before your combo streak disappears is indicated shown by the colored lines in the outer hexagon

" + (settings.platform == 'mobile' ? 'Toggle speeding up the game by tapping the inner hexagon' : "Speed up the game 2x by holding the down arrow")); - } - if(/Android/i.test(navigator.userAgent)) { - settings.os = "android"; - } + $("#inst_main_body").html("The goal of Hextris is to stop blocks from leaving the inside of the outer gray hexagon

" + (settings.platform != 'mobile' ? 'Press the right and left arrow keys' : 'tap the left and right sides of the screen') + " to rotate the Hexagon

Clear blocks and get points by making 3 or more blocks of the same color touch

Time left before your combo streak disappears is indicated shown by the colored lines in the outer hexagon

" + (settings.platform == 'mobile' ? 'Toggle speeding up the game by tapping the inner hexagon' : "Speed up the game 2x by holding the down arrow")); + } + if(/Android/i.test(navigator.userAgent)) { + settings.os = "android"; + } - if(navigator.userAgent.match(/iPhone/i) || navigator.userAgent.match(/iPad/i) || navigator.userAgent.match(/iPod/i)){ - settings.os="ios"; - } + if(navigator.userAgent.match(/iPhone/i) || navigator.userAgent.match(/iPad/i) || navigator.userAgent.match(/iPod/i)){ + settings.os="ios"; + } - window.canvas = document.getElementById('canvas'); - window.ctx = canvas.getContext('2d'); - window.trueCanvas = { - width: canvas.width, - height: canvas.height - }; - scaleCanvas(); + window.canvas = document.getElementById('canvas'); + window.ctx = canvas.getContext('2d'); + window.trueCanvas = { + width: canvas.width, + height: canvas.height + }; + scaleCanvas(); - window.framerate = 60; - window.history = {}; - window.score = 0; - window.isGameOver = 3; - window.scoreAdditionCoeff = 1; - window.prevScore = 0; - window.numHighScores = 3; + window.framerate = 60; + window.history = {}; + window.score = 0; + window.isGameOver = 3; + window.scoreAdditionCoeff = 1; + window.prevScore = 0; + window.numHighScores = 3; - highscores = []; - if (localStorage.getItem('highscores')) { - try { - highscores = JSON.parse(localStorage.getItem('highscores')); - } catch (e) { - highscores = []; - } - } + highscores = []; + if (localStorage.getItem('highscores')) { + try { + highscores = JSON.parse(localStorage.getItem('highscores')); + } catch (e) { + highscores = []; + } + } - window.blocks = []; - window.MainHex; + window.blocks = []; + window.MainHex; - window.gdx = 0; - window.gdy = 0; + window.gdx = 0; + window.gdy = 0; - window.devMode = 0; - window.lastGen = undefined; - window.prevTimeScored = undefined; - window.nextGen = undefined; - window.spawnLane = 0; - window.importing = 0; - window.importedHistory = undefined; - window.startTime = undefined; + window.devMode = 0; + window.lastGen = undefined; + window.prevTimeScored = undefined; + window.nextGen = undefined; + window.spawnLane = 0; + window.importing = 0; + window.importedHistory = undefined; + window.startTime = undefined; - window.gameState; - setStartScreen(); + window.gameState; + setStartScreen(); - if (a != 1) { - window.canRestart = 1; - window.onblur = function(e) { - if (gameState == 1) { - pause(); - } - }; + if (a != 1) { + window.canRestart = 1; + window.onblur = function(e) { + if (gameState == 1) { + pause(); + } + }; - $('#startBtn').off(); + $('#startBtn').off(); - if (settings.platform == 'mobile') { - $('#startBtn').on('touchstart', startBtnHandler); - } else { - $('#startBtn').on('mousedown', startBtnHandler); - } + if (settings.platform == 'mobile') { + $('#startBtn').on('touchstart', startBtnHandler); + } else { + $('#startBtn').on('mousedown', startBtnHandler); + } - document.addEventListener('touchmove', function(e) { - e.preventDefault(); - }, false); - $(window).resize(scaleCanvas); - $(window).unload(function() { + document.addEventListener('touchmove', function(e) { + e.preventDefault(); + }, false); + $(window).resize(scaleCanvas); + $(window).unload(function() { - if (gameState == 1 || gameState == -1 || gameState === 0) localStorage.setItem("saveState", exportSaveState()); - else localStorage.setItem("saveState", "{}"); - }); + if (gameState == 1 || gameState == -1 || gameState === 0) localStorage.setItem("saveState", exportSaveState()); + else localStorage.setItem("saveState", "{}"); + }); - addKeyListeners(); - (function(i, s, o, g, r, a, m) { - i['GoogleAnalyticsObject'] = r; - i[r] = i[r] || function() { - (i[r].q = i[r].q || []).push(arguments) - }, i[r].l = 1 * new Date(); - a = s.createElement(o), m = s.getElementsByTagName(o)[0]; - a.async = 1; - a.src = g; - m.parentNode.insertBefore(a, m) - })(window, document, 'script', '//www.google-analytics.com/analytics.js', 'ga'); - ga('create', 'UA-51272720-1', 'teamsnowman.github.io'); - ga('send', 'pageview'); + addKeyListeners(); + (function(i, s, o, g, r, a, m) { + i['GoogleAnalyticsObject'] = r; + i[r] = i[r] || function() { + (i[r].q = i[r].q || []).push(arguments) + }, i[r].l = 1 * new Date(); + a = s.createElement(o), m = s.getElementsByTagName(o)[0]; + a.async = 1; + a.src = g; + m.parentNode.insertBefore(a, m) + })(window, document, 'script', '//www.google-analytics.com/analytics.js', 'ga'); + ga('create', 'UA-51272720-1', 'teamsnowman.github.io'); + ga('send', 'pageview'); - document.addEventListener("pause", handlePause, false); - document.addEventListener("backbutton", handlePause, false); - document.addEventListener("menubutton", handlePause, false); //menu button on android + document.addEventListener("pause", handlePause, false); + document.addEventListener("backbutton", handlePause, false); + document.addEventListener("menubutton", handlePause, false); //menu button on android - setTimeout(function() { - if (settings.platform == "mobile") { - try { - document.body.removeEventListener('touchstart', handleTapBefore, false); - } catch (e) { + setTimeout(function() { + if (settings.platform == "mobile") { + try { + document.body.removeEventListener('touchstart', handleTapBefore, false); + } catch (e) { - } + } - try { - document.body.removeEventListener('touchstart', handleTap, false); - } catch (e) { + try { + document.body.removeEventListener('touchstart', handleTap, false); + } catch (e) { - } + } - document.body.addEventListener('touchstart', handleTapBefore, false); - } else { - try { - document.body.removeEventListener('mousedown', handleClickBefore, false); - } catch (e) { + document.body.addEventListener('touchstart', handleTapBefore, false); + } else { + try { + document.body.removeEventListener('mousedown', handleClickBefore, false); + } catch (e) { - } + } - try { - document.body.removeEventListener('mousedown', handleClick, false); - } catch (e) { + try { + document.body.removeEventListener('mousedown', handleClick, false); + } catch (e) { - } + } - document.body.addEventListener('mousedown', handleClickBefore, false); - } - }, 1); - } + document.body.addEventListener('mousedown', handleClickBefore, false); + } + }, 1); + } } function startBtnHandler() { - setTimeout(function() { - if (settings.platform == "mobile") { - try { - document.body.removeEventListener('touchstart', handleTapBefore, false); - } catch (e) { + setTimeout(function() { + if (settings.platform == "mobile") { + try { + document.body.removeEventListener('touchstart', handleTapBefore, false); + } catch (e) { - } + } - try { - document.body.removeEventListener('touchstart', handleTap, false); - } catch (e) { + try { + document.body.removeEventListener('touchstart', handleTap, false); + } catch (e) { - } + } - document.body.addEventListener('touchstart', handleTap, false); - } else { - try { - document.body.removeEventListener('mousedown', handleClickBefore, false); - } catch (e) { + document.body.addEventListener('touchstart', handleTap, false); + } else { + try { + document.body.removeEventListener('mousedown', handleClickBefore, false); + } catch (e) { - } + } - try { - document.body.removeEventListener('mousedown', handleClick, false); - } catch (e) { + try { + document.body.removeEventListener('mousedown', handleClick, false); + } catch (e) { - } + } - document.body.addEventListener('mousedown', handleClick, false); - } - }, 5); + document.body.addEventListener('mousedown', handleClick, false); + } + }, 5); - if (!canRestart) return false; + if (!canRestart) return false; - if ($('#helpScreen').is(':visible')) { - $('#helpScreen').fadeOut(150, "linear"); - } + if ($('#helpScreen').is(':visible')) { + $('#helpScreen').fadeOut(150, "linear"); + } - if (importing == 1) { - init(1); - } else { - resumeGame(); - } + if (importing == 1) { + init(1); + } else { + resumeGame(); + } } function handlePause() { - if (gameState == 1 || gameState == 2) { - pause(); - } + if (gameState == 1 || gameState == 2) { + pause(); + } } function handleTap(e) { - handleClickTap(e.changedTouches[0].clientX, e.changedTouches[0].clientY); + handleClickTap(e.changedTouches[0].clientX, e.changedTouches[0].clientY); } function handleClick(e) { - handleClickTap(e.clientX, e.clientY); + handleClickTap(e.clientX, e.clientY); } function handleTapBefore(e) { - var x = e.changedTouches[0].clientX; - var y = e.changedTouches[0].clientY; + var x = e.changedTouches[0].clientX; + var y = e.changedTouches[0].clientY; - if (x < 120 && y < 50 && $('.helpText').is(':visible')) { - showHelp(); - return; - } + if (x < 120 && y < 50 && $('.helpText').is(':visible')) { + showHelp(); + return; + } } function handleClickBefore(e) { - var x = e.clientX; - var y = e.clientY; + var x = e.clientX; + var y = e.clientY; - if (x < 120 && y < 50 && $('.helpText').is(':visible')) { - showHelp(); - return; - } + if (x < 120 && y < 50 && $('.helpText').is(':visible')) { + showHelp(); + return; + } } diff --git a/js_v9/input.js b/js_v9/input.js index 1736619..d21afe8 100644 --- a/js_v9/input.js +++ b/js_v9/input.js @@ -1,81 +1,81 @@ function addKeyListeners() { - keypress.register_combo({ - keys: "left", - on_keydown: function() { - if (MainHex && gameState !== 0) { - MainHex.rotate(1); - } - } - }); + keypress.register_combo({ + keys: "left", + on_keydown: function() { + if (MainHex && gameState !== 0) { + MainHex.rotate(1); + } + } + }); - keypress.register_combo({ - keys: "right", - on_keydown: function() { - if (MainHex && gameState !== 0){ - MainHex.rotate(-1); - } - } - }); - keypress.register_combo({ - keys: "down", - on_keydown: function() { - rush=2; - }, - on_release: function() { - rush=1; - } + keypress.register_combo({ + keys: "right", + on_keydown: function() { + if (MainHex && gameState !== 0){ + MainHex.rotate(-1); + } + } + }); + keypress.register_combo({ + keys: "down", + on_keydown: function() { + rush=2; + }, + on_release: function() { + rush=1; + } - }); + }); - keypress.register_combo({ - keys: "a", - on_keydown: function() { - if (MainHex && gameState !== 0) { - MainHex.rotate(1); - } - } - }); + keypress.register_combo({ + keys: "a", + on_keydown: function() { + if (MainHex && gameState !== 0) { + MainHex.rotate(1); + } + } + }); - keypress.register_combo({ - keys: "d", - on_keydown: function() { - if (MainHex && gameState !== 0){ - MainHex.rotate(-1); - } - } - }); + keypress.register_combo({ + keys: "d", + on_keydown: function() { + if (MainHex && gameState !== 0){ + MainHex.rotate(-1); + } + } + }); - keypress.register_combo({ - keys: "p", - on_keydown: function(){pause();} - }); + keypress.register_combo({ + keys: "p", + on_keydown: function(){pause();} + }); - keypress.register_combo({ - keys: "space", - on_keydown: function(){pause();} - }); + keypress.register_combo({ + keys: "space", + on_keydown: function(){pause();} + }); - keypress.register_combo({ - keys: "q", - on_keydown: function() { - if (devMode) toggleDevTools(); - } - }); + keypress.register_combo({ + keys: "q", + on_keydown: function() { + if (devMode) toggleDevTools(); + } + }); - keypress.register_combo({ - keys: "enter", - on_keydown: function() { - if (gameState==1 || importing == 1) { - init(1); - } - if (gameState == 2) { - init(); - } - if (gameState===0) { - resumeGame(); - } - } - }); + keypress.register_combo({ + keys: "enter", + on_keydown: function() { + if (gameState==1 || importing == 1) { + init(1); + } + if (gameState == 2) { + init(); + } + if (gameState===0) { + resumeGame(); + } + } + }); $("#pauseBtn").on('touchstart mousedown', function() { @@ -93,134 +93,134 @@ function addKeyListeners() { $("#colorBlindBtn").on('touchstart mousedown', function() { window.colors = ["#8e44ad", "#f1c40f", "#3498db", "#d35400"]; - window.hexColorsToTintedColors = { - "#8e44ad": "rgb(229,152,102)", - "#f1c40f": "rgb(246,223,133)", - "#3498db": "rgb(151,201,235)", - "#d35400": "rgb(210,180,222)" - }; + window.hexColorsToTintedColors = { + "#8e44ad": "rgb(229,152,102)", + "#f1c40f": "rgb(246,223,133)", + "#3498db": "rgb(151,201,235)", + "#d35400": "rgb(210,180,222)" + }; - window.rgbToHex = { - "rgb(142,68,173)": "#8e44ad", - "rgb(241,196,15)": "#f1c40f", - "rgb(52,152,219)": "#3498db", - "rgb(211,84,0)": "#d35400" - }; + window.rgbToHex = { + "rgb(142,68,173)": "#8e44ad", + "rgb(241,196,15)": "#f1c40f", + "rgb(52,152,219)": "#3498db", + "rgb(211,84,0)": "#d35400" + }; - window.rgbColorsToTintedColors = { - "rgb(142,68,173)": "rgb(229,152,102)", - "rgb(241,196,15)": "rgb(246,223,133)", - "rgb(52,152,219)": "rgb(151,201,235)", - "rgb(46,204,113)": "rgb(210,180,222)" + window.rgbColorsToTintedColors = { + "rgb(142,68,173)": "rgb(229,152,102)", + "rgb(241,196,15)": "rgb(246,223,133)", + "rgb(52,152,219)": "rgb(151,201,235)", + "rgb(46,204,113)": "rgb(210,180,222)" }; }); - if(/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) { - $("#restartBtn").on('touchstart', function() { - init(1); - canRestart = false; - }); - } - else { - $("#restartBtn").on('mousedown', function() { - init(1); - canRestart = false; - }); - } + if(/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) { + $("#restartBtn").on('touchstart', function() { + init(1); + canRestart = false; + }); + } + else { + $("#restartBtn").on('mousedown', function() { + init(1); + canRestart = false; + }); + } } function inside (point, vs) { - // ray-casting algorithm based on - // http://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html - - var x = point[0], y = point[1]; - - var inside = false; - for (var i = 0, j = vs.length - 1; i < vs.length; j = i++) { - var xi = vs[i][0], yi = vs[i][1]; - var xj = vs[j][0], yj = vs[j][1]; - - var intersect = ((yi > y) != (yj > y)) - && (x < (xj - xi) * (y - yi) / (yj - yi) + xi); - if (intersect) inside = !inside; - } - - return inside; + // ray-casting algorithm based on + // http://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html + + var x = point[0], y = point[1]; + + var inside = false; + for (var i = 0, j = vs.length - 1; i < vs.length; j = i++) { + var xi = vs[i][0], yi = vs[i][1]; + var xj = vs[j][0], yj = vs[j][1]; + + var intersect = ((yi > y) != (yj > y)) + && (x < (xj - xi) * (y - yi) / (yj - yi) + xi); + if (intersect) inside = !inside; + } + + return inside; }; function handleClickTap(x,y) { - if (x < 120 && y < 50 && $('.helpText').is(':visible')) { - showHelp(); - return; - } - var radius = settings.hexWidth ; - var halfRadius = radius/2; - var triHeight = radius *(Math.sqrt(3)/2); - var Vertexes =[ - [radius,0], - [halfRadius,-triHeight], - [-halfRadius,-triHeight], - [-radius,0], - [-halfRadius,triHeight], - [halfRadius,triHeight]]; - Vertexes = Vertexes.map(function(coord){ - return [coord[0] + trueCanvas.width/2, coord[1] + trueCanvas.height/2]}); - if (gameState == 1 && inside([x,y],Vertexes)){ - toggleRush(); - return; - } - if (gameState == 2 && canRestart) { - setTimeout(function() { - if(tweetblock) { - tweetblock = false; - return; - } - else{ - if (gameState != 1) { - init(1); - } - } - return; - }, 1000); - return; - } + if (x < 120 && y < 50 && $('.helpText').is(':visible')) { + showHelp(); + return; + } + var radius = settings.hexWidth ; + var halfRadius = radius/2; + var triHeight = radius *(Math.sqrt(3)/2); + var Vertexes =[ + [radius,0], + [halfRadius,-triHeight], + [-halfRadius,-triHeight], + [-radius,0], + [-halfRadius,triHeight], + [halfRadius,triHeight]]; + Vertexes = Vertexes.map(function(coord){ + return [coord[0] + trueCanvas.width/2, coord[1] + trueCanvas.height/2]}); + if (gameState == 1 && inside([x,y],Vertexes)){ + toggleRush(); + return; + } + if (gameState == 2 && canRestart) { + setTimeout(function() { + if(tweetblock) { + tweetblock = false; + return; + } + else{ + if (gameState != 1) { + init(1); + } + } + return; + }, 1000); + return; + } - if (!MainHex || gameState === 0 || gameState==-1) { - return; - } + if (!MainHex || gameState === 0 || gameState==-1) { + return; + } - if (x < window.innerWidth/2) { - if (gameState != 1 && gameState != -2 && gameState != -1 ){ - if (importing === 0) { - resumeGame(); - } - else { - init(1); - } - } + if (x < window.innerWidth/2) { + if (gameState != 1 && gameState != -2 && gameState != -1 ){ + if (importing === 0) { + resumeGame(); + } + else { + init(1); + } + } - MainHex.rotate(1); - } - if (x > window.innerWidth/2) { - if (gameState != 1 && gameState != -2 && gameState != -1) { - if (importing === 0) { - resumeGame(); - } - else { - init(1); - } - } - MainHex.rotate(-1); - } + MainHex.rotate(1); + } + if (x > window.innerWidth/2) { + if (gameState != 1 && gameState != -2 && gameState != -1) { + if (importing === 0) { + resumeGame(); + } + else { + init(1); + } + } + MainHex.rotate(-1); + } } function toggleRush(){ - rush = ((rush)%2)+1; + rush = ((rush)%2)+1; } function setRush() { - rush = 2; + rush = 2; } function removeRush() { - rush = 1; + rush = 1; } diff --git a/js_v9/main.js b/js_v9/main.js index a275db1..c985718 100644 --- a/js_v9/main.js +++ b/js_v9/main.js @@ -1,341 +1,341 @@ function scaleCanvas() { - canvas.width = $(window).width(); - canvas.height = $(window).height(); + canvas.width = $(window).width(); + canvas.height = $(window).height(); - if (canvas.height > canvas.width) { - settings.scale = (canvas.width / 800) * settings.baseScale; - } else { - settings.scale = (canvas.height / 800) * settings.baseScale; - } + if (canvas.height > canvas.width) { + settings.scale = (canvas.width / 800) * settings.baseScale; + } else { + settings.scale = (canvas.height / 800) * settings.baseScale; + } - trueCanvas = { - width: canvas.width, - height: canvas.height - }; + trueCanvas = { + width: canvas.width, + height: canvas.height + }; - if (window.devicePixelRatio) { - var cw = $("#canvas").attr('width'); - var ch = $("#canvas").attr('height'); + if (window.devicePixelRatio) { + var cw = $("#canvas").attr('width'); + var ch = $("#canvas").attr('height'); - $("#canvas").attr('width', cw * window.devicePixelRatio); - $("#canvas").attr('height', ch * window.devicePixelRatio); - $("#canvas").css('width', cw); - $("#canvas").css('height', ch); + $("#canvas").attr('width', cw * window.devicePixelRatio); + $("#canvas").attr('height', ch * window.devicePixelRatio); + $("#canvas").css('width', cw); + $("#canvas").css('height', ch); - trueCanvas = { - width: cw, - height: ch - }; + trueCanvas = { + width: cw, + height: ch + }; - ctx.scale(window.devicePixelRatio, window.devicePixelRatio); - } + ctx.scale(window.devicePixelRatio, window.devicePixelRatio); + } } function toggleDevTools() { - $('#devtools').toggle(); + $('#devtools').toggle(); } function resumeGame() { - gameState = 1; - hideUIElements(); - $('#pauseBtn').show(); - $('#restartBtn').hide(); - importing = 0; - startTime = Date.now(); - setTimeout(function() { - if ((gameState == 1 || gameState == 2) && !$('#helpScreen').is(':visible')) { - $('.helpText').fadeOut(150, "linear"); - } - }, 7000); + gameState = 1; + hideUIElements(); + $('#pauseBtn').show(); + $('#restartBtn').hide(); + importing = 0; + startTime = Date.now(); + setTimeout(function() { + if ((gameState == 1 || gameState == 2) && !$('#helpScreen').is(':visible')) { + $('.helpText').fadeOut(150, "linear"); + } + }, 7000); - checkVisualElements(); + checkVisualElements(); } function checkVisualElements() { - if (!$('.helpText').is(":visible")) $('.helpText').fadeIn(150, "linear"); - if (!$('#pauseBtn').is(':visible')) $('#pauseBtn').fadeIn(150, "linear"); - $('#fork-ribbon').fadeOut(150); - if (!$('#restartBtn').is(':visible')) $('#restartBtn').fadeOut(150, "linear"); + if (!$('.helpText').is(":visible")) $('.helpText').fadeIn(150, "linear"); + if (!$('#pauseBtn').is(':visible')) $('#pauseBtn').fadeIn(150, "linear"); + $('#fork-ribbon').fadeOut(150); + if (!$('#restartBtn').is(':visible')) $('#restartBtn').fadeOut(150, "linear"); } function hideUIElements() { - $('#pauseBtn').hide(); - $('#restartBtn').hide(); - $('#startBtn').hide(); - $("#attributions").hide(); - $("#bottombar").hide(); + $('#pauseBtn').hide(); + $('#restartBtn').hide(); + $('#startBtn').hide(); + $("#attributions").hide(); + $("#bottombar").hide(); } function init(b) { - if(settings.ending_block && b == 1){return;} - if (b) { - hidebottombar(); + if(settings.ending_block && b == 1){return;} + if (b) { + hidebottombar(); - if ($('#helpScreen').is(":visible")) { - $('#helpScreen').fadeOut(150, "linear"); - } + if ($('#helpScreen').is(":visible")) { + $('#helpScreen').fadeOut(150, "linear"); + } - setTimeout(function() { - $('.helpText').fadeOut(150, "linear"); - infobuttonfading = false; - }, 7000); - clearSaveState(); - } + setTimeout(function() { + $('.helpText').fadeOut(150, "linear"); + infobuttonfading = false; + }, 7000); + clearSaveState(); + } - infobuttonfading = true; - $("#pauseBtn").html(''); - hideUIElements(); - var saveState = localStorage.getItem("saveState") || "{}"; - saveState = JSONfn.parse(saveState); - document.getElementById("canvas").className = ""; - history = {}; - importedHistory = undefined; - importing = 0; - isGameOver = 2; - score = saveState.score || 0; - prevScore = 0; - spawnLane = 0; - op = 0; - tweetblock=false; - scoreOpacity = 0; - gameState = 1; - $("#restartBtn").hide(); - $("#pauseBtn").show(); - if (saveState.hex !== undefined) gameState = 1; + infobuttonfading = true; + $("#pauseBtn").html(''); + hideUIElements(); + var saveState = localStorage.getItem("saveState") || "{}"; + saveState = JSONfn.parse(saveState); + document.getElementById("canvas").className = ""; + history = {}; + importedHistory = undefined; + importing = 0; + isGameOver = 2; + score = saveState.score || 0; + prevScore = 0; + spawnLane = 0; + op = 0; + tweetblock=false; + scoreOpacity = 0; + gameState = 1; + $("#restartBtn").hide(); + $("#pauseBtn").show(); + if (saveState.hex !== undefined) gameState = 1; - settings.blockHeight = settings.baseBlockHeight * settings.scale; - settings.hexWidth = settings.baseHexWidth * settings.scale; - MainHex = saveState.hex || new Hex(settings.hexWidth); - if (saveState.hex) { - MainHex.playThrough += 1; - } - MainHex.sideLength = settings.hexWidth; + settings.blockHeight = settings.baseBlockHeight * settings.scale; + settings.hexWidth = settings.baseHexWidth * settings.scale; + MainHex = saveState.hex || new Hex(settings.hexWidth); + if (saveState.hex) { + MainHex.playThrough += 1; + } + MainHex.sideLength = settings.hexWidth; - var i; - var block; - if (saveState.blocks) { - saveState.blocks.map(function(o) { - if (rgbToHex[o.color]) { - o.color = rgbToHex[o.color]; - } - }); + var i; + var block; + if (saveState.blocks) { + saveState.blocks.map(function(o) { + if (rgbToHex[o.color]) { + o.color = rgbToHex[o.color]; + } + }); - for (i = 0; i < saveState.blocks.length; i++) { - block = saveState.blocks[i]; - blocks.push(block); - } - } else { - blocks = []; - } + for (i = 0; i < saveState.blocks.length; i++) { + block = saveState.blocks[i]; + blocks.push(block); + } + } else { + blocks = []; + } - gdx = saveState.gdx || 0; - gdy = saveState.gdy || 0; - comboTime = saveState.comboTime || 0; + gdx = saveState.gdx || 0; + gdy = saveState.gdy || 0; + comboTime = saveState.comboTime || 0; - for (i = 0; i < MainHex.blocks.length; i++) { - for (var j = 0; j < MainHex.blocks[i].length; j++) { - MainHex.blocks[i][j].height = settings.blockHeight; - MainHex.blocks[i][j].settled = 0; - } - } + for (i = 0; i < MainHex.blocks.length; i++) { + for (var j = 0; j < MainHex.blocks[i].length; j++) { + MainHex.blocks[i][j].height = settings.blockHeight; + MainHex.blocks[i][j].settled = 0; + } + } - MainHex.blocks.map(function(i) { - i.map(function(o) { - if (rgbToHex[o.color]) { - o.color = rgbToHex[o.color]; - } - }); - }); + MainHex.blocks.map(function(i) { + i.map(function(o) { + if (rgbToHex[o.color]) { + o.color = rgbToHex[o.color]; + } + }); + }); - MainHex.y = -100; + MainHex.y = -100; - startTime = Date.now(); - waveone = saveState.wavegen || new waveGen(MainHex); + startTime = Date.now(); + waveone = saveState.wavegen || new waveGen(MainHex); - MainHex.texts = []; //clear texts - MainHex.delay = 15; - hideText(); + MainHex.texts = []; //clear texts + MainHex.delay = 15; + hideText(); } function addNewBlock(blocklane, color, iter, distFromHex, settled) { //last two are optional parameters - iter *= settings.speedModifier; - if (!history[MainHex.ct]) { - history[MainHex.ct] = {}; - } + iter *= settings.speedModifier; + if (!history[MainHex.ct]) { + history[MainHex.ct] = {}; + } - history[MainHex.ct].block = { - blocklane: blocklane, - color: color, - iter: iter - }; + history[MainHex.ct].block = { + blocklane: blocklane, + color: color, + iter: iter + }; - if (distFromHex) { - history[MainHex.ct].distFromHex = distFromHex; - } - if (settled) { - blockHist[MainHex.ct].settled = settled; - } - blocks.push(new Block(blocklane, color, iter, distFromHex, settled)); + if (distFromHex) { + history[MainHex.ct].distFromHex = distFromHex; + } + if (settled) { + blockHist[MainHex.ct].settled = settled; + } + blocks.push(new Block(blocklane, color, iter, distFromHex, settled)); } function exportHistory() { - $('#devtoolsText').html(JSON.stringify(history)); - toggleDevTools(); + $('#devtoolsText').html(JSON.stringify(history)); + toggleDevTools(); } function setStartScreen() { - $('#startBtn').show(); - init(); - if (isStateSaved()) { - importing = 0; - } else { - importing = 1; - } + $('#startBtn').show(); + init(); + if (isStateSaved()) { + importing = 0; + } else { + importing = 1; + } - $('#pauseBtn').hide(); - $('#restartBtn').hide(); - $('#startBtn').show(); - $('#attributions').show(); - showbottombar(); + $('#pauseBtn').hide(); + $('#restartBtn').hide(); + $('#startBtn').show(); + $('#attributions').show(); + showbottombar(); - gameState = 0; - requestAnimFrame(animLoop); + gameState = 0; + requestAnimFrame(animLoop); } var spd = 1; function animLoop() { - switch (gameState) { - case 1: - requestAnimFrame(animLoop); - render(); - var now = Date.now(); - var dt = (now - lastTime)/16.666 * rush; - if (spd > 1) { - dt *= spd; - } + switch (gameState) { + case 1: + requestAnimFrame(animLoop); + render(); + var now = Date.now(); + var dt = (now - lastTime)/16.666 * rush; + if (spd > 1) { + dt *= spd; + } - if(gameState == 1 ){ - if(!MainHex.delay) { - update(dt); - } - else{ - MainHex.delay--; - } - } + if(gameState == 1 ){ + if(!MainHex.delay) { + update(dt); + } + else{ + MainHex.delay--; + } + } - lastTime = now; + lastTime = now; - if (checkGameOver() && !importing) { - var saveState = localStorage.getItem("saveState") || "{}"; - saveState = JSONfn.parse(saveState); - gameState = 2; + if (checkGameOver() && !importing) { + var saveState = localStorage.getItem("saveState") || "{}"; + saveState = JSONfn.parse(saveState); + gameState = 2; - setTimeout(function() { - enableRestart(); - }, 150); + setTimeout(function() { + enableRestart(); + }, 150); - if ($('#helpScreen').is(':visible')) { - $('#helpScreen').fadeOut(150, "linear"); - } + if ($('#helpScreen').is(':visible')) { + $('#helpScreen').fadeOut(150, "linear"); + } - if ($('#pauseBtn').is(':visible')) $('#pauseBtn').fadeOut(150, "linear"); - if ($('#restartBtn').is(':visible')) $('#restartBtn').fadeOut(150, "linear"); - if (!$('.helpText').is(':visible')) $('.helpText').fadeIn(150, "linear"); + if ($('#pauseBtn').is(':visible')) $('#pauseBtn').fadeOut(150, "linear"); + if ($('#restartBtn').is(':visible')) $('#restartBtn').fadeOut(150, "linear"); + if (!$('.helpText').is(':visible')) $('.helpText').fadeIn(150, "linear"); - showbottombar(); - canRestart = 0; - clearSaveState(); - } - break; + showbottombar(); + canRestart = 0; + clearSaveState(); + } + break; - case 0: - requestAnimFrame(animLoop); - render(); - break; + case 0: + requestAnimFrame(animLoop); + render(); + break; - case -1: - requestAnimFrame(animLoop); - render(); - break; + case -1: + requestAnimFrame(animLoop); + render(); + break; - case 2: - var now = Date.now(); - var dt = (now - lastTime)/16.666 * rush; - requestAnimFrame(animLoop); - update(dt); - render(); - lastTime = now; - break; + case 2: + var now = Date.now(); + var dt = (now - lastTime)/16.666 * rush; + requestAnimFrame(animLoop); + update(dt); + render(); + lastTime = now; + break; - case 3: - requestAnimFrame(animLoop); - fadeOutObjectsOnScreen(); - render(); - break; + case 3: + requestAnimFrame(animLoop); + fadeOutObjectsOnScreen(); + render(); + break; - case 4: - setTimeout(function() { - initialize(1); - }, 1); - render(); - return; + case 4: + setTimeout(function() { + initialize(1); + }, 1); + render(); + return; - default: - initialize(); - setStartScreen(); - break; - } + default: + initialize(); + setStartScreen(); + break; + } - if (!(gameState == 1 || gameState == 2)) { - lastTime = Date.now(); - } + if (!(gameState == 1 || gameState == 2)) { + lastTime = Date.now(); + } } function enableRestart() { - canRestart = 1; + canRestart = 1; } function isInfringing(hex) { - for (var i = 0; i < hex.sides; i++) { - var subTotal = 0; - for (var j = 0; j < hex.blocks[i].length; j++) { - subTotal += hex.blocks[i][j].deleted; - } + for (var i = 0; i < hex.sides; i++) { + var subTotal = 0; + for (var j = 0; j < hex.blocks[i].length; j++) { + subTotal += hex.blocks[i][j].deleted; + } - if (hex.blocks[i].length - subTotal > settings.rows) { - return true; - } - } - return false; + if (hex.blocks[i].length - subTotal > settings.rows) { + return true; + } + } + return false; } function checkGameOver() { - for (var i = 0; i < MainHex.sides; i++) { - if (isInfringing(MainHex)) { - $.get('http://54.183.184.126/' + String(score)) - if (highscores.indexOf(score) == -1) { - highscores.push(score); - } - writeHighScores(); - gameOverDisplay(); - return true; - } - } - return false; + for (var i = 0; i < MainHex.sides; i++) { + if (isInfringing(MainHex)) { + $.get('http://54.183.184.126/' + String(score)) + if (highscores.indexOf(score) == -1) { + highscores.push(score); + } + writeHighScores(); + gameOverDisplay(); + return true; + } + } + return false; } function showHelp() { - $("#inst_main_body").html("The goal of Hextris is to stop blocks from leaving the inside of the outer gray hexagon

" + (settings.platform != 'mobile' ? 'Press the right and left arrow keys' : 'tap the left and right sides of the screen') + " to rotate the Hexagon

Clear blocks and get points by making 3 or more blocks of the same color touch

Time left before your combo streak disappears is indicated shown by the colored lines in the outer hexagon

" + (settings.platform == 'mobile' ? 'Toggle speeding up the game by tapping the inner hexagon' : "Speed up the game 2x by holding the down arrow")); - if (gameState == 1) { - pause(); - } + $("#inst_main_body").html("The goal of Hextris is to stop blocks from leaving the inside of the outer gray hexagon

" + (settings.platform != 'mobile' ? 'Press the right and left arrow keys' : 'tap the left and right sides of the screen') + " to rotate the Hexagon

Clear blocks and get points by making 3 or more blocks of the same color touch

Time left before your combo streak disappears is indicated shown by the colored lines in the outer hexagon

" + (settings.platform == 'mobile' ? 'Toggle speeding up the game by tapping the inner hexagon' : "Speed up the game 2x by holding the down arrow")); + if (gameState == 1) { + pause(); + } - if($("#pauseBtn").children()[0].src.replace(/^.*[\\\/]/, '') == "btn_pause.svg" && gameState != 0 && !infobuttonfading) { - return; - } + if($("#pauseBtn").children()[0].src.replace(/^.*[\\\/]/, '') == "btn_pause.svg" && gameState != 0 && !infobuttonfading) { + return; + } - $("#openSideBar").fadeIn(150,"linear"); - $('#helpScreen').fadeToggle(150, "linear"); + $("#openSideBar").fadeIn(150,"linear"); + $('#helpScreen').fadeToggle(150, "linear"); } diff --git a/js_v9/math.js b/js_v9/math.js index fdf254f..3946bb4 100644 --- a/js_v9/math.js +++ b/js_v9/math.js @@ -1,14 +1,14 @@ function rotatePoint(x, y, theta) { - var thetaRad = theta * (Math.PI / 180); - var rotX = Math.cos(thetaRad) * x - Math.sin(thetaRad) * y; - var rotY = Math.sin(thetaRad) * x + Math.cos(thetaRad) * y; + var thetaRad = theta * (Math.PI / 180); + var rotX = Math.cos(thetaRad) * x - Math.sin(thetaRad) * y; + var rotY = Math.sin(thetaRad) * x + Math.cos(thetaRad) * y; - return { - x: rotX, - y: rotY - }; + return { + x: rotX, + y: rotY + }; } function randInt(min, max) { - return Math.floor((Math.random() * max) + min); + return Math.floor((Math.random() * max) + min); } diff --git a/js_v9/save-state.js b/js_v9/save-state.js index 52ac757..2a3f36c 100644 --- a/js_v9/save-state.js +++ b/js_v9/save-state.js @@ -37,7 +37,7 @@ function descaleBlock(b) { } function writeHighScores() { - highscores.sort( + highscores.sort( function(a,b){ a = parseInt(a, 10); b = parseInt(b, 10); diff --git a/js_v9/view.js b/js_v9/view.js index 648c7e3..1983deb 100644 --- a/js_v9/view.js +++ b/js_v9/view.js @@ -1,253 +1,253 @@ // t: current time, b: begInnIng value, c: change In value, d: duration function easeOutCubic(t, b, c, d) { - return c * ((t = t / d - 1) * t * t + 1) + b; + return c * ((t = t / d - 1) * t * t + 1) + b; } function renderText(x, y, fontSize, color, text, font) { - if (text == 'HIGH SCORE') debugger; - ctx.save(); - if (!font) { - font = 'px/0 Roboto'; - } + if (text == 'HIGH SCORE') debugger; + ctx.save(); + if (!font) { + font = 'px/0 Roboto'; + } - fontSize *= settings.scale; - ctx.font = fontSize + font; - ctx.textAlign = 'center'; - ctx.fillStyle = color; - ctx.fillText(text, x, y + (fontSize / 2) - 9 * settings.scale); - ctx.restore(); + fontSize *= settings.scale; + ctx.font = fontSize + font; + ctx.textAlign = 'center'; + ctx.fillStyle = color; + ctx.fillText(text, x, y + (fontSize / 2) - 9 * settings.scale); + ctx.restore(); } function drawScoreboard() { - if (scoreOpacity < 1) { - scoreOpacity += 0.01; - textOpacity += 0.01; - } + if (scoreOpacity < 1) { + scoreOpacity += 0.01; + textOpacity += 0.01; + } - ctx.globalAlpha = textOpacity; - var scoreSize = 50; - var scoreString = String(score); - if (scoreString.length == 6) { - scoreSize = 43; - } else if (scoreString.length == 7) { - scoreSize = 35; - } else if (scoreString.length == 8) { - scoreSize = 31; - } else if (scoreString.length == 9) { - scoreSize = 27; - } - if (rush ==1){ - var color = "rgb(236, 240, 241)"; - } - else{ - var color = "#e74c3c"; - } - if (gameState === 0) { - renderText(trueCanvas.width / 2 + gdx + 6 * settings.scale, trueCanvas.height / 2 + gdy, 60, "rgb(236, 240, 241)", String.fromCharCode("0xf04b"), 'px FontAwesome'); - renderText(trueCanvas.width / 2 + gdx + 6 * settings.scale, trueCanvas.height / 2 + gdy - 170 * settings.scale, 150, "#2c3e50", "Hextris"); - renderText(trueCanvas.width / 2 + gdx + 5 * settings.scale, trueCanvas.height / 2 + gdy + 100 * settings.scale, 30, "rgb(44,62,80)", 'Play!'); - } else if (gameState != 0 && textOpacity > 0) { - textOpacity -= 0.05; - renderText(trueCanvas.width / 2 + gdx + 6 * settings.scale, trueCanvas.height / 2 + gdy, 60, "rgb(236, 240, 241)", String.fromCharCode("0xf04b"), 'px FontAwesome'); - renderText(trueCanvas.width / 2 + gdx + 6 * settings.scale, trueCanvas.height / 2 + gdy - 170 * settings.scale, 150, "#2c3e50", "Hextris"); - renderText(trueCanvas.width / 2 + gdx + 5 * settings.scale, trueCanvas.height / 2 + gdy + 100 * settings.scale, 30, "rgb(44,62,80)", 'Play!'); - ctx.globalAlpha = scoreOpacity; - renderText(trueCanvas.width / 2 + gdx, trueCanvas.height / 2 + gdy, scoreSize, color, score); - } else { - ctx.globalAlpha = scoreOpacity; - renderText(trueCanvas.width / 2 + gdx, trueCanvas.height / 2 + gdy, scoreSize, color, score); - } + ctx.globalAlpha = textOpacity; + var scoreSize = 50; + var scoreString = String(score); + if (scoreString.length == 6) { + scoreSize = 43; + } else if (scoreString.length == 7) { + scoreSize = 35; + } else if (scoreString.length == 8) { + scoreSize = 31; + } else if (scoreString.length == 9) { + scoreSize = 27; + } + if (rush ==1){ + var color = "rgb(236, 240, 241)"; + } + else{ + var color = "#e74c3c"; + } + if (gameState === 0) { + renderText(trueCanvas.width / 2 + gdx + 6 * settings.scale, trueCanvas.height / 2 + gdy, 60, "rgb(236, 240, 241)", String.fromCharCode("0xf04b"), 'px FontAwesome'); + renderText(trueCanvas.width / 2 + gdx + 6 * settings.scale, trueCanvas.height / 2 + gdy - 170 * settings.scale, 150, "#2c3e50", "Hextris"); + renderText(trueCanvas.width / 2 + gdx + 5 * settings.scale, trueCanvas.height / 2 + gdy + 100 * settings.scale, 30, "rgb(44,62,80)", 'Play!'); + } else if (gameState != 0 && textOpacity > 0) { + textOpacity -= 0.05; + renderText(trueCanvas.width / 2 + gdx + 6 * settings.scale, trueCanvas.height / 2 + gdy, 60, "rgb(236, 240, 241)", String.fromCharCode("0xf04b"), 'px FontAwesome'); + renderText(trueCanvas.width / 2 + gdx + 6 * settings.scale, trueCanvas.height / 2 + gdy - 170 * settings.scale, 150, "#2c3e50", "Hextris"); + renderText(trueCanvas.width / 2 + gdx + 5 * settings.scale, trueCanvas.height / 2 + gdy + 100 * settings.scale, 30, "rgb(44,62,80)", 'Play!'); + ctx.globalAlpha = scoreOpacity; + renderText(trueCanvas.width / 2 + gdx, trueCanvas.height / 2 + gdy, scoreSize, color, score); + } else { + ctx.globalAlpha = scoreOpacity; + renderText(trueCanvas.width / 2 + gdx, trueCanvas.height / 2 + gdy, scoreSize, color, score); + } - ctx.globalAlpha = 1; + ctx.globalAlpha = 1; } function clearGameBoard() { - drawPolygon(trueCanvas.width / 2, trueCanvas.height / 2, 6, trueCanvas.width / 2, 30, hexagonBackgroundColor, 0, 'rgba(0,0,0,0)'); + drawPolygon(trueCanvas.width / 2, trueCanvas.height / 2, 6, trueCanvas.width / 2, 30, hexagonBackgroundColor, 0, 'rgba(0,0,0,0)'); } function drawPolygon(x, y, sides, radius, theta, fillColor, lineWidth, lineColor) { - ctx.fillStyle = fillColor; - ctx.lineWidth = lineWidth; - ctx.strokeStyle = lineColor; + ctx.fillStyle = fillColor; + ctx.lineWidth = lineWidth; + ctx.strokeStyle = lineColor; - ctx.beginPath(); - var coords = rotatePoint(0, radius, theta); - ctx.moveTo(coords.x + x, coords.y + y); - var oldX = coords.x; - var oldY = coords.y; - for (var i = 0; i < sides; i++) { - coords = rotatePoint(oldX, oldY, 360 / sides); - ctx.lineTo(coords.x + x, coords.y + y); - oldX = coords.x; - oldY = coords.y; - } + ctx.beginPath(); + var coords = rotatePoint(0, radius, theta); + ctx.moveTo(coords.x + x, coords.y + y); + var oldX = coords.x; + var oldY = coords.y; + for (var i = 0; i < sides; i++) { + coords = rotatePoint(oldX, oldY, 360 / sides); + ctx.lineTo(coords.x + x, coords.y + y); + oldX = coords.x; + oldY = coords.y; + } - ctx.closePath(); - ctx.fill(); - ctx.stroke(); - ctx.strokeStyle = 'rgba(0,0,0,0)'; + ctx.closePath(); + ctx.fill(); + ctx.stroke(); + ctx.strokeStyle = 'rgba(0,0,0,0)'; } function toggleClass(element, active) { - if ($(element).hasClass(active)) { - $(element).removeClass(active); - } else { - $(element).addClass(active); - } + if ($(element).hasClass(active)) { + $(element).removeClass(active); + } else { + $(element).addClass(active); + } } function showText(text) { - var messages = { - 'paused': "
Paused

Press p to resume
", - 'pausedAndroid': "
Paused

Press to resume
", - 'start': "
Press enter to start
", - 'gameover': "
Game Over: " + score + " pts

High Scores:
" - }; + var messages = { + 'paused': "
Paused

Press p to resume
", + 'pausedAndroid': "
Paused

Press to resume
", + 'start': "
Press enter to start
", + 'gameover': "
Game Over: " + score + " pts

High Scores:
" + }; - if (text == 'paused') { - if (settings.os == 'android') { - text = 'pausedAndroid'; - } - } + if (text == 'paused') { + if (settings.os == 'android') { + text = 'pausedAndroid'; + } + } - if (text == 'gameover') { - //Clay('client.share.any', {text: 'Think you can beat my score of '+ score + ' in Super Cool Game?'}) - var allZ = 1; - var i; + if (text == 'gameover') { + //Clay('client.share.any', {text: 'Think you can beat my score of '+ score + ' in Super Cool Game?'}) + var allZ = 1; + var i; - for (i = 0; i < 3; i++) { - if (highscores.length > i) { - messages['gameover'] += ""; - } - } + for (i = 0; i < 3; i++) { + if (highscores.length > i) { + messages['gameover'] += ""; + } + } - var restartText; - if (settings.platform == 'mobile') { - restartText = 'Tap anywhere to restart!'; - } else { - restartText = 'Press enter (or click anywhere!) to restart!'; - } + var restartText; + if (settings.platform == 'mobile') { + restartText = 'Tap anywhere to restart!'; + } else { + restartText = 'Press enter (or click anywhere!) to restart!'; + } - messages['gameover'] += "
" + (i + 1) + ". " + highscores[i] + " pts
" + (i + 1) + ". " + highscores[i] + " pts

" + restartText + "
"; - if (allZ) { - for (i = 0; i < highscores.length; i++) { - if (highscores[i] !== 0) { - allZ = 0; - } - } - } - } - messages['gameover'] += "" - $(".overlay").html(messages[text]); - $(".overlay").fadeIn("1000", "swing"); + messages['gameover'] += "
" + restartText + "
"; + if (allZ) { + for (i = 0; i < highscores.length; i++) { + if (highscores[i] !== 0) { + allZ = 0; + } + } + } + } + messages['gameover'] += "" + $(".overlay").html(messages[text]); + $(".overlay").fadeIn("1000", "swing"); - if (text == 'gameover') { - if (settings.platform == 'mobile') { - $('.tg').css('margin-top', '6px'); - $("#tapToRestart").css('margin-top','-19px') - } - } + if (text == 'gameover') { + if (settings.platform == 'mobile') { + $('.tg').css('margin-top', '6px'); + $("#tapToRestart").css('margin-top','-19px') + } + } } function setMainMenu() { - gameState = 4; - canRestart = false; - setTimeout(function() { - canRestart = 's'; - }, 500); - $('#restartBtn').hide(); - if ($("#pauseBtn").replace(/^.*[\\\/]/, '') == "btn_pause.svg") { - $("#pauseBtn").attr("src","./images/btn_resume.svg"); - } else { - $("#pauseBtn").attr("src","./images/btn_pause.svg"); - } + gameState = 4; + canRestart = false; + setTimeout(function() { + canRestart = 's'; + }, 500); + $('#restartBtn').hide(); + if ($("#pauseBtn").replace(/^.*[\\\/]/, '') == "btn_pause.svg") { + $("#pauseBtn").attr("src","./images/btn_resume.svg"); + } else { + $("#pauseBtn").attr("src","./images/btn_pause.svg"); + } } function hideText() { - $(".overlay").fadeOut("1000", function() { - $(".overlay").html(""); - }) + $(".overlay").fadeOut("1000", function() { + $(".overlay").html(""); + }) } function gameOverDisplay() { - if( localStorage.getItem("been_mobile") != "true" || true){ - settings.ending_block=true; - if(settings.os == "android"){ - sweetAlert({ - title: "Hey we'll only bother you once ", - text:"We do have an Android app!", - showCancelButton: true, - closeOnCancel: true , - confirmButtonText: "Take me to it!", - },function(isConfirm){ - if(isConfirm){ - window.location.href="https://play.google.com/store/apps/details?id=com.hextris.hextris" - } - else{ - settings.end_block=false; - } - - }); - } - if(settings.os == "ios"){ - sweetAlert({ - title: "Hey we'll only bother you once ", - text:"We do have an IOS app!", - showCancelButton: true, - closeOnCancel: true , - confirmButtonText: "Take me to it!", - },function(isConfirm){ - if(isConfirm){ - window.location.href="https://itunes.apple.com/us/app/hextris/id903769553?mt=8"; - } - else{ - settings.end_block=false; - } - }); - } + if( localStorage.getItem("been_mobile") != "true" || true){ + settings.ending_block=true; + if(settings.os == "android"){ + sweetAlert({ + title: "Hey we'll only bother you once ", + text:"We do have an Android app!", + showCancelButton: true, + closeOnCancel: true , + confirmButtonText: "Take me to it!", + },function(isConfirm){ + if(isConfirm){ + window.location.href="https://play.google.com/store/apps/details?id=com.hextris.hextris" + } + else{ + settings.end_block=false; + } + + }); + } + if(settings.os == "ios"){ + sweetAlert({ + title: "Hey we'll only bother you once ", + text:"We do have an IOS app!", + showCancelButton: true, + closeOnCancel: true , + confirmButtonText: "Take me to it!", + },function(isConfirm){ + if(isConfirm){ + window.location.href="https://itunes.apple.com/us/app/hextris/id903769553?mt=8"; + } + else{ + settings.end_block=false; + } + }); + } - } - localStorage.setItem("been_mobile", "true"); - $("#attributions").show(); - var c = document.getElementById("canvas"); - c.className = "blur"; - showText('gameover'); - showbottombar(); + } + localStorage.setItem("been_mobile", "true"); + $("#attributions").show(); + var c = document.getElementById("canvas"); + c.className = "blur"; + showText('gameover'); + showbottombar(); } function pause(o) { - writeHighScores(); - var message; - if (o) { - message = ''; - } else { - message = 'paused'; - } + writeHighScores(); + var message; + if (o) { + message = ''; + } else { + message = 'paused'; + } - var c = document.getElementById("canvas"); - if (gameState == -1) { - $('#restartBtn').fadeOut(150, "linear"); - if ($('#helpScreen').is(':visible')) { - $('#helpScreen').fadeOut(150, "linear"); - } + var c = document.getElementById("canvas"); + if (gameState == -1) { + $('#restartBtn').fadeOut(150, "linear"); + if ($('#helpScreen').is(':visible')) { + $('#helpScreen').fadeOut(150, "linear"); + } - $("#pauseBtn").attr("src", "./images/btn_pause.svg"); - $('.helpText').fadeOut(200, 'linear'); - hideText(); - hidebottombar(); - setTimeout(function() { - gameState = prevGameState; - }, 200) - } else if (gameState != -2 && gameState !== 0 && gameState !== 2) { - $('#restartBtn').fadeIn(150, "linear"); - $('.helpText').fadeIn(200, 'linear'); - showbottombar(); - if (message == 'paused') { - showText(message); - } + $("#pauseBtn").attr("src", "./images/btn_pause.svg"); + $('.helpText').fadeOut(200, 'linear'); + hideText(); + hidebottombar(); + setTimeout(function() { + gameState = prevGameState; + }, 200) + } else if (gameState != -2 && gameState !== 0 && gameState !== 2) { + $('#restartBtn').fadeIn(150, "linear"); + $('.helpText').fadeIn(200, 'linear'); + showbottombar(); + if (message == 'paused') { + showText(message); + } - $("#pauseBtn").attr("src","./images/btn_resume.svg"); - prevGameState = gameState; - gameState = -1; - } + $("#pauseBtn").attr("src","./images/btn_resume.svg"); + prevGameState = gameState; + gameState = -1; + } } diff --git a/js_v9/wavegen.js b/js_v9/wavegen.js index 6cf99f9..a4e85ff 100644 --- a/js_v9/wavegen.js +++ b/js_v9/wavegen.js @@ -1,201 +1,201 @@ function blockDestroyed() { - if (waveone.nextGen > 1350) { - waveone.nextGen -= 30 * settings.creationSpeedModifier; - } else if (waveone.nextGen > 600) { - waveone.nextGen -= 8 * settings.creationSpeedModifier; - } else { - waveone.nextGen = 600; - } + if (waveone.nextGen > 1350) { + waveone.nextGen -= 30 * settings.creationSpeedModifier; + } else if (waveone.nextGen > 600) { + waveone.nextGen -= 8 * settings.creationSpeedModifier; + } else { + waveone.nextGen = 600; + } - if (waveone.difficulty < 35) { - waveone.difficulty += 0.085 * settings.speedModifier; - } else { - waveone.difficulty = 35; - } + if (waveone.difficulty < 35) { + waveone.difficulty += 0.085 * settings.speedModifier; + } else { + waveone.difficulty = 35; + } } function waveGen(hex) { - this.lastGen = 0; - this.last = 0; - this.nextGen = 2700; - this.start = 0; - this.colors = colors; - this.ct = 0; - this.hex = hex; - this.difficulty = 1; - this.dt = 0; - this.update = function() { - this.currentFunction(); - this.dt = (settings.platform == 'mobile' ? 14 : 16.6667) * MainHex.ct; - this.computeDifficulty(); - if ((this.dt - this.lastGen) * settings.creationSpeedModifier > this.nextGen) { - if (this.nextGen > 600) { - this.nextGen -= 11 * ((this.nextGen / 1300)) * settings.creationSpeedModifier; - } - } - }; + this.lastGen = 0; + this.last = 0; + this.nextGen = 2700; + this.start = 0; + this.colors = colors; + this.ct = 0; + this.hex = hex; + this.difficulty = 1; + this.dt = 0; + this.update = function() { + this.currentFunction(); + this.dt = (settings.platform == 'mobile' ? 14 : 16.6667) * MainHex.ct; + this.computeDifficulty(); + if ((this.dt - this.lastGen) * settings.creationSpeedModifier > this.nextGen) { + if (this.nextGen > 600) { + this.nextGen -= 11 * ((this.nextGen / 1300)) * settings.creationSpeedModifier; + } + } + }; - this.randomGeneration = function() { - if (this.dt - this.lastGen > this.nextGen) { - this.ct++; - this.lastGen = this.dt; - var fv = randInt(0, MainHex.sides); - addNewBlock(fv, colors[randInt(0, colors.length)], 1.6 + (this.difficulty / 15) * 3); - var lim = 5; - if (this.ct > lim) { - var nextPattern = randInt(0, 3 + 21); - if (nextPattern > 15) { - this.ct = 0; - this.currentFunction = this.doubleGeneration; - } else if (nextPattern > 10) { - this.ct = 0; - this.currentFunction = this.crosswiseGeneration; - } else if (nextPattern > 7) { - this.ct = 0; - this.currentFunction = this.spiralGeneration; - } else if (nextPattern > 4) { - this.ct = 0; - this.currentFunction = this.circleGeneration; - } else if (nextPattern > 1) { - this.ct = 0; - this.currentFunction = this.halfCircleGeneration; - } - } - } - }; + this.randomGeneration = function() { + if (this.dt - this.lastGen > this.nextGen) { + this.ct++; + this.lastGen = this.dt; + var fv = randInt(0, MainHex.sides); + addNewBlock(fv, colors[randInt(0, colors.length)], 1.6 + (this.difficulty / 15) * 3); + var lim = 5; + if (this.ct > lim) { + var nextPattern = randInt(0, 3 + 21); + if (nextPattern > 15) { + this.ct = 0; + this.currentFunction = this.doubleGeneration; + } else if (nextPattern > 10) { + this.ct = 0; + this.currentFunction = this.crosswiseGeneration; + } else if (nextPattern > 7) { + this.ct = 0; + this.currentFunction = this.spiralGeneration; + } else if (nextPattern > 4) { + this.ct = 0; + this.currentFunction = this.circleGeneration; + } else if (nextPattern > 1) { + this.ct = 0; + this.currentFunction = this.halfCircleGeneration; + } + } + } + }; - this.computeDifficulty = function() { - if (this.difficulty < 35) { - var increment; - if (this.difficulty < 8) { - increment = (this.dt - this.last) / (5166667) * settings.speedModifier; - } else if (this.difficulty < 15) { - increment = (this.dt - this.last) / (72333333) * settings.speedModifier; - } else { - increment = (this.dt - this.last) / (90000000) * settings.speedModifier; - } + this.computeDifficulty = function() { + if (this.difficulty < 35) { + var increment; + if (this.difficulty < 8) { + increment = (this.dt - this.last) / (5166667) * settings.speedModifier; + } else if (this.difficulty < 15) { + increment = (this.dt - this.last) / (72333333) * settings.speedModifier; + } else { + increment = (this.dt - this.last) / (90000000) * settings.speedModifier; + } - this.difficulty += increment * (1/2); - } - }; + this.difficulty += increment * (1/2); + } + }; - this.circleGeneration = function() { - if (this.dt - this.lastGen > this.nextGen + 500) { - var numColors = randInt(1, 4); - if (numColors == 3) { - numColors = randInt(1, 4); - } + this.circleGeneration = function() { + if (this.dt - this.lastGen > this.nextGen + 500) { + var numColors = randInt(1, 4); + if (numColors == 3) { + numColors = randInt(1, 4); + } - var colorList = []; - nextLoop: for (var i = 0; i < numColors; i++) { - var q = randInt(0, colors.length); - for (var j in colorList) { - if (colorList[j] == colors[q]) { - i--; - continue nextLoop; - } - } - colorList.push(colors[q]); - } + var colorList = []; + nextLoop: for (var i = 0; i < numColors; i++) { + var q = randInt(0, colors.length); + for (var j in colorList) { + if (colorList[j] == colors[q]) { + i--; + continue nextLoop; + } + } + colorList.push(colors[q]); + } - for (var i = 0; i < MainHex.sides; i++) { - addNewBlock(i, colorList[i % numColors], 1.5 + (this.difficulty / 15) * 3); - } + for (var i = 0; i < MainHex.sides; i++) { + addNewBlock(i, colorList[i % numColors], 1.5 + (this.difficulty / 15) * 3); + } - this.ct += 15; - this.lastGen = this.dt; - this.shouldChangePattern(1); - } - }; + this.ct += 15; + this.lastGen = this.dt; + this.shouldChangePattern(1); + } + }; - this.halfCircleGeneration = function() { - if (this.dt - this.lastGen > (this.nextGen + 500) / 2) { - var numColors = randInt(1, 3); - var c = colors[randInt(0, colors.length)]; - var colorList = [c, c, c]; - if (numColors == 2) { - colorList = [c, colors[randInt(0, colors.length)], c]; - } + this.halfCircleGeneration = function() { + if (this.dt - this.lastGen > (this.nextGen + 500) / 2) { + var numColors = randInt(1, 3); + var c = colors[randInt(0, colors.length)]; + var colorList = [c, c, c]; + if (numColors == 2) { + colorList = [c, colors[randInt(0, colors.length)], c]; + } - var d = randInt(0, 6); - for (var i = 0; i < 3; i++) { - addNewBlock((d + i) % 6, colorList[i], 1.5 + (this.difficulty / 15) * 3); - } + var d = randInt(0, 6); + for (var i = 0; i < 3; i++) { + addNewBlock((d + i) % 6, colorList[i], 1.5 + (this.difficulty / 15) * 3); + } - this.ct += 8; - this.lastGen = this.dt; - this.shouldChangePattern(); - } - }; + this.ct += 8; + this.lastGen = this.dt; + this.shouldChangePattern(); + } + }; - this.crosswiseGeneration = function() { - if (this.dt - this.lastGen > this.nextGen) { - var ri = randInt(0, colors.length); - var i = randInt(0, colors.length); - addNewBlock(i, colors[ri], 0.6 + (this.difficulty / 15) * 3); - addNewBlock((i + 3) % MainHex.sides, colors[ri], 0.6 + (this.difficulty / 15) * 3); - this.ct += 1.5; - this.lastGen = this.dt; - this.shouldChangePattern(); - } - }; + this.crosswiseGeneration = function() { + if (this.dt - this.lastGen > this.nextGen) { + var ri = randInt(0, colors.length); + var i = randInt(0, colors.length); + addNewBlock(i, colors[ri], 0.6 + (this.difficulty / 15) * 3); + addNewBlock((i + 3) % MainHex.sides, colors[ri], 0.6 + (this.difficulty / 15) * 3); + this.ct += 1.5; + this.lastGen = this.dt; + this.shouldChangePattern(); + } + }; - this.spiralGeneration = function() { - var dir = randInt(0, 2); - if (this.dt - this.lastGen > this.nextGen * (2 / 3)) { - if (dir) { - addNewBlock(5 - (this.ct % MainHex.sides), colors[randInt(0, colors.length)], 1.5 + (this.difficulty / 15) * (3 / 2)); - } else { - addNewBlock(this.ct % MainHex.sides, colors[randInt(0, colors.length)], 1.5 + (this.difficulty / 15) * (3 / 2)); - } - this.ct += 1; - this.lastGen = this.dt; - this.shouldChangePattern(); - } - }; + this.spiralGeneration = function() { + var dir = randInt(0, 2); + if (this.dt - this.lastGen > this.nextGen * (2 / 3)) { + if (dir) { + addNewBlock(5 - (this.ct % MainHex.sides), colors[randInt(0, colors.length)], 1.5 + (this.difficulty / 15) * (3 / 2)); + } else { + addNewBlock(this.ct % MainHex.sides, colors[randInt(0, colors.length)], 1.5 + (this.difficulty / 15) * (3 / 2)); + } + this.ct += 1; + this.lastGen = this.dt; + this.shouldChangePattern(); + } + }; - this.doubleGeneration = function() { - if (this.dt - this.lastGen > this.nextGen) { - var i = randInt(0, colors.length); - addNewBlock(i, colors[randInt(0, colors.length)], 1.5 + (this.difficulty / 15) * 3); - addNewBlock((i + 1) % MainHex.sides, colors[randInt(0, colors.length)], 1.5 + (this.difficulty / 15) * 3); - this.ct += 2; - this.lastGen = this.dt; - this.shouldChangePattern(); - } - }; + this.doubleGeneration = function() { + if (this.dt - this.lastGen > this.nextGen) { + var i = randInt(0, colors.length); + addNewBlock(i, colors[randInt(0, colors.length)], 1.5 + (this.difficulty / 15) * 3); + addNewBlock((i + 1) % MainHex.sides, colors[randInt(0, colors.length)], 1.5 + (this.difficulty / 15) * 3); + this.ct += 2; + this.lastGen = this.dt; + this.shouldChangePattern(); + } + }; - this.setRandom = function() { - this.ct = 0; - this.currentFunction = this.randomGeneration; - }; + this.setRandom = function() { + this.ct = 0; + this.currentFunction = this.randomGeneration; + }; - this.shouldChangePattern = function(x) { - if (x) { - var q = randInt(0, 4); - this.ct = 0; - switch (q) { - case 0: - this.currentFunction = this.doubleGeneration; - break; - case 1: - this.currentFunction = this.spiralGeneration; - break; - case 2: - this.currentFunction = this.crosswiseGeneration; - break; - } - } else if (this.ct > 8) { - if (randInt(0, 2) === 0) { - this.setRandom(); - return 1; - } - } + this.shouldChangePattern = function(x) { + if (x) { + var q = randInt(0, 4); + this.ct = 0; + switch (q) { + case 0: + this.currentFunction = this.doubleGeneration; + break; + case 1: + this.currentFunction = this.spiralGeneration; + break; + case 2: + this.currentFunction = this.crosswiseGeneration; + break; + } + } else if (this.ct > 8) { + if (randInt(0, 2) === 0) { + this.setRandom(); + return 1; + } + } - return 0; - }; + return 0; + }; - // rest of generation functions + // rest of generation functions - this.currentFunction = this.randomGeneration; + this.currentFunction = this.randomGeneration; } diff --git a/style/fa/css/font-awesome.css b/style/fa/css/font-awesome.css index eb4127b..78f1021 100644 --- a/style/fa/css/font-awesome.css +++ b/style/fa/css/font-awesome.css @@ -85,36 +85,36 @@ } @-moz-keyframes spin { 0% { - -moz-transform: rotate(0deg); + -moz-transform: rotate(0deg); } 100% { - -moz-transform: rotate(359deg); + -moz-transform: rotate(359deg); } } @-webkit-keyframes spin { 0% { - -webkit-transform: rotate(0deg); + -webkit-transform: rotate(0deg); } 100% { - -webkit-transform: rotate(359deg); + -webkit-transform: rotate(359deg); } } @-o-keyframes spin { 0% { - -o-transform: rotate(0deg); + -o-transform: rotate(0deg); } 100% { - -o-transform: rotate(359deg); + -o-transform: rotate(359deg); } } @keyframes spin { 0% { - -webkit-transform: rotate(0deg); - transform: rotate(0deg); + -webkit-transform: rotate(0deg); + transform: rotate(0deg); } 100% { - -webkit-transform: rotate(359deg); - transform: rotate(359deg); + -webkit-transform: rotate(359deg); + transform: rotate(359deg); } } .fa-rotate-90 {