Frame 1
stop();
_global.points = new ScoreKeeper();
_global.musicPlayer = new Music();
_global.soundOn = true;
Instance of Symbol 26 MovieClip in Frame 1
onClipEvent (load) {
myFlag = 0;
Counter = -1;
totalFileSize = _root.getBytesTotal();
startBytes = _root.getBytesLoaded();
}
onClipEvent (enterFrame) {
if (Counter == -1) {
bytesLoaded = _root.getBytesLoaded();
amountLoaded = bytesLoaded / totalFileSize;
percentLoaded = int(100 * amountLoaded);
_root.loadingText = percentLoaded + " %";
_root.loader.loaderInside._xscale = percentLoaded;
if ((amountLoaded >= 1) && (myFlag == 0)) {
myFlag = 1;
Counter = 20;
}
} else if (Counter == 0) {
_root.gotoAndPlay(5);
} else {
Counter--;
}
}
Frame 2
stop();
Instance of Symbol 26 MovieClip in Frame 2
onClipEvent (load) {
_global.musicPlayer.SetTrack("title");
_global.musicPlayer.PlayWithCrossFade(2);
if (_global.soundOn == true) {
_root.soundButton.gotoAndStop("off");
} else {
_root.soundButton.gotoAndStop("on");
}
_global.points.Reset();
}
onClipEvent (enterFrame) {
if (_global.soundOn == true) {
_global.musicPlayer.RunPlayer();
}
}
Frame 3
function setup() {
blnIdle = false;
nextRock = 2;
nextRockCounter = 40;
nextRockMin = 10;
nextRockMax = 40;
rockSpeed = -7;
rockSize = 0;
rockMoveY = 0;
nextStarCounter = 100;
starSpeed = -5;
blnShipDestroyed = false;
endGameCounter = -1;
pointMultiplier = 1;
_root.outputMultiplier = "x1";
_root.pointText.textColor = 16777011 /* 0xFFFF33 */;
starsInARow = 0;
totalStars = 0;
_global.points.SetIncrement(25);
}
function setDestinationAndMove() {
if (blnShipDestroyed == false) {
targetX = _root._xmouse;
targetY = _root._ymouse;
var _local3 = targetX - _root.ship._x;
var _local2 = targetY - _root.ship._y;
speedX = _local3 / 2;
speedY = _local2 / 2;
_root.ship._x = _root.ship._x + speedX;
_root.ship._y = _root.ship._y + speedY;
angleRadians = Math.atan2(_local2, _local3);
angleDegrees = (360 * angleRadians) / (Math.PI*2);
_root.ship.thrusterFront._rotation = angleDegrees;
_root.ship.thrusterBack._rotation = angleDegrees;
combinedSpeed = Math.abs(speedX + speedY);
if (combinedSpeed < 2) {
if (blnIdle == false) {
_root.ship.gotoAndPlay("idle");
blnIdle = true;
}
} else if (blnIdle == true) {
_root.ship.gotoAndPlay("flying");
blnIdle = false;
}
if (combinedSpeed < 2) {
_root.ship.thrusterFront.gotoAndPlay("stop");
_root.ship.thrusterBack.gotoAndPlay("stop");
} else if ((combinedSpeed > 19) && (speedX > 0)) {
_root.ship.thrusterFront.gotoAndPlay("medium");
_root.ship.thrusterBack.gotoAndPlay("medium");
} else {
_root.ship.thrusterFront.gotoAndPlay("slow");
_root.ship.thrusterBack.gotoAndPlay("slow");
}
}
if (endGameCounter > 0) {
endGameCounter--;
}
if (endGameCounter == 0) {
clearScreenAndContinue();
}
}
function clearScreenAndContinue() {
var _local2 = 0;
while (_local2 < rocks.length) {
removeRock(_local2);
_local2--;
_local2++;
}
_local2 = 0;
while (_local2 < stars.length) {
removeStar(_local2);
_local2--;
_local2++;
}
_root.gotoAndPlay("score");
}
function adjustDifficulty() {
nextRockMax = nextRockMax - 4;
starSpeed = starSpeed - 0.75;
if (nextRockMax <= 8) {
nextRockMax = 8;
}
if (totalStars == 90) {
nextRockMin = 8;
}
if (totalStars == 135) {
nextRockMin = 6;
}
if (totalStars == 150) {
nextRockMin = 3;
}
rockSpeed = rockSpeed - 0.75;
if (totalStars >= 30) {
rockSize = rockSize + 4;
if (rockSize > 85) {
rockSize = 85;
}
}
if (totalStars >= 60) {
rockMoveY = rockMoveY + 0.2;
if (rockMoveY > 6) {
rockMoveY = 6;
}
}
}
function moveRocks() {
var _local2 = 0;
while (_local2 < rocks.length) {
rocks[_local2].Move();
if (rocks[_local2].isOffScreen() == true) {
removeRock(_local2);
_local2--;
}
_local2++;
}
_local2 = 0;
while (_local2 < rocks.length) {
if (blnShipDestroyed == false) {
if (collisionDetection("ship", rocks[_local2].getID(), 0) == true) {
blnShipDestroyed = true;
endGameCounter = 60;
_root.ship.gotoAndPlay("explode");
}
}
_local2++;
}
}
function moveStars() {
var _local3 = 0;
while (_local3 < stars.length) {
stars[_local3].Move();
if (stars[_local3].isOffScreen() == true) {
removeStar(_local3);
_local3--;
pointMultiplier = 1;
_root.outputMultiplier = "x1";
_global.points.SetIncrement(25);
starsInARow = 0;
_root.pointText.textColor = 16777011 /* 0xFFFF33 */;
}
_local3++;
}
if (blnShipDestroyed == false) {
_local3 = 0;
while (_local3 < stars.length) {
if (collisionDetection("ship", stars[_local3].getID(), 3) == true) {
var _local4 = stars[_local3].getID();
if (_local4.charAt(0) == "b") {
_global.points.AddPoints(1500 * pointMultiplier);
} else {
_global.points.AddPoints(150 * pointMultiplier);
}
removeStar(_local3);
_local3--;
starsInARow++;
totalStars++;
starCounter++;
if (starCounter >= 15) {
starCounter = 0;
adjustDifficulty();
}
if (starsInARow > 50) {
pointMultiplier = 4;
_root.outputMultiplier = "x4";
_global.points.SetIncrement(100);
_root.pointText.textColor = 16724889 /* 0xFF3399 */;
} else if (starsInARow > 25) {
pointMultiplier = 3;
_global.points.SetIncrement(75);
_root.outputMultiplier = "x3";
_root.pointText.textColor = 16724736 /* 0xFF3300 */;
} else if (starsInARow > 10) {
pointMultiplier = 2;
_global.points.SetIncrement(50);
_root.outputMultiplier = "x2";
_root.pointText.textColor = 16750848 /* 0xFF9900 */;
}
}
_local3++;
}
}
}
function collisionDetection(clip1, clip2, modifier) {
var _local7 = _root[clip1]._x;
var _local6 = _root[clip1]._y;
var _local10 = _root[clip2]._x;
var _local8 = _root[clip2]._y;
var _local4 = (_root[clip2]._width / 2) + modifier;
var _local3 = _local10 - _local7;
var _local2 = _local8 - _local6;
var _local5 = Math.sqrt((_local3 * _local3) + (_local2 * _local2));
if (_local5 <= _local4) {
return(true);
}
return(false);
}
function removeRock(index) {
_root[rocks[index].getID()].removeMovieClip();
delete rocks[index];
rocks.splice(index, 1);
}
function removeStar(index) {
_root[stars[index].getID()].removeMovieClip();
delete stars[index];
stars.splice(index, 1);
}
function starGenerator() {
nextStarCounter--;
if (nextStarCounter < 1) {
addStar();
nextStarCounter = 10;
}
}
function rockGenerator() {
nextRockCounter--;
if (nextRockCounter < 1) {
addRock();
nextRockCounter = Math.round(Math.random() * (nextRockMax - nextRockMin)) + nextRockMin;
}
}
function addStar() {
var _local2;
if (Math.round(Math.random() * 100) > 97) {
_local2 = "bonusBall";
starID = "bonus" + nextRock;
} else {
_local2 = "pointBall";
starID = "star" + nextRock;
}
nextRock++;
var _local4 = Math.round(Math.random() * 250) + 25;
_root.attachMovie(_local2, starID, nextRock);
_root[starID]._x = 750;
_root[starID]._y = _local4;
var _local3 = new MovingObject(starID, starSpeed, 0, 0);
stars.push(_local3);
}
function addRock() {
rockID = "rock" + nextRock;
nextRock++;
var _local8 = Math.round(Math.random() * 2);
var _local2;
switch (_local8) {
case 0 :
_local2 = "rock 1";
break;
case 1 :
_local2 = "rock 2";
break;
case 2 :
_local2 = "rock 3";
break;
default :
_local2 = "rock 1";
}
var _local6 = Math.round(Math.random() * 250) + 25;
var _local3 = Math.round(Math.random() * (rockSize * 2)) - rockSize;
var _local7 = (Math.random() * (rockMoveY * 2)) - rockMoveY;
_root.attachMovie(_local2, rockID, nextRock);
_root[rockID]._x = 750;
_root[rockID]._y = _local6;
_root[rockID]._xscale = 100 + _local3;
_root[rockID]._yscale = 100 + _local3;
var _local4 = Math.round(Math.random() * 6) + -3;
var _local5 = new MovingObject(rockID, rockSpeed, _local7, _local4);
rocks.push(_local5);
}
stop();
var targetX;
var targetY;
var speedX;
var speedY;
var blnIdle;
var rocks = new Array();
var nextRock;
var stars = new Array();
var nextRockCounter;
var nextRockMin;
var nextRockMax;
var rockSpeed;
var rockSize;
var rockMoveY;
var nextStarCounter;
var starSpeed;
var lastStarY;
var blnShipDestroyed;
var endGameCounter;
var pointMultiplier;
var starsInARow;
var totalStars;
var starCounter;
Instance of Symbol 26 MovieClip in Frame 3
onClipEvent (load) {
_root.setup();
_global.musicPlayer.SetTrack("music");
_global.musicPlayer.PlayWithCrossFade(2);
}
onClipEvent (enterFrame) {
_root.setDestinationAndMove();
_root.moveRocks();
_root.moveStars();
_root.rockGenerator();
_root.starGenerator();
_global.points.Run();
if (_global.soundOn == true) {
_global.musicPlayer.RunPlayer();
}
_root.outputScore = _global.points.GetDisplayScore();
}
Frame 4
function setVars() {
saver.Code("266593765-832475015-287625234-283728642-216319992-124659883");
saver.GameID(223);
}
function doSave(name) {
setVars();
saver.SendScores(name, _global.points.GetScore());
_root.gotoAndPlay("Main");
}
function doBagunk() {
setVars();
saver.UserLogin(_global.points.GetScore());
_root.gotoAndPlay("Main");
}
stop();
var saver = new BagunkScores();
Instance of Symbol 26 MovieClip in Frame 4
onClipEvent (load) {
_root.finalScore = _global.points.GetScore();
_global.musicPlayer.SetTrack("title");
_global.musicPlayer.PlayWithCrossFade(2);
}
onClipEvent (enterFrame) {
if (_global.soundOn == true) {
_global.musicPlayer.RunPlayer();
}
}
Frame 6
gotoAndPlay ("main");
Frame 7
stop();
Instance of Symbol 26 MovieClip in Frame 7
onClipEvent (load) {
_global.musicPlayer.SetTrack("title");
_global.musicPlayer.PlayWithCrossFade(2);
}
onClipEvent (enterFrame) {
if (_global.soundOn == true) {
_global.musicPlayer.RunPlayer();
}
}
Symbol 116 MovieClip [__Packages.ScoreKeeper] Frame 0
class ScoreKeeper
{
var increment, currentScore, displayScore;
function ScoreKeeper () {
increment = 1;
currentScore = 0;
displayScore = 0;
}
function SetIncrement(inc) {
increment = inc;
}
function AddPoints(inc) {
currentScore = currentScore + inc;
}
function Run() {
if (currentScore != displayScore) {
displayScore = displayScore + increment;
if (displayScore > currentScore) {
displayScore = currentScore;
}
}
}
function GetDisplayScore() {
return(displayScore);
}
function GetScore() {
return(currentScore);
}
function Reset() {
currentScore = 0;
displayScore = 0;
}
}
Symbol 117 MovieClip [__Packages.Music] Frame 0
class Music
{
var mySound, volume, currentTrack, inCrossfade, state, changeSongs, targetVolume, volumeSpeed;
function Music () {
mySound = new Sound();
volume = 100;
currentTrack = "";
inCrossfade = false;
state = false;
changeSongs = true;
}
function SetTrack(setMusic) {
if (setMusic == currentTrack) {
changeSongs = false;
} else {
changeSongs = true;
currentTrack = setMusic;
}
}
function Play() {
mySound.stop();
mySound.attachSound(currentTrack);
volume = 100;
mySound.setVolume(volume);
mySound.start(0, 2000);
state = true;
}
function Stop() {
mySound.stop();
state = false;
}
function PlayWithCrossFade(secondDuration) {
if (changeSongs == true) {
if (state == true) {
inCrossfade = true;
targetVolume = 0;
var _local2 = secondDuration * 30;
volumeSpeed = (targetVolume - volume) / (_local2 / 2);
} else {
mySound.stop();
mySound.attachSound(currentTrack);
mySound.start(0, 2000);
state = true;
inCrossfade = false;
targetVolume = 100;
volume = 0;
mySound.setVolume(0);
var _local2 = secondDuration * 30;
volumeSpeed = (targetVolume - volume) / _local2;
}
}
}
function RunPlayer() {
if (targetVolume != volume) {
var _local2;
_local2 = volume + volumeSpeed;
if ((volumeSpeed < 0) && (_local2 < 0)) {
_local2 = 0;
} else if ((volumeSpeed > 0) && (_local2 > targetVolume)) {
_local2 = targetVolume;
}
volume = _local2;
mySound.setVolume(_local2);
}
if (inCrossfade == true) {
if (volume <= 0) {
volumeSpeed = volumeSpeed * -1;
inCrossfade = false;
targetVolume = 100;
mySound.stop();
mySound.attachSound(currentTrack);
mySound.setVolume(0);
mySound.start(0, 2000);
state = true;
}
}
}
}
Symbol 118 MovieClip [__Packages.MovingObject] Frame 0
class MovingObject
{
var objectID, xSpeed, ySpeed, rotationSpeed, onScreenOnce;
function MovingObject (id, x, y, rotation) {
objectID = id;
xSpeed = x;
ySpeed = y;
rotationSpeed = rotation;
onScreenOnce = false;
}
function isOffScreen() {
var _local3 = false;
var _local6 = _root[objectID]._y - (_root[objectID]._height / 2);
var _local4 = _root[objectID]._y + (_root[objectID]._height / 2);
var _local5 = _root[objectID]._x + (_root[objectID]._width / 2);
var _local7 = _root[objectID]._x - (_root[objectID]._width / 2);
if (_local6 > _root._height) {
_local3 = true;
} else if (_local4 < 0) {
_local3 = true;
} else if (_local5 < 0) {
_local3 = true;
} else if (_local7 > _root._width) {
_local3 = true;
}
if (_local3 == false) {
onScreenOnce = true;
}
if ((onScreenOnce == true) && (_local3 == true)) {
return(true);
}
return(false);
}
function getID() {
return(objectID);
}
function Move() {
_root[objectID]._x = _root[objectID]._x + xSpeed;
_root[objectID]._y = _root[objectID]._y + ySpeed;
_root[objectID]._rotation = _root[objectID]._rotation + rotationSpeed;
}
}
Symbol 119 MovieClip [__Packages.BagunkScores] Frame 0
class BagunkScores
{
var filePath, loadVarObject, gameID, connectionPassword;
function BagunkScores () {
filePath = "http://www.bagunk.com/receiveScores.php";
loadVarObject = new LoadVars();
}
function GameID(id) {
gameID = id;
}
function Code(passwordString) {
connectionPassword = passwordString;
}
function SendScores(username, score) {
loadVarObject.name = username;
loadVarObject.score = score;
loadVarObject.gameID = gameID;
loadVarObject.code = connectionPassword;
loadVarObject.pageMode = 1;
loadVarObject.send(filePath, "_blank", "POST");
}
function UserLogin(score) {
loadVarObject.code = connectionPassword;
loadVarObject.gameID = gameID;
loadVarObject.score = score;
loadVarObject.pageMode = 2;
loadVarObject.send(filePath, "_blank", "POST");
}
}
Symbol 39 Button
on (release) {
_root.gotoAndPlay("game");
}
Symbol 42 Button
on (release) {
getURL ("http://www.bagunk.com/scores.php?profile=223");
}
Symbol 45 Button
on (release) {
gotoAndPlay ("credits");
}
Symbol 48 Button
on (release) {
gotoAndPlay ("on");
_global.soundOn = false;
_global.musicPlayer.Stop();
}
Symbol 51 Button
on (release) {
gotoAndPlay ("off");
_global.soundOn = true;
_global.musicPlayer.SetTrack("title");
_global.musicPlayer.Play();
}
Symbol 52 MovieClip Frame 1
stop();
Symbol 52 MovieClip Frame 2
stop();
Symbol 60 MovieClip Frame 1
stop();
Symbol 60 MovieClip Frame 2
stop();
Symbol 60 MovieClip Frame 3
stop();
Symbol 84 MovieClip Frame 15
stop();
Symbol 85 MovieClip Frame 1
stop();
Symbol 85 MovieClip Frame 26
gotoAndPlay ("idle");
Symbol 85 MovieClip Frame 51
stop();
Symbol 95 MovieClip Frame 66
stop();
Symbol 100 Button
on (release) {
_root.gotoAndPlay("main");
}
Symbol 104 Button
on (release) {
_root.doSave(yourScore.text);
}
Symbol 108 Button
on (release) {
_root.doBagunk();
}
Symbol 113 Button
on (release) {
gotoAndPlay ("main");
}