This commit is contained in:
meadowstream 2014-05-24 14:12:19 -04:00
commit aa75117137
5 changed files with 37 additions and 43 deletions

View file

@ -12,11 +12,13 @@ function floodFill(clock,side,index,deleting) {
for(var x =-1;x<2;x++){
for(var y =-1;y<2;y++){
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) {
deleting.push([(side+x+clock.sides)%clock.sides,index+y]);
floodFill(clock,(side+x+clock.sides)%clock.sides,index+y,deleting);
var curSide =(side+x+clock.sides)%clock.sides;
var curIndex = index+y;
if(clock.blocks[curSide] === undefined){continue;}
if(clock.blocks[curSide][curIndex] !== undefined){
if(clock.blocks[curSide][curIndex].color == color && search(deleting,[curSide,curIndex]) === false) {
deleting.push([curSide,curIndex]);
floodFill(clock,curSide,curIndex,deleting);
}
}
}

View file

@ -13,7 +13,7 @@ function Block(lane, color, iter, distFromHex, settled) {
this.removed = 0;
this.tint = 0; //todo
this.opacity = 1;
this.initializing = 1;
this.initialization = 1;
this.parentArr;
this.iter = iter;
@ -28,10 +28,7 @@ function Block(lane, color, iter, distFromHex, settled) {
var lane = MainClock.sides - this.lane;// -this.position;
lane += MainClock.position;
while (lane < 0) {
lane += MainClock.sides;
}
lane = lane % MainClock.sides;
lane = (lane+MainClock.sides) % MainClock.sides;
this.opacity = this.opacity - 0.1;
if (this.opacity <= 0) {
@ -173,10 +170,7 @@ function Clock(sideLength) {
var lane = this.sides - block.lane;// -this.position;
this.shakes.push({lane:block.lane, magnitude:2});
lane += this.position;
while (lane < 0) {
lane += this.sides;
}
lane = lane % this.sides;
lane = (lane+this.sides) % this.sides;
block.distFromHex = MainClock.sideLength / 2 * Math.sqrt(3) + block.height * this.blocks[lane].length;
this.blocks[lane].push(block);
block.parentArr = this.blocks[lane];
@ -191,10 +185,7 @@ function Clock(sideLength) {
var lane = this.sides - block.lane;// -this.position;
lane += this.position;
while (lane < 0) {
lane += this.sides;
}
lane = lane % this.sides;
lane = (lane+this.sides) % this.sides;
var arr = this.blocks[lane];
if (position !== undefined) {

View file

@ -146,8 +146,7 @@ function update() {
var objectsToRemove = [];
for (i in blocks) {
MainClock.doesBlockCollide(blocks[i]);
if (!blocks[i].settled && !blocks[i].initializing) {
debugger;
if (!blocks[i].settled) {
blocks[i].distFromHex -= blocks[i].iter;
} else if(!blocks[i].removed){
blocks[i].removed = 1;
@ -189,12 +188,11 @@ function render() {
}
for (i in blocks) {
debugger;
blocks[i].draw();
}
MainClock.draw();
drawPolygon(canvas.originalWidth / 2, MainClock.y + MainClock.dy, 6, 220, 30, '#95a5a6', false);
drawPolygon(canvas.originalWidth / 2 , canvas.originalHeight / 2 , 6, 220, 30, '#BDA0CB', false,6);
}
function stepInitialLoad() {

View file

@ -52,10 +52,13 @@ function clearGameBoard() {
// clearShadows();
}
function drawPolygon(x, y, sides, radius, theta, color, fill) { // can make more elegant, reduce redundancy, fix readability
function drawPolygon(x, y, sides, radius, theta, color, fill, lineWidth) { // can make more elegant, reduce redundancy, fix readability
if (fill == undefined) {
fill = true;
}
if (lineWidth == undefined) {
lineWidth = 3;
}
if (fill) {
ctx.fillStyle = color;
} else {
@ -64,7 +67,7 @@ function drawPolygon(x, y, sides, radius, theta, color, fill) { // can make more
// ctx.shadowColor = '#2ecc71';
// ctx.shadowBlur = 10;
// ctx.strokeStyle = rgba(0,0,0,0);
ctx.lineWidth = 3;
ctx.lineWidth = lineWidth;
ctx.strokeStyle = color;
}
@ -106,4 +109,4 @@ function toggleClass(element, active) {
else {
$(element).addClass(active);
}
}
}

View file

@ -13,7 +13,7 @@ function waveGen(clock) {
this.difficulty = 0;
this.integerDifficulty = this.difficulty;
this.dt = 0;
this.currentFunction = this.circleGeneration;
this.update = function() {
this.currentFunction();
this.dt += 16.6666667;
@ -32,21 +32,21 @@ function waveGen(clock) {
var fv = randInt(0, MainClock.sides);
addNewBlock(fv, colors[randInt(0, colors.length)], 1.2 + (this.integerDifficulty/15) * 3);
if (this.ct > 5) {
var nextPattern = randInt(0, 20 + 4);
if (nextPattern > 4 + 17) {
this.ct = 0;
this.currentFunction = this.doubleGeneration;
} else if (nextPattern > 4 + 14) {
this.ct = 0;
this.currentFunction = this.crosswiseGeneration;
} else if (nextPattern > 4 + 11) {
this.ct = 0;
this.currentFunction = this.spiralGeneration;
}
else if (nextPattern > 4 + 8) {
//var nextPattern = randInt(0, 20 + 4);
//if (nextPattern > 4 + 17) {
//this.ct = 0;
//this.currentFunction = this.doubleGeneration;
//} else if (nextPattern > 4 + 14) {
//this.ct = 0;
//this.currentFunction = this.crosswiseGeneration;
//} else if (nextPattern > 4 + 11) {
//this.ct = 0;
//this.currentFunction = this.spiralGeneration;
//}
//else if (nextPattern > 4 + 8) {
this.ct = 0;
this.currentFunction = this.circleGeneration;
}
//}
}
}
@ -66,9 +66,9 @@ function waveGen(clock) {
this.circleGeneration = function() {
if (this.dt - this.lastGen > this.nextGen + 500) {
var numColors = randInt(0, 4);
var numColors = randInt(1, 4);
if (numColors == 3) {
numColors = randInt(0, 4);
numColors = randInt(1, 4);
}
var colorList = [];
@ -90,7 +90,7 @@ function waveGen(clock) {
this.ct += 15;
this.lastGen = this.dt;
this.shouldGoBackToRandom();
//this.shouldGoBackToRandom();
}
};
@ -153,4 +153,4 @@ function generatorFunction() {
// In each generator function you need a few things
// Something defining when the next block is being generated
// Something defining which and when the next function is going to be passed
// Something defining which and when the next function is going to be passed