removed false gameovers, added css for local fonts
This commit is contained in:
parent
9c5ed782eb
commit
047ca6833d
5 changed files with 84 additions and 47 deletions
57
index.html
57
index.html
|
@ -7,35 +7,42 @@
|
|||
<link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Roboto">
|
||||
<link rel="stylesheet" type="text/css" href="style.css">
|
||||
<style>
|
||||
* {
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Roboto';
|
||||
font-style: normal;
|
||||
font-weight: 400;
|
||||
src: local('Roboto Regular'), local('Roboto-Regular'), url("fonts/roboto.woff") format('woff');
|
||||
}
|
||||
|
||||
body {
|
||||
color: #ecf0f1;
|
||||
font-family: 'Roboto', sans-serif;
|
||||
background-color:#ecf0f1;
|
||||
}
|
||||
* {
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
#clickToExit {
|
||||
cursor:pointer;
|
||||
}
|
||||
body {
|
||||
color: #ecf0f1;
|
||||
font-family: 'Roboto', sans-serif;
|
||||
background-color:#ecf0f1;
|
||||
}
|
||||
|
||||
#canvas {
|
||||
position: absolute;
|
||||
left: calc(50% - 80vmin / 2);
|
||||
height: 80vmin;
|
||||
width: 80vmin;
|
||||
background-color:#ecf0f1;
|
||||
z-index:3;
|
||||
}
|
||||
#clickToExit {
|
||||
cursor:pointer;
|
||||
}
|
||||
|
||||
#title {
|
||||
z-index:99999;
|
||||
margin-top:20px;
|
||||
color:#2c3e50;
|
||||
}
|
||||
#canvas {
|
||||
position: absolute;
|
||||
left: calc(50% - 80vmin / 2);
|
||||
height: 80vmin;
|
||||
width: 80vmin;
|
||||
background-color:#ecf0f1;
|
||||
z-index:3;
|
||||
}
|
||||
|
||||
#title {
|
||||
z-index:99999;
|
||||
margin-top:20px;
|
||||
color:#2c3e50;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
|
|
@ -217,7 +217,6 @@ function Clock(sideLength) {
|
|||
}
|
||||
} else {
|
||||
if (arr[position - 1].settled && block.distFromHex - block.iter - arr[position - 1].distFromHex - arr[position - 1].height <= 0) {
|
||||
debugger;
|
||||
block.distFromHex = arr[position - 1].distFromHex + arr[position - 1].height;
|
||||
block.settled = 1;
|
||||
consolidateBlocks(this, lane, block.getIndex());
|
||||
|
|
23
js/main.js
23
js/main.js
|
@ -30,6 +30,7 @@ var framerate = 60;
|
|||
var history = {};
|
||||
var score = 0;
|
||||
var scoreScalar = 1;
|
||||
var isGameOver = 2;
|
||||
var scoreAdditionCoeff = 1;
|
||||
var prevScore = 0;
|
||||
var numHighScores = 3;
|
||||
|
@ -58,6 +59,7 @@ function init() {
|
|||
history = {};
|
||||
importedHistory = undefined;
|
||||
importing = 0;
|
||||
isGameOver = 2;
|
||||
score = 0;
|
||||
prevScore = 0;
|
||||
spawnLane = 0;
|
||||
|
@ -210,6 +212,9 @@ function render() {
|
|||
if (gameState == -2) {
|
||||
if (Date.now() - startTime > 1300) {
|
||||
var op = (Date.now() - startTime - 1300)/500;
|
||||
if (op > 1) {
|
||||
op = 1;
|
||||
}
|
||||
ctx.globalAlpha = op;
|
||||
drawPolygon(canvas.originalWidth / 2 , canvas.originalHeight / 2 , 6, 220, 30, "#bdc3c7", false,6);
|
||||
ctx.globalAlpha = 1;
|
||||
|
@ -259,12 +264,19 @@ function getStepDY(t, b, c, d) {
|
|||
}
|
||||
}
|
||||
|
||||
isGameOver--;
|
||||
|
||||
function animLoop() {
|
||||
if (gameState == 1) {
|
||||
requestAnimFrame(animLoop);
|
||||
update();
|
||||
render();
|
||||
checkGameOver();
|
||||
if (checkGameOver()) {
|
||||
isGameOver--;
|
||||
if (isGameOver === 0) {
|
||||
gameState = 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (gameState === 0) {
|
||||
clearGameBoard();
|
||||
|
@ -304,19 +316,18 @@ function animLoop() {
|
|||
}
|
||||
// }
|
||||
}
|
||||
|
||||
requestAnimFrame(animLoop);
|
||||
|
||||
function checkGameOver() {
|
||||
for (var i = 0; i < MainClock.sides; i++) {
|
||||
if (MainClock.blocks[i].length > 8) {
|
||||
gameState = 2;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
window.onblur = function (e) {
|
||||
if (gameState == 1) gameState = -1;
|
||||
}
|
||||
|
||||
|
||||
// window.onblur = function (e) {
|
||||
// if (gameState == 1) gameState = -1;
|
||||
// }
|
|
@ -29,8 +29,8 @@ function waveGen(clock) {
|
|||
this.ct++;
|
||||
this.lastGen = this.dt;
|
||||
var fv = randInt(0, MainClock.sides);
|
||||
addNewBlock(fv, colors[randInt(0, colors.length)], 1.2 + (this.integerDifficulty/15) * 3);
|
||||
if (this.ct > 5) {
|
||||
addNewBlock(fv, colors[randInt(0, colors.length)], 1.5 + (this.integerDifficulty/15) * 3);
|
||||
if (this.ct > 7) {
|
||||
var nextPattern = randInt(0, 20 + 4);
|
||||
if (nextPattern > 4 + 17) {
|
||||
this.ct = 0;
|
||||
|
@ -84,12 +84,12 @@ function waveGen(clock) {
|
|||
}
|
||||
|
||||
for (var i = 0; i < MainClock.sides; i++) {
|
||||
addNewBlock(i, colorList[i % numColors], 1.2 + (this.integerDifficulty/15) * 3);
|
||||
addNewBlock(i, colorList[i % numColors], 1.5 + (this.integerDifficulty/15) * 3);
|
||||
}
|
||||
|
||||
this.ct += 15;
|
||||
this.lastGen = this.dt;
|
||||
this.shouldGoBackToRandom();
|
||||
this.shouldChangePattern(1);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -101,27 +101,33 @@ function waveGen(clock) {
|
|||
addNewBlock((i + 3) % MainClock.sides, colors[ri], 0.6 + (this.integerDifficulty/15) * 3);
|
||||
this.ct += 1.5;
|
||||
this.lastGen = this.dt;
|
||||
this.shouldGoBackToRandom();
|
||||
this.shouldChangePattern();
|
||||
}
|
||||
};
|
||||
|
||||
this.spiralGeneration = function() {
|
||||
if (this.dt - this.lastGen > this.nextGen * (2/3)) {
|
||||
addNewBlock(this.ct % MainClock.sides, colors[randInt(0, colors.length)], 1.2 + (this.integerDifficulty/15) * (3/2));
|
||||
var dir = randInt(0, 2);
|
||||
if (this.dt - this.lastGen > this.nextGen * (5/9)) {
|
||||
if (dir) {
|
||||
addNewBlock(5 - (this.ct % MainClock.sides), colors[randInt(0, colors.length)], 1.5 + (this.integerDifficulty/15) * (3/2));
|
||||
}
|
||||
else {
|
||||
addNewBlock(this.ct % MainClock.sides, colors[randInt(0, colors.length)], 1.5 + (this.integerDifficulty/15) * (3/2));
|
||||
}
|
||||
this.ct += 1;
|
||||
this.lastGen = this.dt;
|
||||
this.shouldGoBackToRandom();
|
||||
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.2 + (this.integerDifficulty/15) * 3);
|
||||
addNewBlock((i + 1) % MainClock.sides, colors[randInt(0, colors.length)], 1.2 + (this.integerDifficulty/15) * 3);
|
||||
addNewBlock(i, colors[randInt(0, colors.length)], 1.5 + (this.integerDifficulty/15) * 3);
|
||||
addNewBlock((i + 1) % MainClock.sides, colors[randInt(0, colors.length)], 1.5 + (this.integerDifficulty/15) * 3);
|
||||
this.ct += 2;
|
||||
this.lastGen = this.dt;
|
||||
this.shouldGoBackToRandom();
|
||||
this.shouldChangePattern();
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -130,8 +136,23 @@ function waveGen(clock) {
|
|||
this.currentFunction = this.randomGeneration;
|
||||
};
|
||||
|
||||
this.shouldGoBackToRandom = function() {
|
||||
if (this.ct > 8) {
|
||||
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;
|
||||
|
|
3
vendor/hammer.min.js
vendored
3
vendor/hammer.min.js
vendored
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue