fixed merge conflicts

This commit is contained in:
meadowstream 2014-07-04 12:45:51 -04:00
commit f3e39a6ddd
11 changed files with 92 additions and 91 deletions

View file

@ -24,7 +24,7 @@
<script type = 'text/javascript' src="js/wavegen.js"></script>
<script type = 'text/javascript' src="js/math.js"></script>
<script type = 'text/javascript' src="js/Block.js"></script>
<script type = 'text/javascript' src="js/Clock.js"></script>
<script type = 'text/javascript' src="js/Hex.js"></script>
<script type = 'text/javascript' src="js/Text.js"></script>
<script type = 'text/javascript' src="js/comboTimer.js"></script>
<script type = 'text/javascript' src="js/checking.js"></script>

View file

@ -22,7 +22,7 @@ function Block(fallingLane, color, iter, distFromHex, settled) {
this.opacity = 1;
//boolean for when the block is expanding
this.initializing = 1;
this.ict = MainClock.ct;
this.ict = MainHex.ct;
//speed of block
this.iter = iter;
//number of iterations before starting to drop
@ -36,14 +36,14 @@ function Block(fallingLane, color, iter, distFromHex, settled) {
if (this.deleted) {
//add shakes
if (this.opacity >= 0.925) {
var tLane = this.attachedLane - MainClock.position;
tLane = MainClock.sides - tLane;
var tLane = this.attachedLane - MainHex.position;
tLane = MainHex.sides - tLane;
while (tLane < 0) {
tLane += MainClock.sides;
tLane += MainHex.sides;
}
tLane %= MainClock.sides;
MainClock.shakes.push({lane:tLane, magnitude:3 * (window.devicePixelRatio ? window.devicePixelRatio : 1) * (settings.scale)});
tLane %= MainHex.sides;
MainHex.shakes.push({lane:tLane, magnitude:3 * (window.devicePixelRatio ? window.devicePixelRatio : 1) * (settings.scale)});
}
//fade out the opacity
this.opacity = this.opacity - 0.075;
@ -60,7 +60,7 @@ function Block(fallingLane, color, iter, distFromHex, settled) {
this.getIndex = function (){
//get the index of the block in its stack
var parentArr = MainClock.blocks[this.attachedLane];
var parentArr = MainHex.blocks[this.attachedLane];
for (var i = 0; i < parentArr.length; i++) {
if (parentArr[i] == this) {
return i;
@ -100,12 +100,12 @@ function Block(fallingLane, color, iter, distFromHex, settled) {
var p3;
var p4;
if (this.initializing) {
var rat = ((MainClock.ct - this.ict)/this.initLen);
var rat = ((MainHex.ct - this.ict)/this.initLen);
p1 = rotatePoint((-this.width / 2) * rat, this.height / 2, this.angle);
p2 = rotatePoint((this.width / 2) * rat, this.height / 2, this.angle);
p3 = rotatePoint((this.widthWide / 2) * rat, -this.height / 2, this.angle);
p4 = rotatePoint((-this.widthWide / 2) * rat, -this.height / 2, this.angle);
if ((MainClock.ct - this.ict) == this.initLen) {
if ((MainHex.ct - this.ict) == this.initLen) {
this.initializing = 0;
}
} else {

View file

@ -1,4 +1,4 @@
function Clock(sideLength) {
function Hex(sideLength) {
this.playThrough = 0;
this.fillColor = [44,62,80];
this.tempColor = [44,62,80];
@ -49,7 +49,7 @@ function Clock(sideLength) {
this.shakes.push({lane:block.fallingLane, magnitude:4.5 * (window.devicePixelRatio ? window.devicePixelRatio : 1) * (settings.scale)});
lane += this.position;
lane = (lane + this.sides) % this.sides;
block.distFromHex = MainClock.sideLength / 2 * Math.sqrt(3) + block.height * this.blocks[lane].length;
block.distFromHex = MainHex.sideLength / 2 * Math.sqrt(3) + block.height * this.blocks[lane].length;
this.blocks[lane].push(block);
block.attachedLane = lane;
block.checked = 1;

View file

@ -65,7 +65,7 @@ function consolidateBlocks(clock,side,index){
}
}
// add scores
var now = MainClock.ct;
var now = MainHex.ct;
if(now - clock.lastCombo < 240 ){
clock.comboTime += 1;
clock.lastCombo = now;

View file

@ -1,7 +1,8 @@
function drawTimer(){
if(MainClock.ct - MainClock.lastCombo < settings.comboTime){
<<<<<<< HEAD
if(MainHex.ct - MainHex.lastCombo < settings.comboTime){
for(var i=0;i<6;i++){
var done = (MainClock.ct -MainClock.lastCombo);
var done = (MainHex.ct -MainHex.lastCombo);
if(done<(settings.comboTime)*(5-i)*(1/6)){
drawSide(i,i+1,1,1);
drawSide(12-i,11-i,1,1);
@ -22,9 +23,9 @@ function drawSide(startVertex,endVertex,fraction,offset){
ctx.beginPath();
ctx.lineCap = "round";
if (gameState === 0) {
ctx.strokeStyle = hexColorsToTintedColors[MainClock.lastColorScored];
ctx.strokeStyle = hexColorsToTintedColors[MainHex.lastColorScored];
} else {
ctx.strokeStyle = MainClock.lastColorScored;
ctx.strokeStyle = MainHex.lastColorScored;
}
ctx.lineWidth =4;
var radius = (settings.rows * settings.blockHeight) * (2/Math.sqrt(3)) + settings.hexWidth + 2;

View file

@ -1,8 +1,8 @@
keypress.register_combo({
keys: "left",
on_keydown: function() {
if (MainClock && gameState !== 0) {
MainClock.rotate(1);
if (MainHex && gameState !== 0) {
MainHex.rotate(1);
}
}
});
@ -10,8 +10,8 @@ keypress.register_combo({
keypress.register_combo({
keys: "right",
on_keydown: function() {
if (MainClock && gameState !== 0){
MainClock.rotate(-1);
if (MainHex && gameState !== 0){
MainHex.rotate(-1);
}
}
});
@ -20,8 +20,8 @@ keypress.register_combo({
keypress.register_combo({
keys: "a",
on_keydown: function() {
if (MainClock && gameState !== 0) {
MainClock.rotate(1);
if (MainHex && gameState !== 0) {
MainHex.rotate(1);
}
}
});
@ -29,8 +29,8 @@ keypress.register_combo({
keypress.register_combo({
keys: "d",
on_keydown: function() {
if (MainClock && gameState !== 0){
MainClock.rotate(-1);
if (MainHex && gameState !== 0){
MainHex.rotate(-1);
}
}
});
@ -108,7 +108,7 @@ $(document).ready(function(){
}, false);
function handleClickTap(x) {
if (!MainClock || gameState === 0 || gameState==2 || gameState==-1) {
if (!MainHex || gameState === 0 || gameState==2 || gameState==-1) {
return;
}
@ -121,7 +121,7 @@ function handleClickTap(x) {
init(1);
}
}
MainClock.rotate(1);
MainHex.rotate(1);
}
if (x > window.innerWidth/2) {
if (gameState != 1 && gameState != -2 && gameState != -1) {
@ -132,6 +132,6 @@ function handleClickTap(x) {
init(1);
}
}
MainClock.rotate(-1);
MainHex.rotate(-1);
}
}

View file

@ -10,13 +10,13 @@ $(document).ready(function(){
}
setTimeout(function(){
document.body.addEventListener('mousedown', function(e) {
handleClickTap(e.clientX);
}, false);
document.body.addEventListener('touchstart', function(e) {
handleClickTap(e.changedTouches[0].clientX);
}, false);
document.body.addEventListener('touchstart', function(e) {
handleClickTap(e.changedTouches[0].clientX);
}, false);
//document.body.addEventListener('mousedown', function(e) {
//handleClickTap(e.clientX);
//}, false);
}, 1);
});
});
@ -128,7 +128,7 @@ if(localStorage.getItem('highscores'))
localStorage.setItem('highscores', highscores);
var blocks = [];
var MainClock;
var MainHex;
var gdx = 0;
var gdy = 0;
@ -185,11 +185,11 @@ function init(b) {
scaleCanvas();
settings.blockHeight = settings.baseBlockHeight * settings.scale;
settings.hexWidth = settings.baseHexWidth * settings.scale;
MainClock = saveState.clock || new Clock(settings.hexWidth);
MainHex = saveState.clock || new Hex(settings.hexWidth);
if (saveState.clock) {
MainClock.playThrough += 1;
MainHex.playThrough += 1;
}
MainClock.sideLength = settings.hexWidth;
MainHex.sideLength = settings.hexWidth;
count = 0;
var i;
@ -214,14 +214,14 @@ function init(b) {
gdy = saveState.gdy || 0;
comboTime = saveState.comboTime || 0;
for(i=0; i<MainClock.blocks.length; i++) {
for (var j=0; j<MainClock.blocks[i].length; j++) {
MainClock.blocks[i][j].height = settings.blockHeight;
MainClock.blocks[i][j].settled = 0;
for(i=0; i<MainHex.blocks.length; i++) {
for (var j=0; j<MainHex.blocks[i].length; j++) {
MainHex.blocks[i][j].height = settings.blockHeight;
MainHex.blocks[i][j].settled = 0;
}
}
MainClock.blocks.map(function(i){
MainHex.blocks.map(function(i){
i.map(function(o){
if (rgbToHex[o.color]) {
o.color = rgbToHex[o.color];
@ -229,13 +229,13 @@ function init(b) {
});
});
MainClock.y = -100;
MainHex.y = -100;
startTime = Date.now();
waveone = saveState.wavegen || new waveGen(MainClock,Date.now(),[1,1,0],[1,1],[1,1]);
waveone = saveState.wavegen || new waveGen(MainHex,Date.now(),[1,1,0],[1,1],[1,1]);
MainClock.texts = []; //clear texts
MainClock.delay = 15;
MainHex.texts = []; //clear texts
MainHex.delay = 15;
hideText();
}
@ -314,10 +314,10 @@ function animLoop() {
switch (gameState) {
case 1:
requestAnimFrame(animLoop);
if (!MainClock.delay) {
if (!MainHex.delay) {
update();
} else {
MainClock.delay--;
MainHex.delay--;
}
render();
if (checkGameOver() && !importing) {
@ -388,8 +388,8 @@ function isInfringing(clock){
}
function checkGameOver() {
for (var i = 0; i < MainClock.sides; i++) {
if (isInfringing(MainClock)) {
for (var i = 0; i < MainHex.sides; i++) {
if (isInfringing(MainHex)) {
updateHighScore();
gameOverDisplay();
return true;

View file

@ -20,9 +20,9 @@ function render() {
}
var i;
for (i = 0; i < MainClock.blocks.length; i++) {
for (var j = 0; j < MainClock.blocks[i].length; j++) {
var block = MainClock.blocks[i][j];
for (i = 0; i < MainHex.blocks.length; i++) {
for (var j = 0; j < MainHex.blocks[i].length; j++) {
var block = MainHex.blocks[i][j];
block.draw(true, j);
}
}
@ -31,15 +31,15 @@ function render() {
blocks[i].draw();
}
MainClock.draw();
MainHex.draw();
if (gameState ==1 || gameState ==-1 || gameState === 0) {
drawScoreboard();
}
for (i = 0; i < MainClock.texts.length; i++) {
var alive = MainClock.texts[i].draw();
for (i = 0; i < MainHex.texts.length; i++) {
var alive = MainHex.texts[i].draw();
if(!alive){
MainClock.texts.splice(i,1);
MainHex.texts.splice(i,1);
i--;
}
}
@ -48,13 +48,13 @@ function render() {
settings.hexWidth = settings.baseHexWidth * settings.scale;
settings.blockHeight = settings.baseBlockHeight * settings.scale;
if (MainClock.ct < 400 && (gameState != 0) && !MainClock.playThrough) {
if (MainClock.ct > 350) {
ctx.globalAlpha = (50 - (MainClock.ct - 350))/50;
if (MainHex.ct < 400 && (gameState != 0) && !MainHex.playThrough) {
if (MainHex.ct > 350) {
ctx.globalAlpha = (50 - (MainHex.ct - 350))/50;
}
if (MainClock.ct < 50) {
ctx.globalAlpha = (MainClock.ct)/50;
if (MainHex.ct < 50) {
ctx.globalAlpha = (MainHex.ct)/50;
}
renderText((trueCanvas.width)/2 + 1.5 * settings.scale, (trueCanvas.height)/2 - 208 * settings.scale, 35, '#2c3e50', 'Controls', '35px Roboto');

View file

@ -3,7 +3,7 @@ function exportSaveState() {
if(gameState == 1 || gameState == -1 || (gameState === 0 && localStorage.getItem('saveState') !== undefined)) {
state = {
clock: $.extend(true, {}, MainClock),
clock: $.extend(true, {}, MainHex),
blocks: $.extend(true, [], blocks),
score: score,
wavegen: waveone,

View file

@ -8,7 +8,7 @@ function update() {
}
if (importedHistory[count].rotate) {
MainClock.rotate(importedHistory[count].rotate);
MainHex.rotate(importedHistory[count].rotate);
}
}
}
@ -25,7 +25,7 @@ function update() {
var objectsToRemove = [];
for (i = 0; i < blocks.length; i++) {
MainClock.doesBlockCollide(blocks[i]);
MainHex.doesBlockCollide(blocks[i]);
if (!blocks[i].settled) {
if (!blocks[i].initializing) blocks[i].distFromHex -= blocks[i].iter * settings.scale;
} else if (!blocks[i].removed) {
@ -33,41 +33,41 @@ function update() {
}
}
for (i = 0; i < MainClock.blocks.length; i++) {
for (j = 0; j < MainClock.blocks[i].length; j++) {
if (MainClock.blocks[i][j].checked ==1 ) {
consolidateBlocks(MainClock,MainClock.blocks[i][j].attachedLane,MainClock.blocks[i][j].getIndex());
MainClock.blocks[i][j].checked=0;
for (i = 0; i < MainHex.blocks.length; i++) {
for (j = 0; j < MainHex.blocks[i].length; j++) {
if (MainHex.blocks[i][j].checked ==1 ) {
consolidateBlocks(MainHex,MainHex.blocks[i][j].attachedLane,MainHex.blocks[i][j].getIndex());
MainHex.blocks[i][j].checked=0;
}
}
}
for (i = 0; i < MainClock.blocks.length; i++) {
for (i = 0; i < MainHex.blocks.length; i++) {
lowestDeletedIndex = 99;
for (j = 0; j < MainClock.blocks[i].length; j++) {
block = MainClock.blocks[i][j];
for (j = 0; j < MainHex.blocks[i].length; j++) {
block = MainHex.blocks[i][j];
if (block.deleted == 2) {
MainClock.blocks[i].splice(j,1);
MainHex.blocks[i].splice(j,1);
blockDestroyed();
if (j < lowestDeletedIndex) lowestDeletedIndex = j;
j--;
}
}
if (lowestDeletedIndex < MainClock.blocks[i].length) {
for (j = lowestDeletedIndex; j < MainClock.blocks[i].length; j++) {
MainClock.blocks[i][j].settled = 0;
if (lowestDeletedIndex < MainHex.blocks[i].length) {
for (j = lowestDeletedIndex; j < MainHex.blocks[i].length; j++) {
MainHex.blocks[i][j].settled = 0;
}
}
}
for (i = 0; i < MainClock.blocks.length; i++) {
for (j = 0; j < MainClock.blocks[i].length; j++) {
block = MainClock.blocks[i][j];
MainClock.doesBlockCollide(block, j, MainClock.blocks[i]);
for (i = 0; i < MainHex.blocks.length; i++) {
for (j = 0; j < MainHex.blocks[i].length; j++) {
block = MainHex.blocks[i][j];
MainHex.doesBlockCollide(block, j, MainHex.blocks[i]);
if (!MainClock.blocks[i][j].settled) {
MainClock.blocks[i][j].distFromHex -= block.iter * settings.scale;
if (!MainHex.blocks[i][j].settled) {
MainHex.blocks[i][j].distFromHex -= block.iter * settings.scale;
}
}
}
@ -78,6 +78,6 @@ function update() {
i--;
}
}
MainClock.ct++;
MainHex.ct++;
count++;
}

View file

@ -37,7 +37,7 @@ function waveGen(clock) {
if (this.dt - this.lastGen > this.nextGen) {
this.ct++;
this.lastGen = this.dt;
var fv = randInt(0, MainClock.sides);
var fv = randInt(0, MainHex.sides);
addNewBlock(fv, colors[randInt(0, colors.length)], 1.6 + (this.difficulty/15) * 3);
if (this.ct > 7) {
var nextPattern = randInt(0, 20 + 4);
@ -91,7 +91,7 @@ function waveGen(clock) {
colorList.push(colors[q]);
}
for (var i = 0; i < MainClock.sides; i++) {
for (var i = 0; i < MainHex.sides; i++) {
addNewBlock(i, colorList[i % numColors], 1.5 + (this.difficulty/15) * 3);
}
@ -106,7 +106,7 @@ function waveGen(clock) {
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) % MainClock.sides, colors[ri], 0.6 + (this.difficulty/15) * 3);
addNewBlock((i + 3) % MainHex.sides, colors[ri], 0.6 + (this.difficulty/15) * 3);
this.ct += 1.5;
this.lastGen = this.dt;
this.shouldChangePattern();
@ -117,10 +117,10 @@ function waveGen(clock) {
var dir = randInt(0, 2);
if (this.dt - this.lastGen > this.nextGen * (5/9)) {
if (dir) {
addNewBlock(5 - (this.ct % MainClock.sides), colors[randInt(0, colors.length)], 1.5 + (this.difficulty/15) * (3/2));
addNewBlock(5 - (this.ct % MainHex.sides), colors[randInt(0, colors.length)], 1.5 + (this.difficulty/15) * (3/2));
}
else {
addNewBlock(this.ct % MainClock.sides, colors[randInt(0, colors.length)], 1.5 + (this.difficulty/15) * (3/2));
addNewBlock(this.ct % MainHex.sides, colors[randInt(0, colors.length)], 1.5 + (this.difficulty/15) * (3/2));
}
this.ct += 1;
this.lastGen = this.dt;
@ -132,7 +132,7 @@ function waveGen(clock) {
if (this.dt - this.lastGen > this.nextGen) {
var i = randInt(0, colors.length);
addNewBlock(i, colors[randInt(0, colors.length)], 1.5 + (this.difficulty/15) * 3);
addNewBlock((i + 1) % MainClock.sides, 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);
this.ct += 2;
this.lastGen = this.dt;
this.shouldChangePattern();