trying to fix white gaps
This commit is contained in:
parent
9109c73d10
commit
d32e16b205
5 changed files with 30 additions and 5 deletions
|
@ -66,7 +66,7 @@ function consolidateBlocks(clock,side,index) {
|
|||
deleted.push([]);
|
||||
}
|
||||
eraseBlocks(clock,deleted);
|
||||
return
|
||||
return;
|
||||
}
|
||||
|
||||
function eraseBlocks(clock,deleted) {
|
||||
|
|
12
entities.js
12
entities.js
|
@ -88,22 +88,34 @@ function Clock(sideLength) {
|
|||
if (position <= 0) {
|
||||
if (block.distFromHex - (this.sideLength/2) * Math.sqrt(3) <= 0) {
|
||||
block.settled = 1;
|
||||
if (iter == 2 && block.distFromHex + 1 - (this.sideLength/2) * Math.sqrt(3) <= 0) {
|
||||
block.distFromHex--;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (block.distFromHex + iter - arr[position - 1].distFromHex - arr[position - 1].height <= 0) {
|
||||
block.settled = 1;
|
||||
if (iter == 2 && block.distFromHex + 1 + iter - arr[position - 1].distFromHex - arr[position - 1].height <= 0) {
|
||||
block.distFromHex--;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (arr.length > 0) {
|
||||
if (block.distFromHex + iter - arr[arr.length - 1].distFromHex - arr[arr.length - 1].height <= 0) {
|
||||
if (iter == 2 && block.distFromHex + iter + 1 - arr[arr.length - 1].distFromHex - arr[arr.length - 1].height <= 0) {
|
||||
block.distFromHex--;
|
||||
}
|
||||
this.addBlock(block);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (block.distFromHex + iter - (this.sideLength/2) * Math.sqrt(3) <= 0) {
|
||||
if (iter == 2 && block.distFromHex + iter + 1 - (this.sideLength/2) * Math.sqrt(3) <= 0) {
|
||||
block.distFromHex--;
|
||||
}
|
||||
this.addBlock(block);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,11 +17,11 @@
|
|||
</head>
|
||||
<body style="background-color:#2c3e50">
|
||||
|
||||
<div style='margin: 0 auto; width: 100%;text-align: center; margin-top: 50px;'><h1 style='color:#ecf0f1; font-size:50px;'>Hextris</h1>
|
||||
<div style='margin: 0 auto; width: 100%;text-align: center; margin-top: 20px;'><h1 style='color:#ecf0f1; font-size:50px;'>Hextris</h1>
|
||||
<span id="score">0 (x1)</span>
|
||||
</div>
|
||||
|
||||
<canvas id="canvas" width = '700' height = '700' style='background-color:#2c3e50; position:absolute;left:50%;margin-left:-350px;'></canvas>
|
||||
<canvas id="canvas" width = '700' height = '700' style='background-color:#2c3e50; position:absolute;left:50%;margin-left:-350px'></canvas>
|
||||
|
||||
<script src="math.js"></script>
|
||||
<script src="entities.js"></script>
|
||||
|
|
12
input.js
12
input.js
|
@ -16,3 +16,15 @@ keypress.register_combo({
|
|||
}
|
||||
},
|
||||
});
|
||||
|
||||
keypress.register_combo({
|
||||
keys: "space",
|
||||
on_keyup: function(){
|
||||
iter = 1;
|
||||
scoreAdditionCoeff = 1;
|
||||
},
|
||||
on_keydown: function() {
|
||||
iter = 2;
|
||||
scoreAdditionCoeff = 2;
|
||||
}
|
||||
});
|
||||
|
|
5
main.js
5
main.js
|
@ -42,9 +42,10 @@ function init() {
|
|||
var colors = ["#e74c3c", "#f1c40f","#3498db"];
|
||||
var hexagonBackgroundColor = '#ecf0f1';
|
||||
var swegBlue = '#2c3e50'; //tumblr?
|
||||
var scoreAdditionCoeff = 1;
|
||||
|
||||
function render() {
|
||||
document.getElementById("score").innerHTML = score + " (x"+scoreScalar+")";
|
||||
document.getElementById("score").innerHTML = score + " (x"+scoreScalar * scoreAdditionCoeff+")";
|
||||
var now = Date.now();
|
||||
if(now - lastGen > nextGen) {
|
||||
blocks.push(new Block(randInt(0, 6), colors[randInt(0, colors.length)]));
|
||||
|
@ -52,7 +53,7 @@ function render() {
|
|||
nextGen = randInt(500/iter, 1500/iter);
|
||||
}
|
||||
if(now - prevScore > 1000) {
|
||||
score += 5 * scoreScalar;
|
||||
score += 5 * (scoreScalar * scoreAdditionCoeff);
|
||||
prevScore = now;
|
||||
iter += 0.1;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue