/***DANGER*****DANGER: DO NOT LOOK AT THIS CODE. IF YOU DO, YOUR COMPUTER _WILL_ EXPLODE AND POSSIBLY YOUR HEAD TOO***DANGER***DANGER****DANGER***********/
/*************AND NO, THE COORDINATES ARE NOT HERE, SO THERE'S NO NEED TO EVEN LOOK***********************************************/
/******************************************************GLOBAL VARIABLES********************************************/
//
var myVar;
var tempLeft = 0; //left position of easy button
var tempTop = 0; //top position of easy button
var gameNum = 1;
var secretNumber = 0;
//var coordString="COORDINATES: N 48 ";
var windowWidth=0;
var windowHeight=0;
var buttonWidth = 200;
var buttonHeight = 200;
var horizRange=0;
var vertRange=0;
var numTimesChased=0;
var giveMugglesCoffee=0; //start at speed 200, go to 50 if mugglesCoffee=1
/*******************************************************TARGET VARIABLES************************************************/
var easyTop=0;
var easyLeft=0;
var letterAHeight = 30;
var letterAWidth = 30;
var buttonWidthSmall = 40;
var buttonHeightSmall = 40;
var letterATop1=0;
var letterALeft1=0;
var letterAGot1=false;
var letterATop2=0;
var letterALeft2=0;
var letterAGot2=false;
var letterATop3=0;
var letterALeft3=0;
var letterAGot3=false;
var letterATop4=0;
var letterALeft4=0;
var letterAGot4=false;
var letterATop5=0;
var letterALeft5=0;
var letterAGot5=false;
var letterATop6=0;
var letterALeft6=0;
var letterAGot6=false;
var letterATop7=0;
var letterALeft7=0;
var letterAGot7=false;
var letterATop8=0;
var letterALeft8=0;
var letterAGot8=false;
var spaceBarPressed=false;
var speed1;
var speed2;
var speed3;
var speed4;
var speed5;
var speed6;
var speed7;
var speed8;
var numTargetLoops=0;
/*******************************************************MAZE VARIABLES************************************************/
var widthHintButton=0;
var muggleSpeed=200; //lower number the faster, default is 200
var nasty=false; //whether or not to go back to beginning if bump into wall
var widthCanvas;
var heightCanvas;
var sizeGrid; //length of 1 side of each grid, in pixels
var yOffset;
var rows = new Array(33);
rows[0]=[1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,0,0,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1,1,1,0,1,1,0,1,1,1,0,0,0,0,0,0,0,1,0,1,1,1,1,0,1,0,0,1,1,0,0,1,1,1,0,1,1,0,0,0,1,1,0,0,0,0,0,0,0,0,1,0,1,1,1,1,1,0,1,0,0,0,0,0,0,0];
rows[31]=[1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,1,1,1,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0];
rows[32]=[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0];
//33 rows, 82 columns
var upPressed = 0;
var downPressed = 0;
var leftPressed = 0;
var rightPressed = 0;
var row=0; //initial row for easy button
var col=1; //initial column for easy button
var muggleRow=[14,11,9,11]; //INITIAL POSITIONS OF MUGGLES
var muggleCol=[6,74,29,50];
var oldDir=["right","right","right","right"]; //array of directions for muggles
//var newDir=["","","",""];
var hallway=false;
var corner=false;
var deadend=false;
var junction3=false;
var junction4=false;
var typeJunction="";
var numPos=0;
var posUp = 0;
var posDown = 0;
var posRight = 0;
var posLeft = 0;
var ranNum = 0;
var posArray = new Array();
var bool1=false;
var bool2=false;
var oppDir=""; //temp varible
/****************************MEMORY VARIABLES***************************/
var leftMemory;
var topMemory;
var xSpacing;
var ySpacing;
var widthAmmocan;
var heightAmmocan;
var nameString;
var startTop=0;
var startLeft=0;
var cardsArray = new Array(6); //tells you which card is where, randomly generated, this is the FINAL SCRAMBLED ARRAY
cardsArray[0]=new Array(6);
cardsArray[1]=new Array(6);
cardsArray[2]=new Array(6);
cardsArray[3]=new Array(6);
cardsArray[4]=new Array(6);
cardsArray[5]=new Array(6);
var ranCards=0;
//var numPoss=0;
var scrambledArray=["","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",""];
var beginArray=["easybuttonWide1","easybuttonWide2","letterEWide1","letterEWide2","letterAWide1","letterAWide2","letterSWide1","letterSWide2","letterYWide1","letterYWide2","unknownWide1","unknownWide2","multiWide1","multiWide2","earthcacheWide1","earthcacheWide2","letterboxWide1","letterboxWide2","eventWide1","eventWide2","citoWide1","citoWide2","megaWide1","megaWide2","wherigoWide1","wherigoWide2","labcacheWide1","labcacheWide2","virtualWide1","virtualWide2","webcamWide1","webcamWide2","traditionalWide1","traditionalWide2","logoWide1","logoWide2"];
var positionArray=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35];
var numLeft=36;
var thisCard=0;
var tempStr="";
var numCardsClicked=0; //only let people click 2 cards
var cardsClickedArray=["",""];
var rowsClickedArray=[0,0];
var colsClickedArray=[0,0];
//KEEPS TRACK OF HOW MANY OF EACH CARD YOU HAVE TURNED OVER
var numMatches=0;
/******************************************************DECIDE***********************************************************/
function decide() {
windowWidth = window.innerWidth;
windowHeight = window.innerHeight;
//alert("inside decide function");
if (gameNum == 1) {
$("#hintButton").css({"top":(windowHeight - 30),"left":(0),"visibility":"visible"});
//gameNum = 7;
//memory();
//finale();
//makeMaze();
//makeButtonMoveChase();
makeButtonMoveHoriz(4000);
//gameNum = 9;
//makeMaze();
//target();
} else if (gameNum == 2) {
makeButtonMoveVert(800);
} else if (gameNum == 3) {
makeButtonMoveLeftRight(1000);
} else if (gameNum == 4) {
makeButtonMoveRandom(400);
} else if (gameNum == 5) {
makeButtonMoveDiag(10);
} else if (gameNum == 6) {
makeButtonMoveChase();
} else if (gameNum == 7) {
memory();
//gameNum++;
//decide();
} else if (gameNum == 8) {
target();
} else if (gameNum == 9) {
makeMaze();
} else if (gameNum ==10) {
finale();
}
}
/***************************************CLICK FOR HINT****************************************/
function clickForHint() {
alert("hint clicked");
switch (gameNum)
{
case 1:
alert("Click on the easy button. After that, a new animation should start. If it doesn't, try moving your mouse.");
break;
case 2:
alert("Click on the easy button. After that, a new animation should start. If it doesn't, try moving your mouse.");
break;
case 3:
alert("Click on the easy button. After that, a new animation should start. If it doesn't, try moving your mouse.");
break;
case 4:
alert("Click on the easy button. After that, a new animation should start. If it doesn't, try moving your mouse.");
break;
case 5:
alert("Click on the easy button. After that, a new animation should start. If it doesn't, try moving your mouse.");
break;
case 6:
alert("Persistence pays off!");
break;
case 7:
alert("Memory game: Click on the cards to match them. Do not click them too rapidly or you may confuse them.");
break;
case 8:
alert("Use the SPACE BAR to shoot all 8 letters and the LEFT and RIGHT ARROW KEYS to move.");
break;
case 9:
alert("Use the ARROW KEYS on your keyboard to get to the end of the maze. Be sure to stay away from the muggles!!");
break;
}
}
/*********************************GIVE MUGGLES COFFEE*******************************/
function changeMuggleSpeed() { //default speed is 200, toggles between 200 and 50
///$(this).text("Hello");
if (giveMugglesCoffee== 0) {
//alert("mugglescoffee = 0");
//$("#muggleButton").css({"value": "SLOW MUGGLES DOWN"});
//$("#muggleButton").val = "changed";
$("#muggleButton").text("TAKE AWAY COFFEE");
muggleSpeed=110;
clearInterval(myVar);
myVar = setInterval(function(){muggleLoop("muggle0"); muggleLoop("muggle1"); muggleLoop("muggle2"); muggleLoop("muggle3"); },muggleSpeed);
//$("#muggle1").css({"top":muggleTop,"left":muggleLeft,"width":sizeGrid-2,"height":sizeGrid-2, "visibility":"visible"});
giveMugglesCoffee = 1;
} else if (giveMugglesCoffee == 1) {
$("#muggleButton").text("GIVE MUGGLES COFFEE");
muggleSpeed = 200;
clearInterval(myVar);
myVar = setInterval(function(){muggleLoop("muggle0"); muggleLoop("muggle1"); muggleLoop("muggle2"); muggleLoop("muggle3"); },muggleSpeed);
giveMugglesCoffee = 0;
}
}
/*********************************************************MEMORY**********************************************************/
function memory() { //DRAW 36 CARDS ALL TOGETHER, 6 COLUMNS, 6 ROWS
widthAmmocan = $("#ammocan00").css("width");
//alert("widthAmmocan = " + widthAmmocan);
heightAmmocan = $("#ammocan00").css("height");
//alert("heightAmmocan = " + heightAmmocan);
//CALCULATE Y-SPACING FIRST, THEN CALCULATE X-SPACING BASED ON THAT AND MAINTAING THE CORRECT ASPECT RATIO FOR THE IMAGES TO BE CORRECTLY
ySpacing = Math.floor((windowHeight- 100) / 6);
//alert("yspacing = " + yspacing);
//dimensions of ammocan are 150 wide by 100 high so xspacing must be 1.5*yspacing
xSpacing = Math.floor(1.5*ySpacing);
//alert("xspacing = " + xspacing);
startTop = 50;
startLeft = Math.floor((windowWidth - (6*xSpacing))/2)
//CHECK TO SEE IF X-SPACING WILL NOT MAKE IT TOO WIDE TO FIT ON SCREEN
if (windowWidth > (xSpacing*6)) {
//alert("spacing OK: windowWidth, xSpacingx6"+ windowWidth+" " + (xSpacing*6));
} else { //CALCULATE A DIFFERENT WAY: X-SPACING FIRST, THEN Y-SPACING
alert("calculate differenet way");
xSpacing = Math.floor((windowWidth- 100) / 6);
ySpacing = Math.floor(xSpacing/1.5);
startLeft = 50;
startTop = Math.floor((windowHeight - 6*ySpacing)/2);
}
var tempName="";
//DRAW GRID OF CARDS
for (var i = 0; i < 6; i++) {
for (var j = 0; j < 6; j++) {
tempTop = startTop + i*ySpacing;
tempLeft = startLeft+ j*xSpacing;
tempName = "#ammocan"+i+""+j;
//alert("tempNAme = " + tempName);
$(tempName).css({"top":tempTop,"left":tempLeft,"width":(xSpacing),"height":(ySpacing), "visibility":"visible"});
}
}
//DETERMINE BACKS OF CARDS, USING RANDOMNESS, USING 6X6 2-DIMENSIONAL ARRAY
//REMOVE ELEMENTS FROM BEGINARRAY, 1 BY 1 AND PUT INTO SCRAMBLED ARRAY
for (var i=0;i<36;i++) {
tempStr=beginArray[i];
//beginArray.splice
//alert("tempStr = " + tempStr);
ranCards=Math.floor((Math.random()*numLeft));
//alert("ranCards = " + ranCards);
thisCard = positionArray[ranCards];
//alert("thisCard="+thisCard);
positionArray.splice(ranCards, 1); //remove this elemnet from ranArray
numLeft = numLeft - 1;
//alert("numLeft="+numLeft);
scrambledArray[thisCard]=tempStr;
}
//PRINT OUT SCRAMBLED ARRAY FOR TESTING PURPOSES
for (var i=0; i<36; i++) {
//alert(scrambledArray[i]);
}
//CREATE FINAL CARDSARRAY (6X6)
for (var k=0; k<36; k++) {
if (k <6) {
//alert(scrambledArray[i]);
cardsArray[0][k]=scrambledArray[k];
}
if ((5 0) {
if (rows[muggleRowTemp-1][muggleColTemp] == 0) {
//alert("can go up");
posUp = 1;
numPos++;
posArray.push("up");
}
}
// CAN YOU GO DOWN
if (muggleRowTemp < 32) {
if (rows[muggleRowTemp+1][muggleColTemp] ==0) {
//alert("can go down");
posDown = 1;
numPos++;
posArray.push("down");
}
}
// CAN YOU GO RIGHT
if (muggleColTemp < 81) {
if (rows[muggleRowTemp][muggleColTemp+1] == 0) {
//alert("can go right");
posRight = 1;
numPos++;
posArray.push("right");
}
}
// CAN YOU GO LEFT
if (muggleColTemp > 0) {
if (rows[muggleRowTemp][muggleColTemp-1] == 0) {
//alert("can go left");
posLeft = 1;
numPos++;
posArray.push("left");
}
}
//alert("total number of possilibites = " + posArray.length);
/****DETERMINE WHAT TYPE OF JUNCTION YOU ARE AT (DEADEND, HALLWAY, CORNER, 3WAYJUNCTION, 4WAYJUNCTION*****/
//DEAD END OR AT VERY BEGINNING
if (numPos == 1) {
typeJunction="deadend";
//alert("dead end");
}
//HALLWAY OR CORNER
else if (numPos ==2) {
bool1 = ((rows[muggleRowTemp][muggleColTemp-1] == rows[muggleRowTemp][muggleColTemp+1]) && (rows[muggleRowTemp][muggleColTemp+1] == 0));
bool2 = ((rows[muggleRowTemp+1][muggleColTemp] == rows[muggleRowTemp-1][muggleColTemp]) && (rows[muggleRowTemp-1][muggleColTemp] == 0));
//alert("bool1 = " + bool1);
//alert("bool2 = " + bool2);
//determine if hallway or corner
if ( bool1 || bool2 ) {
typeJunction="hallway";
//alert("hallway");
} else {
typeJunction="corner";
//alert("corner");
}
}
//3 WAY JUNCTION
else if (numPos == 3) {
typeJunction="3wayjunction";
//alert("3way junction");
}
//4 WAY JUNCTION
else if (numPos ==4) {
//alert("4way junction");
typeJunction="4wayjunction";
}
//alert("ranNum = " + ranNum);
/*********DETERMINE NEW DIRECTION********/
if (typeJunction == "deadend") {
newDirTemp = opposite(oldDirTemp);
//alert("newDirTemp = " + newDirTemp);
} else if (typeJunction == "hallway") {
newDirTemp = oldDirTemp; //kee[p travelling in same direction
} else if (typeJunction == "corner") {
//there should be 2 possible direction, pick the direction that is not opposite to oldDir
//take oldDir, find opposite, then grab the elemnt in the posArray which is not equal to this
oppDir = opposite(oldDirTemp);
//look in array, remove oppDir from array
for(var i = posArray.length; i--;) {
if(posArray[i] === oppDir) {
posArray.splice(i, 1);
}
}
newDirTemp = posArray[0]; //new direction determined by whatever's left in array
} else if (typeJunction == "3wayjunction") {
oppDir = opposite(oldDirTemp);
for(var i = posArray.length; i--;) {
if(posArray[i] === oppDir) {
posArray.splice(i, 1);
}
}
numPos = numPos - 1; //reduce by 1 to account for element removed
//randomly pick number from 1 to posArray.length
ranNum = Math.floor((Math.random()*(numPos)+1)) - 1;
newDirTemp = posArray[ranNum];
} else if (typeJunction == "4wayjunction") {
oppDirTemp = opposite(oldDirTemp);
for(var i = posArray.length; i--;) {
if(posArray[i] === oppDir) {
posArray.splice(i, 1);
}
}
numPos = numPos - 1; //reduce by 1 to account for element removed
//randomly pick number from 1 to posArray.length
ranNum = Math.floor((Math.random()*(numPos)+1)) - 1;
newDirTemp = posArray[ranNum];
}
//alert("newDir = " + newDir);
if (newDirTemp == "up") {
muggleRowTemp = muggleRowTemp - 1;
muggleTop = (muggleRowTemp * sizeGrid) + 10 + yOffset;
//muggleLeft1 = (muggleCol1 * sizeGrid) + 10;
$("#"+muggleName).css("top",muggleTop);
} else if (newDirTemp == "right") {
muggleColTemp = muggleColTemp + 1;
//muggleTop1 = (muggleRow1 * sizeGrid) + 10;
muggleLeft = (muggleColTemp * sizeGrid) + 10;
$("#"+muggleName).css("left",muggleLeft);
} else if (newDirTemp == "down") {
muggleRowTemp = muggleRowTemp + 1;
muggleTop = (muggleRowTemp * sizeGrid) + 10 + yOffset;
//muggleLeft1 = (muggleCol1 * sizeGrid) + 10;
$("#"+muggleName).css("top",muggleTop);
} else if (newDirTemp == "left") {
//alert("Moving left");
muggleColTemp = muggleColTemp - 1;
//alert("muggleColTemp="+muggleColTemp);
muggleLeft = (muggleColTemp * sizeGrid) + 10;
//alert("muggleName="+muggleName);
$("#"+muggleName).css("left",muggleLeft);
}
//empty array
posArray.splice(0,posArray.length);
numPos = 0;
//alert("posArray0 = " + posArray[0]);
//posArray.length = 0;
//alert("filtered, total number of possilibites = " + posArray.length);
//SET GLOBAL VARIABLES TO CARRY ON TO NEXT LOOP
oldDir[whichMuggle] = newDirTemp; //carry direction into next loop
muggleRow[whichMuggle]=muggleRowTemp;
muggleCol[whichMuggle]=muggleColTemp;
}
/***DANGER*****DANGER: DO NOT LOOK AT THIS CODE. IF YOU DO, YOUR COMPUTER _WILL_ EXPLODE AND POSSIBLY YOUR HEAD TOO***DANGER***DANGER****DANGER***********/
/***************************************************TARGET LOOP*******************************************************/
function targetLoop() {
if (spaceBarPressed == true) { //move easy button
if (easyTop < 20) { //easy button reached top of screen - reset it to bottom of screen and set spaceBarPressed =false
easyTop = (windowHeight - buttonHeightSmall);
$("#easybutton").css("top", easyTop);
spaceBarPressed = false;
//alert("easyTop = " + easyTop);
} else { //easy button still needs to move upwards
easyTop = easyTop - 10;
$("#easybutton").css("top", easyTop);
//alert("easyTop = " + easyTop);
}
}
//DRAW LETTER 1
if (letterAGot1 == false) {
if (letterALeft1 > 20) {
letterALeft1 = letterALeft1 - speed1;
} else { //rest to right side of screen
letterALeft1 = windowWidth - letterAWidth;
}
if ((Math.abs(letterALeft1 - easyLeft) < 20) && (Math.abs(letterATop1 - easyTop) < 20)) {
$("#letterA1").css("visibility","hidden");
$('#easysound')[0].play();
letterAGot1 = true;
} else {
$("#letterA1").css({"top":(letterATop1),"left":(letterALeft1), "visibility":"visible"});
}
}
//DRAW LETTER 2
if (letterAGot2 == false) {
if (letterALeft2 > 20) {
letterALeft2 = letterALeft2 - speed2;
} else { //rest to right side of screen
letterALeft2 = windowWidth - letterAWidth;
}
if ((Math.abs(letterALeft2 - easyLeft) < 20) && (Math.abs(letterATop2 - easyTop) < 20)) {
$("#letterA2").css("visibility","hidden");
$('#easysound')[0].play();
letterAGot2 = true;
} else {
$("#letterA2").css({"top":(letterATop2),"left":(letterALeft2), "visibility":"visible"});
}
}
//DRAW LETTER 3
if (letterAGot3 == false) {
if (letterALeft3 > 20) {
letterALeft3 = letterALeft3 - speed3;
} else { //rest to right side of screen
letterALeft3 = windowWidth - letterAWidth;
}
if ((Math.abs(letterALeft3 - easyLeft) < 20) && (Math.abs(letterATop3 - easyTop) < 20)) {
$("#letterA3").css("visibility","hidden");
$('#easysound')[0].play();
letterAGot3 = true;
} else {
$("#letterA3").css({"top":(letterATop3),"left":(letterALeft3), "visibility":"visible"});
}
}
//DRAW LETTER 4
if (letterAGot4 == false) {
if (letterALeft4 > 20) {
letterALeft4 = letterALeft4 - speed4;
} else { //rest to right side of screen
letterALeft4 = windowWidth - letterAWidth;
}
if ((Math.abs(letterALeft4 - easyLeft) < 20) && (Math.abs(letterATop4 - easyTop) < 20)) {
$("#letterA4").css("visibility","hidden");
$('#easysound')[0].play();
letterAGot4 = true;
} else {
$("#letterA4").css({"top":(letterATop4),"left":(letterALeft4), "visibility":"visible"});
}
}
//DRAW LETTER 5
if (letterAGot5 == false) {
if (letterALeft5 > 20) {
letterALeft5 = letterALeft5 - speed5;
} else { //rest to right side of screen
letterALeft5 = windowWidth - letterAWidth;
}
if ((Math.abs(letterALeft5- easyLeft) < 20) && (Math.abs(letterATop5 - easyTop) < 20)) {
$("#letterA5").css("visibility","hidden");
$('#easysound')[0].play();
letterAGot5 = true;
} else {
$("#letterA5").css({"top":(letterATop5),"left":(letterALeft5), "visibility":"visible"});
}
}
//DRAW LETTER 6
if (letterAGot6 == false) {
if (letterALeft6 > 20) {
letterALeft6 = letterALeft6 - speed6;
} else { //rest to right side of screen
letterALeft6 = windowWidth - letterAWidth;
}
if ((Math.abs(letterALeft6- easyLeft) < 20) && (Math.abs(letterATop6 - easyTop) < 20)) {
$("#letterA6").css("visibility","hidden");
$('#easysound')[0].play();
letterAGot6 = true;
} else {
$("#letterA6").css({"top":(letterATop6),"left":(letterALeft6), "visibility":"visible"});
}
}
//DRAW LETTER 7
if (letterAGot7 == false) {
if (letterALeft7 > 20) {
letterALeft7 = letterALeft7 - speed7;
} else { //rest to right side of screen
letterALeft7 = windowWidth - letterAWidth;
}
if ((Math.abs(letterALeft7- easyLeft) < 20) && (Math.abs(letterATop7 - easyTop) < 20)) {
$("#letterA7").css("visibility","hidden");
$('#easysound')[0].play();
letterAGot7 = true;
} else {
$("#letterA7").css({"top":(letterATop7),"left":(letterALeft7), "visibility":"visible"});
}
}
//DRAW LETTER 8
if (letterAGot8 == false) {
if (letterALeft8 > 20) {
letterALeft8 = letterALeft8 - speed8;
} else { //rest to right side of screen
letterALeft8 = windowWidth - letterAWidth;
}
if ((Math.abs(letterALeft8- easyLeft) < 20) && (Math.abs(letterATop8 - easyTop) < 20)) {
$("#letterA8").css("visibility","hidden");
$('#easysound')[0].play();
letterAGot8 = true;
} else {
$("#letterA8").css({"top":(letterATop8),"left":(letterALeft8), "visibility":"visible"});
}
}
numTargetLoops++;
if (letterAGot1 && letterAGot2 && letterAGot3 && letterAGot4 && letterAGot5 && letterAGot6 && letterAGot7 && letterAGot8) { //All A's have been caught, time to end loop
//coordString = coordString + ".8";
//$("#coordinateButton").text(coordString);
clearInterval(myVar); //STOP WHATEVER ANIMATION ITS DOING
$("#easybutton").stop(true,false);
$("#easybutton").css("visibility","hidden");
gameNum++;
decide();
}
if ((numTargetLoops == 1000) || (numTargetLoops == 1500) || (numTargetLoops == 2000) || (numTargetLoops == 2000) || (numTargetLoops == 2500)) {
//INCREASE SPEED AFTER A WHILE
speed1 = speed1+1;
speed2 = speed2+1;
speed3 = speed3+1;
speed4 = speed4+1;
speed5 = speed5+1;
speed6 = speed6+1;
speed7 = speed7+1;
speed8 = speed8+1;
}
}
/*********************************************************TARGET**************************************************/
function target(speed) {
var vertLetterSpacing=0;
//start with easy button at bottom of screen, in middle
//can move easy button with arrow keys
//if you hit space bar, it makes easy button move vertically until it eventually disappears off the screen and comes back to starting position
//must keep track of easy button position
easyTop = (windowHeight - buttonHeightSmall);
easyLeft = (Math.floor(windowWidth/2));
vertLetterSpacing = Math.floor((windowHeight - 150)/7);
//SET SPEEDS OF EACH LETTER
speed1 = Math.floor((Math.random()*8)+1);
speed2 = Math.floor((Math.random()*8)+1);
speed3 = Math.floor((Math.random()*8)+1);
speed4 = Math.floor((Math.random()*8)+1);
speed5 = Math.floor((Math.random()*8)+1);
speed6 = Math.floor((Math.random()*8)+1);
speed7 = Math.floor((Math.random()*8)+1);
speed8 = Math.floor((Math.random()*8)+1);
//DRAW MINIATURE EASY-BUTTON
$("#easybutton").css({"top":(easyTop),"left":(easyLeft),"width":(buttonWidthSmall),"height":(buttonHeightSmall), "visibility":"visible"});
//DRAW LETTER A's AT THEIR STARTING POSITIONS, BUT INVISIBLE
letterATop1 = 20;
letterALeft1 = (windowWidth - letterAWidth);
$("#letterA1").css({"top":(letterATop1),"left":(letterALeft1),"width":(letterAWidth),"height":(letterAHeight), "visibility":"hidden"});
letterATop2 = vertLetterSpacing+20;
letterALeft2 = (windowWidth - letterAWidth);
$("#letterA2").css({"top":(letterATop2),"left":(letterALeft2),"width":(letterAWidth),"height":(letterAHeight), "visibility":"hidden"});
letterATop3 = vertLetterSpacing*2+20;
letterALeft3 = (windowWidth - letterAWidth);
$("#letterA3").css({"top":(letterATop3),"left":(letterALeft3),"width":(letterAWidth),"height":(letterAHeight), "visibility":"hidden"});
letterATop4 = vertLetterSpacing*3+20;
letterALeft4 = (windowWidth - letterAWidth);
$("#letterA4").css({"top":(letterATop4),"left":(letterALeft4),"width":(letterAWidth),"height":(letterAHeight), "visibility":"hidden"});
letterATop5 = vertLetterSpacing*4+20;
letterALeft5 = (windowWidth - letterAWidth);
$("#letterA5").css({"top":(letterATop5),"left":(letterALeft5),"width":(letterAWidth),"height":(letterAHeight), "visibility":"hidden"});
letterATop6 = vertLetterSpacing*5+20;
letterALeft6 = (windowWidth - letterAWidth);
$("#letterA6").css({"top":(letterATop6),"left":(letterALeft6),"width":(letterAWidth),"height":(letterAHeight), "visibility":"hidden"});
letterATop7 = vertLetterSpacing*6+20;
letterALeft7 = (windowWidth - letterAWidth);
$("#letterA7").css({"top":(letterATop7),"left":(letterALeft7),"width":(letterAWidth),"height":(letterAHeight), "visibility":"hidden"});
letterATop8 = vertLetterSpacing*7+20;
letterALeft8 = (windowWidth - letterAWidth);
$("#letterA8").css({"top":(letterATop8),"left":(letterALeft8),"width":(letterAWidth),"height":(letterAHeight), "visibility":"hidden"});
//alert("Use the LEFT and RIGHT arrow keys to move the easy button left and right and the SPACE BAR to shoot at the letters.\n\n");
//START SHOOTING LETTER A's
myVar = setInterval(function(){targetLoop()},20);
//myVar = setInterval(function(){makeButtonMoveOneDiag()},speed);
}
/*********************************************************MAKE BUTTON MOVE CHASE**************************************************/
function makeButtonMoveChase() {
tempLeft = 0;
tempTop = 0;
//ARRAY OF POSSIBLE POSITIONS - look to easypuzzle2.html
var pos = new Array();
pos[0] = "position:absolute; left: 0; top: 0";
pos[1] = "position:absolute; left: 200; top: 50; width: 200; height: 200";
pos[2] = "position:absolute; left: 400; top: 50; width: 200; height: 200";
pos[3] = "position:absolute; left: 0; top: 250; width: 200; height: 200";
pos[4] = "position:absolute; left: 200; top: 250; width: 200; height: 200";
pos[5] = "position:absolute; left: 400; top: 250; width: 200; height: 200";
pos[6] = "position:absolute; left: 0; top: 450; width: 200; height: 200";
pos[7] = "position:absolute; left: 200; top: 450; width: 200; height: 200";
pos[8] = "position:absolute; left: 400; top: 450; width: 200; height: 200";
$("#easybutton").css({"left":(tempLeft),"top":(tempTop), "visibility":"visible"});
$("#easybutton").mouseenter(function(){
//alert("inside hover function");
if (gameNum == 6) {
if (numTimesChased < 20) {
//alert("inside number times < 20");
tempLeftNew = Math.floor(Math.random()*(windowWidth - buttonWidth));
tempTopNew = Math.floor(Math.random()*(windowHeight - buttonHeight));
//FIGURE OUT TEMPLEFT
var tempInt = Math.abs(tempLeft - tempLeftNew); //horizontal distance between new and old left values
//alert("tempInt = " + tempInt);
if (tempInt < 200) { //new and old positions too close together
if ((tempLeftNew + 200) < (windowWidth - buttonWidth)) {
tempLeftNew = tempLeftNew + 200;
} else {
//alert("too big, subtract instead");
tempLeftNew = tempLeftNew - 200;
//alert("tempLeftNew = " + tempLeftNew);
}
}
//FIGURE OUT TEMPTOP
tempInt = Math.abs(tempTop - tempTopNew); //horizontal distance between new and old left values
//alert("tempInt = " + tempInt);
if (tempInt < 200) { //new and old positions too close together
if ((tempTopNew + 200) < (windowHeight - buttonHeight)) {
//alert("addition OK");
tempTopNew = tempTopNew + 200;
} else {
//alert("too big, subtract instead");
tempTopNew = tempTopNew - 200;
//alert("tempTopNew = " + tempTopNew);
}
}
tempTop = tempTopNew;
tempLeft = tempLeftNew;
$("#easybutton").css({"top":tempTop,"left":tempLeft,"width":200,"height":200});
//clearInterval(myVar);
$("#easybutton").stop(true,false);
} else { //spell out number??
}
}
//alert("inside hover function");
numTimesChased++;
});
}
/*****************************************************MAKE BUTTON MOVE HORIZONTALLY****************************************/
function makeButtonMoveHoriz(speed) {
$("#easybutton").css({"visibility":"visible"});
$(document).ready(function() {
$("#easybutton").delay(500).show(0);
moveRight();
function moveRight() {
$("#easybutton").animate({left: (windowWidth-buttonWidth)},speed);
moveLeft();
}
function moveLeft() {
$("#easybutton").fadeOut(300);
$("#easybutton").animate({left: (0)},300);
$("#easybutton").fadeIn(300);
moveRight();
}
setTimeout(moveRight, 50);
});
}
/************************************************************MOVE VERTICALLY**************************************/
function makeButtonMoveVert(speed) {
//alert("insdie buttonmovevert");
//$("#easybutton").start(true,true);
tempLeft = Math.floor(windowWidth/4);
tempTop = 0;
$("#easybutton").css({"left":(tempLeft),"top":(tempTop)});
//$(document).ready(function() {
//alert("inside ready function");
$("#easybutton").delay(500).show(0);
moveDown();
//setTimeout(moveDown, 50);
//});
function moveDown() {
//alert("inside moveDown //function");
//$("#easybutton").animate({top: (windowHeight-buttonHeight)},speed);
$("#easybutton").animate({top: (windowHeight-buttonHeight)},speed);
moveUp();
}
function moveUp() {
//alert("inside moveUp function");
$("#easybutton").fadeOut(0);
$("#easybutton").animate({top: (0)},0);
$("#easybutton").fadeIn(0);
moveDown();
}
}
/*****************************************************MAKE BUTTON MOVE LEFT TO RIGHT ****************************************/
function makeButtonMoveLeftRight(speed) {
tempLeft = 0;
tempTop = Math.floor((windowHeight - buttonHeight) / 2);
$("#easybutton").css({"left":(tempLeft),"top":(tempTop)});
//$(document).ready(function() {
$("#easybutton").delay(500).show(0);
moveRight();
function moveRight() {
$("#easybutton").animate({left: (windowWidth-buttonWidth)},speed);
moveLeft();
}
function moveLeft() {
//$("#easybutton").fadeOut(300);
//$("#easybutton").delay(500).show(0);
$("#easybutton").animate({left: (0)},speed);
//$("#easybutton").fadeIn(300);
moveRight();
}
//setTimeout(moveRight, 50);
//});
}
/*************************************************************MOVE DIAGONALLY**************************************/
function makeButtonMoveOneDiag() {
if ( tempLeft > (windowWidth - buttonWidth)) {
tempLeft = 0;
}
if ( tempTop > (windowHeight - buttonHeight)) {
tempTop = 0;
}
$("#easybutton").css({"top":tempTop,"left":tempLeft,"width":200,"height":200});
tempLeft = tempLeft + 10;
tempTop = tempTop + 10;
}
function makeButtonMoveDiag(speed) {
tempLeft = 0;
tempTop = 0;
myVar = setInterval(function(){makeButtonMoveOneDiag()},speed);
}
/*********************************************************MOVE RANDOM***********************************************/
function makeButtonMoveOneRandom() {
tempLeft = Math.floor(Math.random()*horizRange);
tempTop = Math.floor(Math.random()*vertRange);
$("#easybutton").css({"top":tempTop,"left":tempLeft,"width":200,"height":200});
// document.getElementById("easybutton").style = "position:absolute; left: " + tempLeft + "; top: " + tempTop + "; width: 200; height: 200";
}
function makeButtonMoveRandom(speed) {
$("#easybutton").css({"left":0,"top":0});
horizRange = windowWidth - buttonWidth;
vertRange = windowHeight - buttonHeight;
myVar = setInterval(function(){makeButtonMoveOneRandom()},speed);
}
/************************************************************MOUSE IS CLICKED ON EASY BUTTON********************************************/
function mouseClick() {
var tempStr;
if (gameNum <7) {
if (gameNum == 1) {
//alert("CLICKED ONBUTTON");
$('#easysound')[0].play();
clearInterval(myVar); //STOP WHATEVER ANIMATION ITS DOING
$("#easybutton").stop(true,false);
//get data from database
//monhof5_data, nums table
//tempStr = getData(gameNum);
//coordString = coordString + "1";
//$("#coordinateButton").text(coordString);
//alert("That was easy! \n\nFinal coordinates: " + coordString + ".\n\nPlease click 'OK', then get ready for more! \n\n(If there's a delay, try moving your mouse.)");
} else if (gameNum == 2) {
$('#easysound')[0].play();
clearInterval(myVar); //STOP WHATEVER ANIMATION ITS DOING
$("#easybutton").stop(true,false);
secretNumber = "";
//coordString = coordString + "2";
//$("#coordinateButton").text(coordString);
} else if (gameNum == 3) {
$('#easysound')[0].play();
clearInterval(myVar); //STOP WHATEVER ANIMATION ITS DOING
$("#easybutton").stop(true,false);
secretNumber = "";
//coordString = coordString + "." + "3";
$("#easybutton").stop(true,true);
//$("#coordinateButton").text(coordString);
} else if (gameNum == 4) {
$('#easysound')[0].play();
clearInterval(myVar); //STOP WHATEVER ANIMATION ITS DOING
$("#easybutton").stop(true,false);
secretNumber = "";
//coordString = coordString + "4";
//$("#coordinateButton").text(coordString);
} else if (gameNum == 5) {
$('#easysound')[0].play();
clearInterval(myVar); //STOP WHATEVER ANIMATION ITS DOING
$("#easybutton").stop(true,false);
//secretNumber = "";
//coordString = coordString + "5";
//$("#coordinateButton").text(coordString);
} else if (gameNum == 6) {
$('#easysound')[0].play();
clearInterval(myVar); //STOP WHATEVER ANIMATION ITS DOING
$("#easybutton").stop(true,false);
//secretNumber = "";
//coordString = coordString + " W 123 " + "6";
//$("#coordinateButton").text(coordString);
$("#easybutton").css("visibility","hidden");
}
gameNum++;
decide();
}
}
/*******************************************************MOUSE CLICK AMMOCAN*****************************************************/
function mouseclickAmmo(which) {
//var numCardsClicked=0; //only let people click 2 cards
//KEEPS TRACK OF HOW MANY OF EACH CARD YOU HAVE TURNED OVER
//var numeasybuttonWide=0;
//var cardsClickedArray=["",""];
//var rowsClickedArray=[0,0];
//var colsClickedArray=[0,0];
var currentId;
var clickedRow;
var clickedCol;
var cardToShow;
if (numCardsClicked == 0) { //first card clicked-don't need to worry about duplicates
//HIDE AMMO CAN AND DISPLAY CARD CLICKED
$(which).css("visibility","hidden"); //hide current ammo can
currentId = $(which).attr('id');
clickedRow = currentId.substring((currentId.length-2),(currentId.length-1));
clickedCol = currentId.substring((currentId.length-1),(currentId.length));
rowsClickedArray[0] = clickedRow;
colsClickedArray[0] = clickedCol;
cardToShow=cardsArray[clickedRow][clickedCol];
tempTop = startTop + clickedRow*ySpacing;
tempLeft = startLeft+ clickedCol*xSpacing;
$("#"+cardToShow).css({"top":tempTop,"left":tempLeft,"width":(xSpacing),"height":(ySpacing), "visibility":"visible"});
cardsClickedArray[0]=cardToShow;
numCardsClicked = 1;
} else if (numCardsClicked == 1) { //already have a card clicked
//DISPLAY NEW CARD
$(which).css("visibility","hidden"); //hide current ammo can
currentId = $(which).attr('id');
clickedRow = currentId.substring((currentId.length-2),(currentId.length-1));
clickedCol = currentId.substring((currentId.length-1),(currentId.length));
rowsClickedArray[1] = clickedRow;
colsClickedArray[1] = clickedCol;
cardToShow=cardsArray[clickedRow][clickedCol];
tempTop = startTop + clickedRow*ySpacing;
tempLeft = startLeft+ clickedCol*xSpacing;
$("#"+cardToShow).css({"top":tempTop,"left":tempLeft,"width":(xSpacing),"height":(ySpacing), "visibility":"visible"});
cardsClickedArray[1]=cardToShow;
//NOW CHECK IF CARDS MATCH - compare elemnts of cardsClickedArray
if ((cardsClickedArray[0].substring(0,(cardsClickedArray[0].length-1))) == (cardsClickedArray[1].substring(0,(cardsClickedArray[1].length-1)))) {
//CARDS MATCH
setTimeout(function() {
//alert("Yeah, they match!");
$('#easysound')[0].play();
$("#"+cardsClickedArray[0]).css("visibility","hidden");
$("#"+cardsClickedArray[1]).css("visibility","hidden");
numCardsClicked=0;
cardsClickedArray[0]="";
cardsClickedArray[1]="";
numMatches++;
if (numMatches == 18) { //matched all of them
//coordString = coordString + "7";
//$("#coordinateButton").text(coordString);
$('#easysound')[0].play();
gameNum++;
decide();
}
}, 500);
} else { //CARDS DON'T MATCH, LEAVE THEM UNTIL ANOTHER CARD IS CLICKED
numCardsClicked = 2;
}
} else if (numCardsClicked == 2) { //already have 2 cards clicked
//HIDE OLD CARDS AND RESET ARRAY
$("#"+cardsClickedArray[0]).css("visibility","hidden");
$("#"+cardsClickedArray[1]).css("visibility","hidden");
cardsClickedArray[1]="";
//DISPLAY NEW CARD
$(which).css("visibility","hidden"); //hide current ammo can
currentId = $(which).attr('id');
clickedRow = currentId.substring((currentId.length-2),(currentId.length-1));
clickedCol = currentId.substring((currentId.length-1),(currentId.length));
cardToShow=cardsArray[clickedRow][clickedCol];
tempTop = startTop + clickedRow*ySpacing;
tempLeft = startLeft+ clickedCol*xSpacing;
$("#"+cardToShow).css({"top":tempTop,"left":tempLeft,"width":(xSpacing),"height":(ySpacing), "visibility":"visible"});
cardsClickedArray[0]=cardToShow;
numCardsClicked = 1;
//DRAW AMMO CANS AGAIN
//$("#ammocan"+rowsClickedArray[0] + "" + colsClickedArray[0])
tempTop = startTop + rowsClickedArray[0]*ySpacing;
tempLeft = startLeft+ colsClickedArray[0]*xSpacing;
tempName = "#ammocan"+rowsClickedArray[0]+""+colsClickedArray[0];
//alert("tempNAme = " + tempName);
$(tempName).css({"top":tempTop,"left":tempLeft,"width":(xSpacing),"height":(ySpacing), "visibility":"visible"});
tempTop = startTop + rowsClickedArray[1]*ySpacing;
tempLeft = startLeft+ colsClickedArray[1]*xSpacing;
tempName = "#ammocan"+rowsClickedArray[1]+""+colsClickedArray[1];
//alert("tempNAme = " + tempName);
$(tempName).css({"top":tempTop,"left":tempLeft,"width":(xSpacing),"height":(ySpacing), "visibility":"visible"});
//SET NEW VALUES
rowsClickedArray[0] = clickedRow;
colsClickedArray[0] = clickedCol;
}
}
/***DANGER*****DANGER: DO NOT LOOK AT THIS CODE. IF YOU DO, YOUR COMPUTER _WILL_ EXPLODE AND POSSIBLY YOUR HEAD TOO***DANGER***DANGER****DANGER***********/
/*********************************************************KEYDOWN********************************************************/
function backbegin() {
if (nasty == true) {
$("#easybutton").css({"top":10,"left":(sizeGrid+10),"width":sizeGrid-2,"height":sizeGrid-2, "visibility":"visible"});
row = 0;
col = 1;
}
}
/****************************************************************************MAZE KEYS*******************************************************************/
function mazeKeys(keypressed) {
if (keypressed == 38) { //UP ARROW
//alert("up arrow pressed, row, col = "+ row + " " + col);
if ((row == 1) && (col == 80)) { //MADE IT TO )THE END
//PLAY EASY SOUND
//$("#easysound")[0].play();
//alert("made it to the end");
//coordString = coordString + "90";
//$("#coordinateButton").text(coordString);
$("#myCanvas").css("visibility","hidden");
clearInterval(myVar);
$("#muggle0").css("visibility","hidden");
$("#muggle1").css("visibility","hidden");
$("#muggle2").css("visibility","hidden");
$("#muggle3").css("visibility","hidden");
$("#easybutton").css("visibility","hidden");
$("#muggleButton").css("visibility","hidden");
gameNum++;
decide();
}
if (row > 0) { //at least zero
if (rows[row-1][col] == 0) {
//$("#easybutton").animate({top:"-="+sizeGrid});
tempTop = tempTop - sizeGrid;
$("#easybutton").css("top",tempTop);
row = row - 1;
} else {
backbegin();
}
}
//alert("row = " + row + " col = " + col);
} else if (keypressed == 40) { //DOWN ARROW
//alert("down arrow pressed");
//check if move is allowed
if (row < 32) { //max 32
if (rows[row+1][col] == 0) {
//$("#easybutton").animate({top:"+="+sizeGrid});
tempTop = tempTop + sizeGrid;
$("#easybutton").css("top",tempTop);
row = row + 1;
} else {
backbegin();
}
}
//alert("row = " + row + " col = " + col);
} else if (keypressed == 39) {//RIGHT ARROW
if (col < 81) {
if (rows[row][col+1] == 0) {
//$("#easybutton").animate({left:"+="+sizeGrid});
tempLeft = tempLeft + sizeGrid;
$("#easybutton").css("left",tempLeft);
col = col + 1;
} else {
backbegin();
}
}
//alert("row = " + row + " col = " + col);
} else if (keypressed == 37) { //LEFT ARROW
if (col > 0) {
if (rows[row][col-1] == 0) {
//$("#easybutton").animate({left:"-="+sizeGrid});
tempLeft = tempLeft - sizeGrid;
$("#easybutton").css("left",tempLeft);
//$("#easybutton").css("left",(left - sizeGrid));
col = col - 1;
} else {
backbegin();
}
}
}
}
/*********************************************************TARGET KEYS********************************************************/
function targetKeys(keypressed) {
if (keypressed == 39) {//RIGHT ARROW
//alert("right arrow pressed");
if ((easyLeft + 20) < windowWidth) {
//alert("less than");
easyLeft = easyLeft + 20;
}
$("#easybutton").css({"top":(easyTop),"left":(easyLeft)});
} else if (keypressed == 37) { //LEFT ARROW
//alert("left arrow pressed");
if ((easyLeft - 20) > 0) {
easyLeft = easyLeft - 20;
}
$("#easybutton").css({"top":(easyTop),"left":(easyLeft)});
} else if (keypressed == 32) { //SPACE BAR - shoot easy button vertically, then returns to original Top position at bottom of screen
//alert("space bar pressed");
spaceBarPressed = true;
//$("#easybutton").animate({top: (0)}, 1000, "linear");
//$("#easybutton").fadeOut(1);
//$("#easybutton").animate({top: (targetTop)}, 200, "linear");
//$("#easybutton").fadeIn(1);
}
}
/*********************************************************KEYDOWN********************************************************/
$(window).keydown(function(e) {
if (gameNum == 9) {
mazeKeys(e.keyCode);
} else if (gameNum == 8) {
targetKeys(e.keyCode);
}
});
/*****************************************************FINALE*************************************************************/
function finale() {
var dataString=""; //coordinate string from database
var buttonStartArray=new Array();
var buttonEndArray=new Array();
var count=0;
var dataStringLen = 24;
$("#hintButton").css("visibility","hidden");
//FETCH 1 line of data FROM DATABASE
$.ajax({
url: 'easypuzzleBACKUP.php',
data: "",
async: false,
dataType: 'json',
success: function(data)
{
//$.each([ 52, 97 ], function( index, value ) {
// alert( index + ": " + value );
//});
$.each(data, function( index, value ) {
//alert( index + ": " + value.position + ", " + value.coordString+ ", " +value.buttonStart+", "+value.buttonEnd);
buttonStartArray[count] = value.buttonStart;
buttonEndArray[count] = value.buttonEnd;
if (count ==0) {
dataString = value.coordString;
}
count++;
});
}
});
//alert("dataString = " + dataString1 + " " + dataString2 + " " + dataString3 + " " + dataString4 + " " + dataString5);
//ARRAYS TELLING YOU WHERE TO PLACE MINI EASY BUTTONS, D = degrees, P = decimal point, S = space
//var rowArrayTemp = new Array; //copy other arrays to this one
//var colArrayTemp = new Array; //copy other arrays to this one
var rowArrayN=[0,0,1,1,1,2,2,2,3,3,3,4,4];
var colArrayN=[0,4,0,1,4,0,2,4,0,3,4,0,4];
var rowArrayW=[0,0,1,1,1,2,2,2,3,3,4,4];
var colArrayW=[0,4,0,2,4,0,2,4,1,3,1,3];
var rowArrayD=[0,0,1,1];
var colArrayD=[0,1,0,1];
var rowArrayP=[3,3,4,4];
var colArrayP=[1,2,1,2];
var rowArrayS;
var colArrayS;
var rowArray = new Array(10); //2-dimensional array
var colArray = new Array(10);
rowArray[0]=[0,0,0,0,0,1,1,2,2,3,3,4,4,4,4,4];
colArray[0]=[0,1,2,3,4,0,4,0,4,0,4,0,1,2,3,4];
rowArray[1]=[0,1,2,3,4];
colArray[1]=[2,2,2,2,2];
rowArray[2]=[0,0,0,0,0,1,2,2,2,2,2,3,4,4,4,4,4];
colArray[2]=[0,1,2,3,4,4,0,1,2,3,4,0,0,1,2,3,4];
rowArray[3]=[0,0,0,0,0,1,2,2,2,2,2,3,4,4,4,4,4];
colArray[3]=[0,1,2,3,4,4,0,1,2,3,4,4,0,1,2,3,4];
rowArray[4]=[0,0,1,1,2,2,2,2,2,3,4];
colArray[4]=[0,4,0,4,0,1,2,3,4,4,4];
rowArray[5]=[0,0,0,0,0,1,2,2,2,2,2,3,4,4,4,4,4];
colArray[5]=[0,1,2,3,4,0,0,1,2,3,4,4,0,1,2,3,4];
rowArray[6]=[0,0,0,0,0,1,2,2,2,2,2,3,3,4,4,4,4,4];
colArray[6]=[0,1,2,3,4,0,0,1,2,3,4,0,4,0,1,2,3,4];
rowArray[7]=[0,0,0,0,0,1,2,3,4];
colArray[7]=[0,1,2,3,4,4,4,4,4];
rowArray[8]=[0,0,0,0,0,1,1,2,2,2,2,2,3,3,4,4,4,4,4];
colArray[8]=[0,1,2,3,4,0,4,0,1,2,3,4,0,4,0,1,2,3,4];
rowArray[9]=[0,0,0,0,0,1,1,2,2,2,2,2,3,4];
colArray[9]=[0,1,2,3,4,0,4,0,1,2,3,4,4,4];
//dimensions mini easy buttons
var miniWidth;
var miniHeight;
//24 total characters in final coordinates
//top left starting position
var startLeft;
var startTop;
//CALCULATE DIMENSIONS and TOP LEFT STARTING POSITION
miniWidth = Math.floor((windowWidth - 100)/24/6);
//alert("miniWidth = " + miniWidth);
miniHeight=miniWidth; //square
//alert("miniHeight = " + miniHeight);
startLeft = 50;
//alert("startLeft = " + startLeft);
startTop = Math.floor((windowHeight - (5*miniHeight))/2);
//startTop = 400;
//alert("startTop = " + startTop);
//DRAW WORD "EASY" OUT OF MINI EASY BUTTONS
//ANIMATE INTO FORMING FINAL COORDINATES
var tempStrF="";
var rowArrayName="";
var colArrayName="";
var finalTopArray = new Array();
var finalLeftArray = new Array();
//fruits.push("Kiwi")
//var buttonStartArray=new Array();
//var buttonEndArray=new Array();
var whichEasy=""; //global variable
for (var i=0; i<24; i++) { //draw 1 character at a time (24 total characters)
//alert("inside for loop");
tempStrF = dataString.substring(i,i+1);
//alert("tempStrF = " + tempStrF);
//ACCESS RIGHT ARRAY
if (tempStrF == "N") {
//alert("inside N");
for (var j=0;j<(buttonEndArray[i]-buttonStartArray[i]+1);j++) { //draw 1 mini button at a time (number of easy buttons varies)idt)
//alert("j="+j);
//alert("startLeft="+startLeft);
//alert("miniWidth="+miniWidth);
//alert("colArrayN[j]="+colArrayN[0]);
tempLeft = startLeft + i*6*miniWidth + (colArrayN[j])*miniWidth;
//alert("tempLeft="+tempLeft);
tempTop = startTop + (rowArrayN[j])*miniHeight;
//alert("tempTop="+tempTop);
var tempint = parseInt(buttonStartArray[i]) + j;
whichEasy = "easyButtonMini" + tempint;
//alert("whichEasy="+whichEasy);
finalTopArray.push(tempTop);
finalLeftArray.push(tempLeft);
//$("#"+whichEasy).css({"left":tempLeft,"top":tempTop,"width":miniWidth,"height":miniHeight,"visibility":"visible"});
}
} else if (tempStrF == "W") {
//alert("inside W");
for (var j=0;j<(buttonEndArray[i]-buttonStartArray[i]+1);j++) { //draw 1 mini button at a time (number of easy buttons varies)idt)
tempLeft = startLeft + i*6*miniWidth + (colArrayW[j])*miniWidth;
tempTop = startTop + (rowArrayW[j])*miniHeight;
var tempint = parseInt(buttonStartArray[i]) + j;
whichEasy = "easyButtonMini" + tempint;
finalTopArray.push(tempTop);
finalLeftArray.push(tempLeft);
//$("#"+whichEasy).css({"left":tempLeft,"top":tempTop,"width":miniWidth,"height":miniHeight,"visibility":"visible"});
}
} else if (tempStrF == "D") {
//alert("inside D");
for (var j=0;j<(buttonEndArray[i]-buttonStartArray[i]+1);j++) { //draw 1 mini button at a time (number of easy buttons varies)idt)
//alert("j="+j);
//alert("startLeft="+startLeft);
//alert("miniWidth="+miniWidth);
//alert("colArrayN[j]="+colArrayN[0]);
tempLeft = startLeft + i*6*miniWidth + (colArrayD[j])*miniWidth;
//alert("tempLeft="+tempLeft);
tempTop = startTop + (rowArrayD[j])*miniHeight;
//alert("tempTop="+tempTop);
var tempint = parseInt(buttonStartArray[i]) + j;
whichEasy = "easyButtonMini" + tempint;
finalTopArray.push(tempTop);
finalLeftArray.push(tempLeft);
//alert("whichEasy="+whichEasy);
//$("#"+whichEasy).css({"left":tempLeft,"top":tempTop,"width":miniWidth,"height":miniHeight,"visibility":"visible"});
}
} else if (tempStrF == "P") {
//alert("inside P");
for (var j=0;j<(buttonEndArray[i]-buttonStartArray[i]+1);j++) { //draw 1 mini button at a time (number of easy buttons varies)idt)
tempLeft = startLeft + i*6*miniWidth + (colArrayP[j])*miniWidth;
tempTop = startTop + (rowArrayP[j])*miniHeight;
var tempint = parseInt(buttonStartArray[i]) + j;
whichEasy = "easyButtonMini" + tempint;
finalTopArray.push(tempTop);
finalLeftArray.push(tempLeft);
//$("#"+whichEasy).css({"left":tempLeft,"top":tempTop,"width":miniWidth,"height":miniHeight,"visibility":"visible"});
}
} else if (tempStrF == "S") { //do nothing, just leave a space of 5*miniWidth
//alert("drawing space");
} else { //MUST BE A NUMBER FROM 0-9
//rowArray[0]=[0,0,0,0,0,1,1,2,2,3,3,4,4,4,4,4];
//colArray[0]=[0,1,2,3,4,0,4,0,4,0,4,0,1,2,3,4];
//alert("drawing integer");
for (var j=0;j<(buttonEndArray[i]-buttonStartArray[i]+1);j++) { //draw 1 mini button at a time (number of easy buttons varies)idt)
tempLeft = startLeft + i*6*miniWidth + (colArray[tempStrF][j])*miniWidth;
tempTop = startTop + (rowArray[tempStrF][j])*miniHeight;
var tempint = parseInt(buttonStartArray[i]) + j;
whichEasy = "easyButtonMini" + tempint;
finalTopArray.push(tempTop);
finalLeftArray.push(tempLeft);
//$("#"+whichEasy).css({"left":tempLeft,"top":tempTop,"width":miniWidth,"height":miniHeight,"visibility":"visible"});
}
}
}
//alert("drawn");
//DRAW BIG WORD EASY AND MORPH INTO COORDINATES
var megaWidth;
var megaHeight;
var megaStartLeft;
var megaStartTop;
megaWidth = Math.floor((windowWidth-50)/46);
megaHeight = megaWidth;
//alert("megaWidth = " + megaWidth);
megaStartLeft = 25;
megaStartTop = Math.floor((windowHeight - (megaWidth*14))/2);
rowArrayE=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,2,2,3,3,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,6,6,7,7,8,8,8,8,8,8,8,8,8,8,9,9,9,9,9,9,9,9,9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
//alert("tempLeft="+tempLeft);
tempTop = megaStartTop + (rowArrayE[i])*megaHeight;
//alert("tempTop="+tempTop);
//var tempint = i;
whichEasy = "easyButtonMini" + i;
//alert("whichEasy="+whichEasy);
$("#"+whichEasy).css({"left":tempLeft,"top":tempTop,"width":megaWidth,"height":megaHeight,"visibility":"visible"});
}
//DRAW A
for (i=78;i<149;i++) {
tempLeft = megaStartLeft + 12*megaWidth + (colArrayA[i-78])*megaWidth;
//alert("tempLeft="+tempLeft);
tempTop = megaStartTop + (rowArrayA[i-78])*megaHeight;
//alert("tempTop="+tempTop);
//var tempint = i;
whichEasy = "easyButtonMini" + i;
//alert("whichEasy="+whichEasy);
$("#"+whichEasy).css({"left":tempLeft,"top":tempTop,"width":megaWidth,"height":megaHeight,"visibility":"visible"});
}
//DRAW S
for (i=149;i<227;i++) {
tempLeft = megaStartLeft + 24*megaWidth + (colArrayS[i-149])*megaWidth;
//alert("tempLeft="+tempLeft);
tempTop = megaStartTop + (rowArrayS[i-149])*megaHeight;
//alert("tempTop="+tempTop);
//var tempint = i;
whichEasy = "easyButtonMini" + i;
//alert("whichEasy="+whichEasy);
$("#"+whichEasy).css({"left":tempLeft,"top":tempTop,"width":megaWidth,"height":megaHeight,"visibility":"visible"});
}
//DRAW Y
for (i=227;i<266;i++) {
tempLeft = megaStartLeft + 36*megaWidth + (colArrayY[i-227])*megaWidth;
//alert("tempLeft="+tempLeft);
tempTop = megaStartTop + (rowArrayY[i-227])*megaHeight;
//alert("tempTop="+tempTop);
//var tempint = i;
whichEasy = "easyButtonMini" + i;
//alert("whichEasy="+whichEasy);
$("#"+whichEasy).css({"left":tempLeft,"top":tempTop,"width":megaWidth,"height":megaHeight,"visibility":"visible"});
}
// DELAY
setTimeout(function() {
lastBit(finalTopArray,finalLeftArray,miniWidth,miniHeight);
}, 5000);
}
function lastBit(finalTopArray1,finalLeftArray1,miniWidth1,miniHeight1) {
var finalTop;
var finalLeft;
var whichOne1;
//alert("inside lastbit");
for (var i = 0; i < 266; i++) {
whichOne1 = "easyButtonMini" + i;
//alert("whichOne = " + whichOne1);
finalTop = finalTopArray1[i];
//alert("finalTop = " + finalTop);
finalLeft = finalLeftArray1[i];
//alert("finalLeft = " + finalLeft);
//$("#"+whichOne1).css({"left":finalLeft,"top":finalTop,"width":miniWidth1,"height":miniHeight1,"visibility":"visible"});
$("#"+whichOne1).animate({left:finalLeft,top:finalTop,width:miniWidth1,height:miniHeight1},5000);
//$("#easybutton").animate({left: (0)},300);
}
setTimeout(function() {
lastsound();
sendEmail();
}, 5000);
}
function lastsound() {
$('#easysound')[0].play();
}
//SENDS EMAIL STATING THAT GAME HAS BEEN COMPLETED
function sendEmail() {
//alert("inside email function");
$.ajax({
type: 'POST',
url: 'sendEmail.php',
success: function(data) {
//alert("success!");
}
});
}