Merge branch 'master' of http://github.com/teamsnowman/hextris into gh-pages

Conflicts:
	js/checking.js
This commit is contained in:
garrettdreyfus 2014-05-20 22:39:03 -04:00
commit 02a46580af
4 changed files with 22 additions and 28 deletions

View file

@ -20,7 +20,6 @@
<div style="margin: 1vmin auto 0 auto; width: 100%; text-align: center;">
<h1 style="color: #ecf0f1; font-size: 10vmin;">Hextris</h1>
<span id="score" style="color: #ecf0f1; font-size: 4vmin;">0 (x1)</span>
</div>
<canvas id="canvas" width="800" height="800" style="position: absolute; left: calc(50% - 80vmin / 2); height: 80vmin; width: 80vmin; background-color: rgba(0,0,0,0);"></canvas>

View file

@ -1,24 +0,0 @@
floodFill.deleted = [];
function floodFill(clock,side,index) {
if(clock.blocks[side] !== undefined){return;}
if(clock.blocks[side][index] !== undefined){return;}
var color = clock.blocks[side][index].color;
var arrX = [-1,0,1];
var arrY = [-1,0,1];
for( X in arrX){
for(Y in arrY){
var x = arrX[X];
var y = arrY[Y];
if(x==0 && y==0){return;}
if(clock.blocks[(side+x+clock.sides)%clock.sides][index+y] !== undefined){
if(clock.blocks[(side+x+clock.sides)%clock.sides][index+y].color== color && floodFill.deleted.indexOf([side+x,index+y]) == -1){
deleted.push([(side+x+clock.sides)%clock.sides,index+y]);
floodFill(clock,(side+x+clock.sides)%clock.sides,index+y);
}
}
}
}
}

View file

@ -95,10 +95,12 @@ function update() {
}
function render() {
document.getElementById("score").innerHTML = score + " (x" + scoreScalar * scoreAdditionCoeff + ")";
// document.getElementById("score").innerHTML =;
ctx.clearRect(0, 0, canvas.originalWidth, canvas.originalHeight);
clearGameBoard();
renderText(score + " (x" + scoreScalar * scoreAdditionCoeff + ")", canvas.originalWidth/2, canvas.originalHeight/2 - 360);
var i;
for (i in MainClock.blocks) {

View file

@ -18,6 +18,23 @@ function showModal(text, secondaryText) {
ctx.fillText(secondaryText, canvas.originalWidth / 2, canvas.originalHeight / 2 + fontSizeLarge / 4 + fontSizeSmall / 4 + 30);
}
function renderText(lines, x, y, fontSize) {
if(typeof lines == 'string' || lines instanceof String) {
lines = [lines];
}
var fontSize = fontSize || 50;
ctx.font = fontSize + 'px Roboto'; // figure out what is not working
ctx.textAlign = 'center';
ctx.fillStyle = 'white';
for(var i=0; i<lines.length; i++) {
ctx.fillText(lines[i], x, y + (fontSize / 4) * (i+1) + 30 * i );
}
}
function clearShadows() {
ctx.shadowColor = 0;
ctx.shadowBlur = 0;
@ -27,7 +44,7 @@ function clearShadows() {
function clearGameBoard() {
ctx.shadowColor = '#2980b9';
ctx.shadowBlur = 25;
//ctx.shadowBlur = 25;
drawPolygon(canvas.originalWidth / 2, canvas.originalHeight / 2, 6, canvas.originalWidth / 2 - 25, 30, hexagonBackgroundColor);
clearShadows();
}
@ -66,4 +83,4 @@ function drawPolygon(x, y, sides, radius, theta, color, fill) { // can make more
} else {
ctx.stroke();
}
};
};