fixed merge conflicts
This commit is contained in:
commit
f6ecba5024
5 changed files with 22 additions and 29 deletions
|
@ -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: -webkit-radial-gradient(#2980b9 35%,rgba(44,62,80,50) 68%);"></canvas>
|
||||
|
|
|
@ -12,7 +12,7 @@ function floodFill(clock,side,index) {
|
|||
var color = clock.blocks[side][index].color;
|
||||
for(var x =-1;x<2;x++){
|
||||
for(var y =-1;y<2;y++){
|
||||
if(x==y){continue;}
|
||||
if(Math.abs(x)==Math.abs(y)){continue;}
|
||||
if(clock.blocks[(side+x+clock.sides)%clock.sides] === undefined){continue;}
|
||||
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 && search(deleting,[(side+x+clock.sides)%clock.sides,index+y]) == false){
|
||||
|
@ -28,7 +28,7 @@ function consolidateBlocks(clock,side,index){
|
|||
deleting=[];
|
||||
deleting.push([side,index]);
|
||||
floodFill(clock,side,index);
|
||||
debugger;
|
||||
|
||||
var deleteList= deleting;
|
||||
if(deleteList.length<3){return;}
|
||||
for(i in deleteList){
|
||||
|
|
24
js/hey.js
24
js/hey.js
|
@ -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);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -97,9 +97,10 @@ function update() {
|
|||
|
||||
function render() {
|
||||
document.getElementById("score").innerHTML = score + " (x" + scoreScalar * scoreAdditionCoeff + ")";
|
||||
|
||||
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) {
|
||||
|
|
19
js/view.js
19
js/view.js
|
@ -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;
|
||||
|
@ -66,4 +83,4 @@ function drawPolygon(x, y, sides, radius, theta, color, fill) { // can make more
|
|||
} else {
|
||||
ctx.stroke();
|
||||
}
|
||||
};
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue