//+------------------------------------------------------------+ //| Bubble Puzzle Version 3.1 | //| Created 10/01/1999 Last Modified 09/18/2000 | //| Web Site: http://yx.webprovider.com | //| eMail: yangxin@iname.com | //+------------------------------------------------------------+ //| Copyright 1999,2000 Xin Yang All Rights Reserved. | //+------------------------------------------------------------+ //| For personal purpose, send me your URL and put a link back | //| to my web site, then you can use this script free. | //| | //| For commercial purpose, obtain quotation for referencing, | //| using, hosting, selling or distributing this script. | //| | //| In all cases copyright must remain intact. | //+------------------------------------------------------------+ // game levels: var bubbleLevels = new Array(); var bubbleFeedings = new Array(); var bubbleControls = new Array(); bubbleLevels[0] = new Array(-1,-1,0,0,1,1,-1,-1, -1,2,2,3,3,-1,-1, -1,-1,4,4,5,5,-1,-1, -1,6,6,7,7,-1,-1, 99); bubbleFeedings[0] = new Array(7,6,5,4,3,2,1,0); bubbleControls[0] = new Array(0,2,0,30,150); bubbleLevels[1] = new Array(-1,0,4,-1,-1,5,0,-1, 0,-1,4,-1,5,-1,0, -1,1,-1,6,6,-1,1,-1, -1,1,-1,-1,-1,1,-1, -1,-1,2,-1,-1,2,-1,-1, -1,-1,2,-1,2,-1,-1, -1,-1,-1,7,7,-1,-1,-1, 99); bubbleFeedings[1] = new Array(7,2,2,1,1,0,0,6,4,5); bubbleControls[1] = new Array(1,2,0,30,150); bubbleLevels[2] = new Array(-1,0,0,1,1,2,2,-1, 3,-1,-1,-1,-1,-1,4, -1,3,7,6,5,2,4,-1, 5,-1,-1,-1,-1,-1,6, -1,5,1,2,3,7,6,-1, 7,-1,-1,-1,-1,-1,0, -1,7,4,5,7,6,0,-1, 99); bubbleFeedings[2] = new Array(0,7,6,5,4,3,0,1,2); bubbleControls[2] = new Array(0,2,500,30,150); bubbleLevels[3] = new Array(-1,-1,-1,0,0,-1,-1,-1, -1,1,2,-1,3,4,-1, -1,1,-1,2,3,-1,4,-1, -1,5,6,-1,7,0,-1, -1,5,-1,6,7,-1,0,-1, -1,1,1,-1,2,2,-1, -1,-1,-1,3,3,-1,-1,-1); bubbleFeedings[3] = new Array(3,1,2,5,0,6,7,1,4,2,3,0); bubbleControls[3] = new Array(0,0,750,15,60); bubbleLevels[4] = new Array(0,-1,-1,-1,1,1,2,2, 0,-1,-1,-1,7,-1,-1, -1,1,-1,-1,-1,7,-1,-1, -1,1,-1,-1,-1,6,-1, -1,-1,2,-1,-1,-1,6,-1, -1,-1,2,-1,-1,-1,5, 4,4,3,3,-1,-1,-1,5, 99); bubbleFeedings[4] = new Array(5,2,0,7,1,2); bubbleControls[4] = new Array(0,1,1000,30,150); bubbleLevels[5] = new Array(-1,-1,0,-1,-1,0,-1,-1, -1,-1,3,-1,3,-1,-1, 2,2,-1,3,3,-1,2,2, -1,2,2,7,2,2,-1, -1,1,1,7,7,1,1,-1, 1,5,5,7,5,5,1, -1,5,-1,4,4,-1,5,-1, 5,-1,-1,-1,-1,-1,5); bubbleFeedings[5] = new Array(5,1,5,1,4,2,2,7,3,0,1,2,0,0,0,0); bubbleControls[5] = new Array(0,4,1000,120,165); bubbleLevels[6] = new Array(-1,-1,3,-1,-1,3,-1,-1, -1,3,2,-1,2,3,-1, -1,-1,4,2,2,4,-1,-1, 5,5,0,-1,0,5,5, -1,-1,7,-1,-1,7,-1,-1, -1,7,-1,0,-1,7,-1, -1,-1,7,3,3,7,-1,-1, -1,-1,-1,3,-1,-1,-1, 99); bubbleFeedings[6] = new Array(0,1,6,7,4,5,2,3,0,1,5,1,3,4,3,2,3); bubbleControls[6] = new Array(0,2,1000,30,150); bubbleLevels[7] = new Array(-1,2,2,0,-1,7,0,0, -1,-1,0,-1,7,-1,3, -1,-1,1,-1,5,-1,6,-1, -1,2,-1,4,-1,6,-1, -1,6,-1,2,-1,5,-1,-1, 5,-1,1,-1,4,-1,-1, 4,7,0,-1,3,2,0,-1, 99); bubbleFeedings[7] = new Array(4,0,7,3,7,0,3,6,7,4,7,0,3,0,1,7,3,4,5,6,2,2,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7); bubbleControls[7] = new Array(0,3,1000,30,150); bubbleLevels[8] = new Array(-1,-1,-1,1,0,-1,-1,-1, -1,-1,0,-1,1,-1,-1, -1,-1,-1,1,0,-1,-1,-1, -1,3,2,-1,4,5,-1, -1,2,-1,3,5,-1,4,-1, -1,3,2,-1,4,5,-1, 99); bubbleFeedings[8] = new Array(0,1,2,3,4,5,6,7,0,1,2,3,4,5,6,7,2,3,4,5,6,7,2,3,4,5,6,7,0,1); bubbleControls[8] = new Array(2,2,800,30,150); bubbleLevels[9] = new Array(-1,-1,-1,5,-1,-1,-1,-1, -1,-1,7,-1,1,7,-1, -1,4,-1,7,1,-1,-1,-1, -1,5,5,0,2,2,-1, -1,-1,-1,4,6,-1,1,-1, -1,6,4,-1,6,-1,-1, -1,-1,-1,-1,2,-1,-1,-1, 99); bubbleFeedings[9] = new Array(0,3,1,7,3,0,2,5,1,7,5,0,1,2,3,4,6,5); bubbleControls[9] = new Array(0,2,600,30,150); // game codes: var isIE4=false,isNN4=false; var baseX=0,baseY=0; var baseWidth=207,baseMiddle=103,baseBottom=288,baseHeight=308,baseLine=196; var baseMargin=5,borderLeft=0,borderRight=0; var bubbleSize=25; var bubbleStep=20; var bubbleRadiusSmall=12,bubbleRadiusLarge=13; var bubbleDistance=23; var bubbleMax=10,bubbleNormal=8; var bubbleTableSize=8,bubbleTable=new Array(); var bubbleChecked=0,bubbleTrain=0; var bubbleX=0,bubbleY=0,bubbleStepX=0,bubbleStepY=0,bubbleUnitX=0.0,bubbleUnitY=0.0; var bubbleFired=false; var bubbleNum=0; var bubbleCount=0; var bubbleBounce=0; var bubbleTimer=0; var bubbleID=""; var bubbleIDNum=0; var bubbleBonus=100; var bubbleHammer=8,bubbleMulti=9; var bubbleMultiCount=0,bubbleMultiX=new Array(),bubbleMultiY=new Array(),bubbleMultiChecked=new Array(); var bubbleDropFinished=true,bubbleLevelStarted=false; var touchingX=0,touchingY=0,touchedX=0,touchedY=0,lastDimX=0,lastDimY=0; var deltaLength=new Array(25,25,25,25,25,25,25,25,24,24,23,23,22,22,21,21,20,19,18,17,16,15,13,11,9); var hitSide=false,hitTop=false,hitBubble=false; var bubbleLevelMax=0,bubbleLevel=0,bubbleFeedingMax=0,bubbleFeeding=0; var bubbleImage=new Array(); function loadBubble() { for (var i=0; i'; var pointSize=3,pointRadius=1; var pointImage=new Image(pointSize,pointSize); pointImage.src="point.gif"; var dotSize=5,dotRadius=2; var dotImage=new Image(dotSize,dotSize); dotImage.src="dot.gif"; var infoSize=15,infoRadius=7; var infoImage=new Image(infoSize,infoSize); infoImage.src="info.gif"; var infoX=0,infoY=0; var clockSize=15,clockRadius=7; var clockImage=new Image(clockSize,clockSize); clockImage.src="clock.gif"; var clockX=0,clockY=0; var radianUnit=Math.PI/180; var meterSize=5,meterRadius=2; var meterImage=new Image(meterSize,meterSize); meterImage.src="meter.gif"; var meterTimer=0,meterSlice=8,meterCenter=2,meterStep=2; var meterOffset=new Array(); var gunX=0,gunY=0; var gunAngleStep=3,gunAngleSlice=180/gunAngleStep,gunAngleCenter=gunAngleSlice/2,gunAngles=new Array(); var gunOffset=new Array(Math.ceil(-bubbleSize*8/3),Math.ceil(-bubbleSize*4/3),0,Math.floor(bubbleSize*4/3),Math.floor(bubbleSize*8/3)); var gunLevelOffset=0; var gunPointMax=5,gunPoint=new Array(57,47,37,27,17); var gunPointEnd=67,gunPointBegin=17; var gunMargin=gunPointBegin+dotRadius; var gunMoveDirection=1; var gunAngle=gunAngleCenter,gunAngleBegin=0,gunAngleEnd=0; var gunDirection=0; var gunTimer=0; var layerCount=-1; var layerStatus=new Array(); var layerDrop=new Array(); var layerStep=new Array(); var layerTimer=0; var layerString1='
' var numberWidth=10,numberHeight=15; var numbers=new Array(); function loadNumber() { for (var i=0; i<10; i++) { numbers[i]=new Image(numberWidth,numberHeight); numbers[i].src=(""+i+".gif"); } } loadNumber(); var numberX=0,numberY=0; var numberPosition=new Array(); var scoreSize=4; var gameScoreNumber=0,highScoreNumber=1; var numberDigit=new Array(new Array(new Array(0,0),new Array(0,0),new Array(0,0),new Array(0,0)),new Array(new Array(0,0),new Array(0,0),new Array(0,0),new Array(0,0))); var numberShown=new Array(new Array(1,1,1,1),new Array(1,1,1,1)); var numberID="number",numberCount=0; var numberTag1= '
'; var highScore=0,gameScore=0; var infoWindow=null; function showInformation() { if (infoWindow==null) infoWindow=window.open("info.html","infoWindow","width=480,height=450,titlebar=1") else if (infoWindow.closed) infoWindow=window.open("info.html","infoWindow","width=480,height=450,titlebar=1") else infoWindow.focus(); } function moveMeter() { meterStep=(meterStep>0) ? meterStep-1 : meterSlice-1; moveLayerTo("meter",clockX+meterOffset[meterStep].x-meterRadius,clockY-meterOffset[meterStep].y-meterRadius); if (meterStep==meterCenter) { if (!bubbleFired) fireBubble(); } else meterTimer=setTimeout("moveMeter()",bubbleControls[bubbleLevel][2]); } function restoreMeter() { meterStep=meterCenter; moveLayerTo("meter",clockX-meterRadius,clockY-clockRadius-meterRadius); } function newMeter(meterIndex) { this.x=Math.round(Math.cos(meterIndex*45*radianUnit)*clockRadius); this.y=Math.round(Math.sin(meterIndex*45*radianUnit)*clockRadius); } function setMeter() { for (var i=0; i '); showLayer("tablef1",baseY,baseX,baseWidth,baseLine,2,'
 
'); showLayer("tablef2",baseY+baseLine+1,baseX,baseWidth,baseHeight-(baseLine+1),2,'
 
'); showLayer("point1",gunY-gunPoint[0]-pointRadius,gunX-pointRadius,pointSize,pointSize,5,''); showLayer("point2",gunY-gunPoint[1]-pointRadius,gunX-pointRadius,pointSize,pointSize,5,''); showLayer("point3",gunY-gunPoint[2]-pointRadius,gunX-pointRadius,pointSize,pointSize,5,''); showLayer("point4",gunY-gunPoint[3]-pointRadius,gunX-pointRadius,pointSize,pointSize,5,''); showLayer("point5",gunY-gunPoint[4]-pointRadius,gunX-pointRadius,pointSize,pointSize,5,''); showLayer("dot1",gunY-dotRadius,gunX-gunPointBegin-dotRadius,dotSize,dotSize,5,''); showLayer("dot2",gunY-dotRadius,gunX+gunPointBegin-dotRadius,dotSize,dotSize,5,''); showLayer("info",infoY-infoRadius,infoX-infoRadius,infoSize,infoSize,3,''); showLayer("clock",clockY-clockRadius,clockX-clockRadius,clockSize,clockSize,3,''); showLayer("meter",clockY-clockRadius-meterRadius,clockX-meterRadius,meterSize,meterSize,3,''); } function showLayer(_layerID,_top,_left,_width,_height,_zIndex,_layerHTML) { if (isIE4) { document.body.insertAdjacentHTML("BeforeEnd",('
'+_layerHTML+'
')); } else { document.layers[_layerID]=new Layer(_width); with (document.layers[_layerID]) { height=_height; top=_top; left=_left; clip.top=0; clip.left=0; clip.bottom=_height; clip.right=_width; zIndex=_zIndex; document.open("text/html"); document.writeln(_layerHTML); document.close(); visibility="show"; } } } function indexLayer(layerID,layerIndex) { if (isIE4) document.all[layerID].style.zIndex=layerIndex else document.layers[layerID].zIndex=layerIndex; } function getLayerTop(layerID) { if (isIE4) return document.all[layerID].style.pixelTop else return document.layers[layerID].top; } function moveLayerBy(layerID,x,y) { if (isIE4) { document.all[layerID].style.pixelLeft+=x; document.all[layerID].style.pixelTop+=y; } else { document.layers[layerID].moveBy(x,y); } } function moveLayerTo(layerID,x,y) { if (isIE4) { document.all[layerID].style.pixelLeft=x; document.all[layerID].style.pixelTop=y; } else { document.layers[layerID].moveTo(x,y); } } function drawLayer(layerID,layerHTML) { if (isIE4) { document.all[layerID].innerHTML=layerHTML; } else { with (document.layers[layerID].document) { open("text/html"); writeln(layerHTML); close(); } } } function getLayerID(layerNum) { return "bubble"+layerNum+""; } function randomBubble() { return Math.floor(Math.random()*bubbleMax); } function nextBubble() { if (bubbleFeeding0) meterTimer=setTimeout("moveMeter()",bubbleControls[bubbleLevel][2]); } function fireBubble() { if (!bubbleFired) { clearTimeout(meterTimer); restoreMeter(); bubbleX=gunX+gunLevelOffset; bubbleY=gunY; bubbleUnitX=gunAngles[gunAngle].x; bubbleUnitY=gunAngles[gunAngle].y; bubbleStepX=bubbleStep*bubbleUnitX; bubbleStepY=bubbleStep*bubbleUnitY; bubbleFired=true; bubbleBounce=0; bubbleLevelStarted=true; getHit(); moveBubble(); } } function getBubble() { var layerLength=layerStatus.length; var layerNum=-1; var bubbleLayer=""; var layerID=""; for (var i=0; igunAngleEnd || gunAngle0 && x<(bubbleTableSize-1)) { if (bubbleTable[x][y-1].bubbleNum>=0 && !bubbleTable[x][y-1].onBoardChecked) checkOnBoard(x,y-1); } if (x<(bubbleTableSize-1)) { if (bubbleTable[x+1][y].bubbleNum>=0 && !bubbleTable[x+1][y].onBoardChecked) checkOnBoard(x+1,y); } if (y<(bubbleTableSize-1) && x<(bubbleTableSize-1)) { if (bubbleTable[x][y+1].bubbleNum>=0 && !bubbleTable[x][y+1].onBoardChecked) checkOnBoard(x,y+1); } if (y<(bubbleTableSize-1) && x>0) { if (bubbleTable[x-1][y+1].bubbleNum>=0 && !bubbleTable[x-1][y+1].onBoardChecked) checkOnBoard(x-1,y+1); } if (x>0) { if (bubbleTable[x-1][y].bubbleNum>=0 && !bubbleTable[x-1][y].onBoardChecked) checkOnBoard(x-1,y); } if (x>0 && y>0) { if (bubbleTable[x-1][y-1].bubbleNum>=0 && !bubbleTable[x-1][y-1].onBoardChecked) checkOnBoard(x-1,y-1); } } else { if (y>0) { if (bubbleTable[x+1][y-1].bubbleNum>=0 && !bubbleTable[x+1][y-1].onBoardChecked) checkOnBoard(x+1,y-1); } if (x<(bubbleTableSize-2)) { if (bubbleTable[x+1][y].bubbleNum>=0 && !bubbleTable[x+1][y].onBoardChecked) checkOnBoard(x+1,y); } if (y<(bubbleTableSize-1)) { if (bubbleTable[x+1][y+1].bubbleNum>=0 && !bubbleTable[x+1][y+1].onBoardChecked) checkOnBoard(x+1,y+1); } if (y<(bubbleTableSize-1)) { if (bubbleTable[x][y+1].bubbleNum>=0 && !bubbleTable[x][y+1].onBoardChecked) checkOnBoard(x,y+1); } if (x>0) { if (bubbleTable[x-1][y].bubbleNum>=0 && !bubbleTable[x-1][y].onBoardChecked) checkOnBoard(x-1,y); } if (y>0) { if (bubbleTable[x][y-1].bubbleNum>=0 && !bubbleTable[x][y-1].onBoardChecked) checkOnBoard(x,y-1); } } return; } function clearOnBoard() { for (var i=0; i=0 && !bubbleTable[i][j].onBoard) { layerNum=bubbleTable[i][j].layerNum; layerID=getLayerID(layerNum); indexLayer(layerID,4); layerDrop[layerNum]=true; layerStep[layerNum]=Math.ceil(Math.random()*bubbleStep); bubbleTable[i][j].bubbleNum=-1; bubbleTable[i][j].layerNum=-1; bubbleCut++; } return bubbleCut; } function dropBubble() { var layerLength=layerStatus.length; var layerNum=0; var layerID=""; var bubbleDone=true; bubbleDropFinished=false; for (var i=0; igunY) { moveLayerTo(layerID,-bubbleSize,-bubbleSize); indexLayer(layerID,3); layerStatus[i]=true; layerDrop[i]=false; layerStep[i]=0; } else { bubbleDone=false; moveLayerBy(layerID,0,layerStep[i]); layerStep[i]++; } } } if (!bubbleDone) layerTimer=setTimeout("dropBubble()",10) else bubbleDropFinished=true; } function markMulti() { for (var i=0; i=0 && !bubbleTable[i][0].onBoardChecked) checkOnBoard(i,0); bubbleDone=calculateScore(cutBubble()); eventInit(); clearTimeout(layerTimer); dropBubble(); if (bubbleDone) { levelFinished(); bubbleLevel++; levelStart(); } else nextBubble(); } function checkBubble(x,y) { var bubbleMatched=false; bubbleTable[x][y].checked=true; bubbleChecked++; bubbleTrain++; if (y%2==0) { if (y>0 && x<(bubbleTableSize-1)) { if (bubbleTable[x][y-1].bubbleNum==bubbleNum) if (!bubbleTable[x][y-1].checked) bubbleMatched=checkBubble(x,y-1) } if (x<(bubbleTableSize-1)) { if (bubbleTable[x+1][y].bubbleNum==bubbleNum) if (!bubbleTable[x+1][y].checked) bubbleMatched=checkBubble(x+1,y) } if (y<(bubbleTableSize-1) && x<(bubbleTableSize-1)) { if (bubbleTable[x][y+1].bubbleNum==bubbleNum) if (!bubbleTable[x][y+1].checked) bubbleMatched=checkBubble(x,y+1) } if (y<(bubbleTableSize-1) && x>0) { if (bubbleTable[x-1][y+1].bubbleNum==bubbleNum) if (!bubbleTable[x-1][y+1].checked) bubbleMatched=checkBubble(x-1,y+1) } if (x>0) { if (bubbleTable[x-1][y].bubbleNum==bubbleNum) if (!bubbleTable[x-1][y].checked) bubbleMatched=checkBubble(x-1,y) } if (x>0 && y>0) { if (bubbleTable[x-1][y-1].bubbleNum==bubbleNum) if (!bubbleTable[x-1][y-1].checked) bubbleMatched=checkBubble(x-1,y-1) } } else { if (y>0) { if (bubbleTable[x+1][y-1].bubbleNum==bubbleNum) if (!bubbleTable[x+1][y-1].checked) bubbleMatched=checkBubble(x+1,y-1) } if (x<(bubbleTableSize-2)) { if (bubbleTable[x+1][y].bubbleNum==bubbleNum) if (!bubbleTable[x+1][y].checked) bubbleMatched=checkBubble(x+1,y) } if (y<(bubbleTableSize-1)) { if (bubbleTable[x+1][y+1].bubbleNum==bubbleNum) if (!bubbleTable[x+1][y+1].checked) bubbleMatched=checkBubble(x+1,y+1) } if (y<(bubbleTableSize-1)) { if (bubbleTable[x][y+1].bubbleNum==bubbleNum) if (!bubbleTable[x][y+1].checked) bubbleMatched=checkBubble(x,y+1) } if (x>0) { if (bubbleTable[x-1][y].bubbleNum==bubbleNum) if (!bubbleTable[x-1][y].checked) bubbleMatched=checkBubble(x-1,y) } if (y>0) { if (bubbleTable[x][y-1].bubbleNum==bubbleNum) if (!bubbleTable[x][y-1].checked) bubbleMatched=checkBubble(x,y-1) } } bubbleTrain--; if (bubbleChecked>=3 && bubbleTrain==0) return true else return false; } function placeBubble(bubbleLayerNum,bubbleNumber,x,y) { var bubbleLayerID=getLayerID(bubbleLayerNum); moveLayerTo(bubbleLayerID,bubbleTable[x][y].x+baseX-bubbleRadiusSmall,bubbleTable[x][y].y+baseY-bubbleRadiusSmall); bubbleTable[x][y].bubbleNum=bubbleNumber; bubbleTable[x][y].layerNum=bubbleLayerNum; bubbleCount++; } function newBubble(bubbleNumber) { var layerNum=getBubble(); var layerID=getLayerID(layerNum); drawLayer(layerID,bubbleTag1+bubbleImage[bubbleNumber].src+bubbleTag2); return layerNum; } function addBubble(bubbleNumber,x,y) { placeBubble(newBubble(bubbleNumber),bubbleNumber,x,y); } function markBubble() { var bubbleMatched=false; var bubbleMulti1=0,bubbleMulti2=0; placeBubble(bubbleIDNum,bubbleNum,lastDimX,lastDimY); if (lastDimY==bubbleTableSize) gameOver() else { clearCheck(); if (bubbleNum==bubbleHammer) { bubbleMatched=true; bubbleTable[lastDimX][lastDimY].checked=true; if (hitBubble) bubbleTable[touchedX][touchedY].checked=true; setTimeout("clearBubble()",150); } else { if (bubbleNum==bubbleMulti) { bubbleMulti1=0; bubbleMulti2=bubbleNormal-1; } else { bubbleMulti1=bubbleNum; bubbleMulti2=bubbleNum; } for (var i=bubbleMulti1; i<=bubbleMulti2; i++) { setMulti(i); if (checkBubble(lastDimX,lastDimY)) { bubbleMatched=true; markMulti(); } else clearMulti(i); } restoreMulti(); if (bubbleMatched) setTimeout("clearBubble()",150); } if (!bubbleMatched) nextBubble(); } } function getHit() { var hitSideDistance=-1; var hitTopDistance=Math.round((bubbleY-(baseY+bubbleRadiusSmall))/bubbleUnitY); var hitBubbleDistance=getTouched(); var hitDistance=-1; if (bubbleStepX != 0) { if (bubbleStepX>0) hitSideDistance=Math.round((borderRight-bubbleRadiusSmall-bubbleX)/bubbleUnitX) else hitSideDistance=Math.round((borderLeft+bubbleRadiusSmall-bubbleX)/bubbleUnitX); } hitSide=false; hitTop=true; hitBubble=false; hitDistance=hitTopDistance; if (hitDistance>hitBubbleDistance && hitBubbleDistance>=0) { hitSide=false; hitTop=false; hitBubble=true; hitDistance=hitBubbleDistance; } if (hitDistance>hitSideDistance && hitSideDistance>=0) { hitSide=true; hitTop=false; hitBubble=false; hitDistance=hitSideDistance; } touchingX=bubbleX+hitDistance*bubbleUnitX; touchingY=bubbleY-hitDistance*bubbleUnitY; } function getTouched() { var thisDimY=0; var touchFound=false; var touchLineCount=0; var pathDistance=0; var pointLength=0; var pointX=0,pointY=0; var thePointLength=-1; var thePointX=0,thePointY=0; var bubbleLineSize=0; thisDimY=Math.floor((bubbleY-(baseY+2))/bubbleDistance)+1; if (thisDimY>=bubbleTableSize) thisDimY=bubbleTableSize-1; for (var i=thisDimY; i>=0; i--) { bubbleLineSize=(i%2==0)?bubbleTableSize:(bubbleTableSize-1); for (var j=0; j=0) { pointX=bubbleTable[j][i].x-(bubbleX-baseX); pointY=(bubbleY-baseY)-bubbleTable[j][i].y; with(Math) { pathDistance=floor(abs(pointX*bubbleUnitY-pointY*bubbleUnitX)); pointLength=round(abs(pointX*bubbleUnitX+pointY*bubbleUnitY)); if (pathDistance(pointLength-deltaLength[pathDistance])) { thePointX=j; thePointY=i; thePointLength=pointLength-deltaLength[pathDistance]; } } } } } if (touchFound) { if (++touchLineCount>2) break; } } if (touchFound) { touchedX=thePointX; touchedY=thePointY; } return thePointLength; } function moveBubble() { if ((bubbleY-touchingY)<0.1 ) { if (hitSide) { bubbleStepX=-bubbleStepX; bubbleUnitX=-bubbleUnitX; bubbleBounce++; getHit(); setTimeout("moveBubble()",48); return; } else { lastDimY=Math.floor((bubbleY-(baseY+2))/bubbleDistance); if (lastDimY<0) lastDimY=0; if (lastDimY%2==0) { lastDimX=Math.floor((bubbleX-baseX)/(bubbleSize+1)) if (lastDimX<0) lastDimX=0; if (lastDimX>=bubbleTableSize-1) lastDimX=bubbleTableSize-1; } else { lastDimX=Math.floor((bubbleX-baseX-bubbleRadiusLarge)/(bubbleSize+1)); if (lastDimX<0) lastDimX=0; if (lastDimX>=bubbleTableSize-2) lastDimX=bubbleTableSize-2; } setTimeout("markBubble()",100); return; } } else if (bubbleY-bubbleStepY= borderRight-gunMargin) gunMoveDirection=-gunMoveDirection; if (gunDirection !=0) { gunAngle+=gunDirection; if (gunAngle>gunAngleEnd || gunAngleborderRight-pointRadius) pointX=borderRight*2-pointX; if (pointXgunPointEnd) gunPoint[i]=gunPointBegin; } newDotX1=gunPointBegin*(-gunAngles[gunAngle].y); newDotY1=gunPointBegin*(gunAngles[gunAngle].x); newDotX2=gunPointBegin*(gunAngles[gunAngle].y); newDotY2=gunPointBegin*(-gunAngles[gunAngle].x); moveLayerTo("dot1",gunX+newDotX1-dotRadius+gunLevelOffset,gunY-newDotY1-dotRadius); moveLayerTo("dot2",gunX+newDotX2-dotRadius+gunLevelOffset,gunY-newDotY2-dotRadius); gunTimer=setTimeout("bubbleGun()",10); } function armGun(e) { var keyCode=0 ; if (isIE4) keyCode=event.keyCode else keyCode=e.which; if (keyCode==76 || keyCode==108 || keyCode==39) gunDirection=-1; if (keyCode==74 || keyCode==106 || keyCode==37) gunDirection=1; if (keyCode==75 || keyCode==107 || keyCode==38) fireBubble(); return false; } function holdGun(e) { var keyCode=0; if (isIE4) keyCode=event.keyCode else keyCode=e.which; if (keyCode==76 || keyCode==108 || keyCode==39) if (gunDirection==-1) gunDirection=0; if (keyCode==74 || keyCode==106 || keyCode==37) if (gunDirection==1) gunDirection=0; return false; } function eventInit() { document.onkeydown=armGun; document.onkeyup=holdGun; window.onresize=reSizing; } function eventRelease() { document.onkeydown=null; document.onkeyup=null; window.onresize=null; } function buildNumber() { var numberMax=scoreSize*4; var layerHTML=""; var layerID=""; var htmlString=numberTag1+numbers[0].src+numberTag2; for (var i=0; i'+htmlString+''; document.body.insertAdjacentHTML("BeforeEnd",layerHTML); } } else { for (var i=0; i0) { if (isIE4) { numberInClip="rect("+(numberOffset-1)+"px "+numberWidth+"px "+numberHeight+"px 0px)"; numberOutClip="rect(0px "+numberWidth+"px "+(numberOffset-1)+"px 0px)"; document.all[numberIn].style.clip=numberInClip; document.all[numberOut].style.clip=numberOutClip; document.all[numberIn].style.pixelTop++; document.all[numberOut].style.pixelTop++; } else { document.layers[numberIn].clip.top--; document.layers[numberIn].top++; document.layers[numberOut].clip.bottom--; document.layers[numberOut].top++; } eval('setTimeout("showNumber('+singleQuote+numberIn+singleQuote+','+singleQuote+numberOut+singleQuote+')",1)'); } else numberCount--; } function scoreNumber(scoreType) { var thisScore=(scoreType==gameScoreNumber) ? gameScore : highScore; for (var i=0; i=3) bubblePoints=3+(bubbleCut-3)*2+bubbleBounce*5 else bubblePoints=bubbleCut+bubbleBounce*5; gameScore+=bubblePoints; roundScore(gameScoreNumber); return bubbleDone; } function showLevel() { var bubbleNumber=0,bubbleIndex=0,bubbleLineSize=0,bubbleDone=false; if (bubbleDropFinished) { bubbleFeeding=0; bubbleFeedingMax=bubbleFeedings[bubbleLevel].length; gunAngleBegin=bubbleControls[bubbleLevel][3]/gunAngleStep; gunAngleEnd=bubbleControls[bubbleLevel][4]/gunAngleStep; gunLevelOffset=gunOffset[bubbleControls[bubbleLevel][1]]; bubbleLevelStarted=false; for (var i=0; i=0) addBubble(bubbleNumber,j,i); } } } centralizeGun(); nextBubble(); bubbleGun(); eventInit(); } else setTimeout("showLevel()",150); }