home *** CD-ROM | disk | FTP | other *** search
- function Pop()
- {
- }
- function resetStats()
- {
- numpoppable = numpopped = nummanic = 0;
- }
- function setBubbleSize(newsize)
- {
- bubblesize = newsize;
- btnBSButton.instance5.gotoAndPlay(1);
- }
- function removeBubbles()
- {
- for(bubble in sheet)
- {
- if(typeof sheet[bubble] == "movieclip")
- {
- sheet[bubble].removeMovieClip();
- }
- }
- }
- function makeBubbles()
- {
- if(bubblesmade != bubblesize)
- {
- removeBubbles();
- resetStats();
- xPitch = bubblesize + 0.06451612903225806 * bubblesize;
- yPitch = bubblesize - 0.06896551724137931 * bubblesize;
- bubbleCols = Math.round(sheet._width / xPitch) + 1;
- bubbleRows = Math.round(sheet._height / yPitch) + 1;
- var col = 0;
- while(col < bubbleCols)
- {
- var row = 0;
- while(row < bubbleRows)
- {
- var x = col * xPitch + startx;
- if(row % 2 != 0)
- {
- x += xPitch / 2;
- }
- var y = row * yPitch + starty;
- sheet.attachMovie("Pop","pr" + row + "c" + col,bubbleCols * row + col,{_x:x,_y:y,_xscale:100 * (bubblesize / 31),_yscale:100 * (bubblesize / 31),r:row,c:col});
- newBubble = sheet["pr" + row + "c" + col];
- var bounds = newBubble.getBounds(_root);
- if(bounds.xMax > sheetmask._width || bounds.xMin < 0 || bounds.yMax > sheetmask._height || bounds.yMin < 0)
- {
- newBubble.poppable = false;
- }
- row++;
- }
- col++;
- }
- bubblesmade = bubblesize;
- }
- else
- {
- resetSheet();
- }
- }
- function enableSheet(enable)
- {
- if(enable)
- {
- onpress = Pop.prototype.onPress;
- }
- else
- {
- onpress = null;
- }
- var col = 0;
- while(col < bubbleCols)
- {
- var row = 0;
- while(row < bubbleRows)
- {
- sheet["pr" + row + "c" + col].onPress = onpress;
- sheet["pr" + row + "c" + col].useHandCursor = enable;
- row++;
- }
- col++;
- }
- }
- function resetSheet()
- {
- resetStats();
- for(bubble in sheet)
- {
- if(typeof sheet[bubble] == "movieclip")
- {
- sheet[bubble].onLoad();
- }
- }
- }
- function restartTimer()
- {
- minutes = "00";
- seconds = "00";
- tenths = "0";
- buttonPressTime = getTimer() / 1000 - pauseLength;
- pause();
- }
- function pause()
- {
- pauseTime = getTimer() / 1000;
- timing = false;
- txtMin.setTextFormat(timerOff);
- txtColon.setTextFormat(timerOff);
- txtSec.setTextFormat(timerOff);
- txtDot.setTextFormat(timerOff);
- txtTen.setTextFormat(timerOff);
- }
- function unpause()
- {
- unpauseTime = getTimer() / 1000;
- pauseLength = unpauseTime - pauseTime + pauseLength;
- timing = true;
- txtMin.setNewTextFormat(timerOn);
- txtColon.setNewTextFormat(timerOn);
- txtSec.setNewTextFormat(timerOn);
- txtDot.setNewTextFormat(timerOn);
- txtTen.setNewTextFormat(timerOn);
- txtMin.setTextFormat(timerOn);
- txtColon.setTextFormat(timerOn);
- txtSec.setTextFormat(timerOn);
- txtDot.setTextFormat(timerOn);
- txtTen.setTextFormat(timerOn);
- }
- Math.randomBetween = function(a, b)
- {
- return a + Math.floor(Math.random() * (b - a + 1));
- };
- Pop.prototype = new MovieClip();
- Pop.prototype.onLoad = function()
- {
- if(this.poppable)
- {
- if(Math.randomBetween(1,250) == 1)
- {
- buddycase = Math.randomBetween(1,3);
- switch(buddycase)
- {
- case 1:
- buddyc = this.c - 1;
- buddyr = this.r;
- break;
- case 2:
- buddyc = this.c;
- buddyr = this.r - 1;
- if(this.r % 2 == 0)
- {
- buddyc--;
- }
- break;
- case 3:
- buddyc = this.c + 1;
- buddyr = this.r - 1;
- if(this.r % 2 == 0)
- {
- buddyc--;
- break;
- }
- }
- if(sheet["pr" + buddyr + "c" + buddyc].poppable)
- {
- this.buddy = "pr" + buddyr + "c" + buddyc;
- sheet["pr" + buddyr + "c" + buddyc].buddy = "pr" + this.r + "c" + this.c;
- }
- }
- else
- {
- this.buddy = null;
- }
- this.gotoAndStop(Math.randombetween(1,6));
- numpoppable++;
- }
- else
- {
- this.gotoAndStop(Math.randombetween(10,15));
- }
- };
- Pop.prototype.onPress = function(manic)
- {
- if(this._currentframe < 10)
- {
- this.gotoAndStop(Math.randomBetween(10,15));
- specialrandom = Math.randomBetween(1,2000);
- if(this.buddy != null && !Key.isDown(66) && sheet[this.buddy]._currentFrame >= 10)
- {
- sheet[this.buddy].gotoAndStop(Math.randomBetween(1,6));
- buddysound.start();
- numpopped--;
- if(manic)
- {
- nummanic--;
- }
- }
- else if(specialrandom < 5 && !manic)
- {
- specialsound[specialrandom].start();
- }
- else if(specialrandom == 5)
- {
- fartx = this._x;
- farty = this._y;
- fartinst = "inst" + fartx + farty;
- sheet.attachMovie("fart",fartinst,numpoppable * 2,{_x:fartx,_y:farty});
- }
- else
- {
- popsound[Math.randomBetween(1,9)].start();
- }
- numpopped++;
- if(numpopped == 1)
- {
- unpause();
- }
- if(manic)
- {
- nummanic++;
- }
- if(numpopped == numpoppable)
- {
- pause();
- _root.play();
- }
- }
- };
- Pop.prototype.onRollOver = function()
- {
- if(Key.isDown(16) || chkManic.getValue())
- {
- this.onPress(true);
- }
- };
- Pop.prototype.poppable = true;
- Pop.prototype.buddy = null;
- Pop.prototype.r = Pop.prototype.c = 0;
- Object.registerClass("Pop",Pop);
- var startx = 2;
- var starty = 2;
- timerOn = new TextFormat();
- timerOff = new TextFormat();
- timerOn.color = 34816;
- timerOff.color = 16711680;
- _root.onLoad = function()
- {
- presetsmall = 20;
- presetmedium = 31;
- presetlarge = 49;
- setBubbleSize(presetmedium);
- makeBubbles();
- };
- popsound = new Array();
- var n = 1;
- while(n < 10)
- {
- popsound[n] = new Sound();
- popsound[n].attachSound("bw-pop" + n);
- n++;
- }
- specialsound = new Array();
- var n = 1;
- while(n < 5)
- {
- specialsound[n] = new Sound();
- n++;
- }
- specialsound[1].attachSound("aroogalong");
- specialsound[2].attachSound("flush3");
- specialsound[3].attachSound("splash");
- specialsound[4].attachSound("splat");
- buddysound = new Sound();
- buddysound.attachSound("buddyswap");
- _root.onEnterFrame = function()
- {
- totalTime = getTimer() / 1000 - pauseLength;
- goTime = totalTime - buttonPressTime;
- if(timing)
- {
- hours = Math.floor(goTime / 3600);
- minutes = Math.floor((goTime / 3600 - hours) * 60);
- seconds = Math.floor(((goTime / 3600 - hours) * 60 - minutes) * 60);
- tenths = Math.floor((gotime - (seconds + minutes * 60 + hours * 3600)) * 10);
- minutes += hours * 60;
- if(seconds < 10)
- {
- seconds = "0" + seconds;
- }
- if(minutes < 10)
- {
- minutes = "0" + minutes;
- }
- if(minutes == "99")
- {
- if(seconds == "59")
- {
- if(tenths = "9")
- {
- pause();
- _root.play();
- }
- }
- }
- }
- };
- stop();
-