Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New combo feature #173

Open
wants to merge 8 commits into
base: gh-pages
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion js/Hex.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,17 @@ function Hex(sideLength) {
this.ct = 0;
this.lastCombo = this.ct - settings.comboTime;
this.lastColorScored = "#000";
this.comboTime = 1;
this.adrenalineMode = -1000;
this.adrenalineDuration = 800;
this.combosToAdrenaline = 9;
this.adrenalineColor = 1;
this.adrenalineMultiplier = 2;

this.adrenalineOn = function(){
return this.ct - this.adrenalineMode < this.adrenalineDuration;
}


this.texts = [];
this.lastRotate = Date.now();
for (var i = 0; i < this.sides; i++) {
Expand Down
7 changes: 6 additions & 1 deletion js/checking.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,17 @@ function consolidateBlocks(hex,side,index){

// add scores
var now = MainHex.ct;
if(now - hex.lastCombo < settings.comboTime ){
if(now - hex.lastCombo < settings.comboTime && !MainHex.adrenalineOn()){
settings.comboTime = (1/settings.creationSpeedModifier) * (waveone.nextGen/16.666667) * 3;
hex.comboMultiplier += 1;
hex.lastCombo = now;
var coords = findCenterOfBlocks(deletedBlocks);
hex.texts.push(new Text(coords['x'],coords['y'],"x "+hex.comboMultiplier.toString(),"bold Q","#fff",fadeUpAndOut));
if(hex.comboMultiplier >= MainHex.combosToAdrenaline){
hex.adrenalineMode = now;
hex.comboMultiplier = 1;
hex.adrenalineColor = randInt(0, colors.length);
}
}
else{
settings.comboTime = 240;
Expand Down
4 changes: 2 additions & 2 deletions js/comboTimer.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ function drawTimer() {
var rightVertexes = [];
if(MainHex.ct - MainHex.lastCombo < settings.comboTime){
for(var i=0;i<6;i++){
var done = (MainHex.ct -MainHex.lastCombo);
var done = (MainHex.ct - MainHex.lastCombo);
if(done<(settings.comboTime)*(5-i)*(1/6)){
leftVertexes.push(calcSide(i,i+1,1,1));
rightVertexes.push(calcSide(12-i,11-i,1,1));
rightVertexes.push(calcSide(12-i,11-i,1,1));
}
else{
leftVertexes.push(calcSide(i,i+1,1-((done*6)/settings.comboTime)%(1),1));
Expand Down
4 changes: 3 additions & 1 deletion js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,9 @@ function init(b) {
}

function addNewBlock(blocklane, color, iter, distFromHex, settled) { //last two are optional parameters
iter *= settings.speedModifier;
if(!MainHex.adrenalineOn())
iter *= settings.speedModifier;
else iter *= settings.speedModifier*MainHex.adrenalineMultiplier;
if (!history[MainHex.ct]) {
history[MainHex.ct] = {};
}
Expand Down
6 changes: 5 additions & 1 deletion js/render.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
function render() {
var grey = '#bdc3c7';
var red = '#ff93a5';
if (gameState === 0) {
grey = "rgb(220, 223, 225)";
}
Expand All @@ -11,7 +12,10 @@ function render() {
op += 0.01;
}
ctx.globalAlpha = op;
drawPolygon(trueCanvas.width / 2 , trueCanvas.height / 2 , 6, (settings.rows * settings.blockHeight) * (2/Math.sqrt(3)) + settings.hexWidth, 30, grey, false,6);
if(MainHex.adrenalineOn())
drawPolygon(trueCanvas.width / 2 , trueCanvas.height / 2 , 6, (settings.rows * settings.blockHeight) * (2/Math.sqrt(3)) + settings.hexWidth, 30, red, false,6);
else
drawPolygon(trueCanvas.width / 2 , trueCanvas.height / 2 , 6, (settings.rows * settings.blockHeight) * (2/Math.sqrt(3)) + settings.hexWidth, 30, grey, false,6);
drawTimer();
ctx.globalAlpha = 1;
}
Expand Down
70 changes: 51 additions & 19 deletions js/wavegen.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,31 @@ function waveGen(hex) {
this.hex = hex;
this.difficulty = 1;
this.dt = 0;
this.adrenalineMultiplier = 1;
this.update = function() {
this.currentFunction();
this.dt = (settings.platform == 'mobile' ? 14 : 16.6667) * MainHex.ct;
this.computeDifficulty();
if(!MainHex.adrenalineOn()){
this.adrenalineMultiplier = 1;
}else this.adrenalineMultiplier = MainHex.adrenalineMultiplier;
if ((this.dt - this.lastGen) * settings.creationSpeedModifier > this.nextGen) {
if (this.nextGen > 600) {
this.nextGen -= 11 * ((this.nextGen / 1300)) * settings.creationSpeedModifier;
}
}
}}
};

this.randomGeneration = function() {
if (this.dt - this.lastGen > this.nextGen) {
if (this.dt - this.lastGen > this.nextGen / this.adrenalineMultiplier) {
this.ct++;
this.lastGen = this.dt;
var fv = randInt(0, MainHex.sides);
addNewBlock(fv, colors[randInt(0, colors.length)], 1.6 + (this.difficulty / 15) * 3);

if(!MainHex.adrenalineOn())
addNewBlock(fv, colors[randInt(0, colors.length)], 1.6 + (this.difficulty / 15) * 3);
else
addNewBlock(fv, colors[MainHex.adrenalineColor], 1.6 + (this.difficulty / 15) * 3);

var lim = 5;
if (this.ct > lim) {
var nextPattern = randInt(0, 3 + 21);
Expand Down Expand Up @@ -80,7 +88,7 @@ function waveGen(hex) {
};

this.circleGeneration = function() {
if (this.dt - this.lastGen > this.nextGen + 500) {
if (this.dt - this.lastGen > (this.nextGen + 500) / this.adrenalineMultiplier) {
var numColors = randInt(1, 4);
if (numColors == 3) {
numColors = randInt(1, 4);
Expand All @@ -99,7 +107,10 @@ function waveGen(hex) {
}

for (var i = 0; i < MainHex.sides; i++) {
addNewBlock(i, colorList[i % numColors], 1.5 + (this.difficulty / 15) * 3);
if(!MainHex.adrenalineOn())
addNewBlock(i, colorList[i % numColors], 1.5 + (this.difficulty / 15) * 3);
else
addNewBlock(i, colors[MainHex.adrenalineColor], 1.5 + (this.difficulty / 15) * 3);
}

this.ct += 15;
Expand All @@ -109,7 +120,7 @@ function waveGen(hex) {
};

this.halfCircleGeneration = function() {
if (this.dt - this.lastGen > (this.nextGen + 500) / 2) {
if (this.dt - this.lastGen > ((this.nextGen + 500) / 2 ) / this.adrenalineMultiplier) {
var numColors = randInt(1, 3);
var c = colors[randInt(0, colors.length)];
var colorList = [c, c, c];
Expand All @@ -119,7 +130,10 @@ function waveGen(hex) {

var d = randInt(0, 6);
for (var i = 0; i < 3; i++) {
addNewBlock((d + i) % 6, colorList[i], 1.5 + (this.difficulty / 15) * 3);
if(!MainHex.adrenalineOn())
addNewBlock((d + i) % 6, colorList[i], 1.5 + (this.difficulty / 15) * 3);
else
addNewBlock((d + i) % 6, colors[MainHex.adrenalineColor], 1.5 + (this.difficulty / 15) * 3);
}

this.ct += 8;
Expand All @@ -129,11 +143,16 @@ function waveGen(hex) {
};

this.crosswiseGeneration = function() {
if (this.dt - this.lastGen > this.nextGen) {
if (this.dt - this.lastGen > this.nextGen / this.adrenalineMultiplier) {
var ri = randInt(0, colors.length);
var i = randInt(0, colors.length);
addNewBlock(i, colors[ri], 0.6 + (this.difficulty / 15) * 3);
addNewBlock((i + 3) % MainHex.sides, colors[ri], 0.6 + (this.difficulty / 15) * 3);
if(!MainHex.adrenalineOn()){
addNewBlock(i, colors[ri], 0.6 + (this.difficulty / 15) * 3);
addNewBlock((i + 3) % MainHex.sides, colors[ri], 0.6 + (this.difficulty / 15) * 3);
}else{
addNewBlock(i, colors[MainHex.adrenalineColor], 0.6 + (this.difficulty / 15) * 3);
addNewBlock((i + 3) % MainHex.sides, colors[MainHex.adrenalineColor], 0.6 + (this.difficulty / 15) * 3);
}
this.ct += 1.5;
this.lastGen = this.dt;
this.shouldChangePattern();
Expand All @@ -142,11 +161,19 @@ function waveGen(hex) {

this.spiralGeneration = function() {
var dir = randInt(0, 2);
if (this.dt - this.lastGen > this.nextGen * (2 / 3)) {
if (dir) {
addNewBlock(5 - (this.ct % MainHex.sides), colors[randInt(0, colors.length)], 1.5 + (this.difficulty / 15) * (3 / 2));
} else {
addNewBlock(this.ct % MainHex.sides, colors[randInt(0, colors.length)], 1.5 + (this.difficulty / 15) * (3 / 2));
if (this.dt - this.lastGen > (this.nextGen * (2 / 3))/ this.adrenalineMultiplier) {
if(!MainHex.adrenalineOn()){
if (dir) {
addNewBlock(5 - (this.ct % MainHex.sides), colors[randInt(0, colors.length)], 1.5 + (this.difficulty / 15) * (3 / 2));
} else {
addNewBlock(this.ct % MainHex.sides, colors[randInt(0, colors.length)], 1.5 + (this.difficulty / 15) * (3 / 2));
}
}else{
if (dir) {
addNewBlock(5 - (this.ct % MainHex.sides), colors[MainHex.adrenalineColor], 1.5 + (this.difficulty / 15) * (3 / 2));
} else {
addNewBlock(this.ct % MainHex.sides, colors[MainHex.adrenalineColor], 1.5 + (this.difficulty / 15) * (3 / 2));
}
}
this.ct += 1;
this.lastGen = this.dt;
Expand All @@ -155,10 +182,15 @@ function waveGen(hex) {
};

this.doubleGeneration = function() {
if (this.dt - this.lastGen > this.nextGen) {
if (this.dt - this.lastGen > this.nextGen / this.adrenalineMultiplier) {
var i = randInt(0, colors.length);
addNewBlock(i, colors[randInt(0, colors.length)], 1.5 + (this.difficulty / 15) * 3);
addNewBlock((i + 1) % MainHex.sides, colors[randInt(0, colors.length)], 1.5 + (this.difficulty / 15) * 3);
if(!MainHex.adrenalineOn()){
addNewBlock(i, colors[randInt(0, colors.length)], 1.5 + (this.difficulty / 15) * 3);
addNewBlock((i + 1) % MainHex.sides, colors[randInt(0, colors.length)], 1.5 + (this.difficulty / 15) * 3);
}else{
addNewBlock(i, colors[MainHex.adrenalineColor], 1.5 + (this.difficulty / 15) * 3);
addNewBlock((i + 1) % MainHex.sides, colors[MainHex.adrenalineColor], 1.5 + (this.difficulty / 15) * 3);
}
this.ct += 2;
this.lastGen = this.dt;
this.shouldChangePattern();
Expand Down