Frame 1
MochiAd.showPreGameAd({id:"2894a867d85d188f", res:"550x400"});
Frame 2
cryingSoul = new Sound(_root);
cryingSoul.attachSound("BGKICK");
roseAtDawn = new Sound(_root);
roseAtDawn.attachSound("rose");
fallIntoTheBlazingCold = new Sound(_root);
fallIntoTheBlazingCold.attachSound("fallIntoTheBlazingCold");
cryingSoul.start(0, 9999);
explosionS = new Sound(_root);
explosionS.attachSound("explosion");
bossexplosion = new Sound(_root);
bossexplosion.attachSound("bossexplosion");
hitS = new Sound(_root);
hitS.attachSound("hit");
thruster = new Sound(_root);
thruster.attachSound("thruster");
pickup = new Sound(_root);
pickup.attachSound("pickup");
winS = new Sound(_root);
winS.attachSound("pickup");
Frame 3
mute.onRelease = function () {
thruster.setVolume(0);
};
unMute.onRelease = function () {
thruster.setVolume(10);
};
medVolume.onRelease = function () {
thruster.setVolume(5);
};
Frame 81
Frame 84
level = 1;
playsounds = true;
playhit = false;
topHealth = 25;
topFlightJuice = 550;
regenerateRate = 0.75;
gravity = 0.1;
thrust = 0.5;
topspeed = 6;
done = false;
options = false;
faderbox.gotoAndStop("blue");
speed = 6;
type = "penguin";
guy = eval (type);
stop();
play.onRelease = function () {
if (codeinput == "hogwash") {
level = 2;
}
if (codeinput == "diesel") {
level = 3;
}
if (codeinput == "dwarfer") {
level = 4;
}
if (codeinput == "penguins") {
level = 5;
}
if (codeinput == "partridge") {
level = 6;
}
if (codeinput == "bearmeat") {
level = 7;
}
if (codeinput == "blondie") {
level = 8;
}
if (codeinput == "deathcab") {
level = 9;
}
if (codeinput == "stillalive") {
level = 10;
}
if (codeinput == "suicide") {
level = 11;
}
if (codeinput == "bonkers") {
level = 12;
}
if (codeinput == "lucky13") {
level = 13;
}
if (codeinput == "theboss") {
level = 14;
}
done = true;
options = false;
};
intro.onRelease = function () {
gotoAndPlay ("intro");
};
currentAlpha = 0;
play._alpha = currentAlpha;
bearB._alpha = currentAlpha;
penB._alpha = currentAlpha;
birdB._alpha = currentAlpha;
optionsB._alpha = currentAlpha;
intro._alpha = currentAlpha;
fadeIn = function () {
currentAlpha = currentAlpha + speed;
if (currentAlpha >= 100) {
currentAlpha = 100;
}
play._alpha = currentAlpha;
bearB._alpha = currentAlpha;
penB._alpha = currentAlpha;
birdB._alpha = currentAlpha;
optionsB._alpha = currentAlpha;
intro._alpha = currentAlpha;
};
fadeOut = function () {
currentAlpha = currentAlpha - speed;
if (currentAlpha <= 0) {
currentAlpha = 0;
if (options == true) {
gotoAndStop ("options");
} else {
gotoAndStop ("loading");
}
}
play._alpha = currentAlpha;
bearB._alpha = currentAlpha;
penB._alpha = currentAlpha;
birdB._alpha = currentAlpha;
optionsB._alpha = currentAlpha;
intro._alpha = currentAlpha;
};
guy.onEnterFrame = function () {
if (done == false) {
fadeIn();
} else {
fadeOut();
}
guy = eval (type);
guy.gotoX = _root._xmouse;
guy.gotoY = _root._ymouse;
char = penguin;
dx = char._x - char.gotoX;
dy = char._y - char.gotoY;
char._x = char._x - (dx / 5);
char._y = char._y - (dy / 5);
char = bird;
dx = char._x - char.gotoX;
dy = char._y - char.gotoY;
char._x = char._x - (dx / 5);
char._y = char._y - (dy / 5);
char = bear;
dx = char._x - char.gotoX;
dy = char._y - char.gotoY;
char._x = char._x - (dx / 5);
char._y = char._y - (dy / 5);
};
penB.onRelease = function () {
guy = eval (type);
guy.gotoX = Stage.width / 2;
guy.gotoY = Stage.height + 100;
type = "penguin";
guy = eval (type);
};
birdB.onRelease = function () {
guy = eval (type);
guy.gotoX = Stage.width / 2;
guy.gotoY = Stage.height + 100;
type = "bird";
guy = eval (type);
};
bearB.onRelease = function () {
guy = eval (type);
guy.gotoX = Stage.width / 2;
guy.gotoY = Stage.height + 100;
type = "bear";
guy = eval (type);
};
optionsB.onRelease = function () {
done = true;
options = true;
};
Frame 90
lands = 12;
total = 0;
rocks = 6;
objects = 5;
buttons = 3;
enemies = 8;
notputdown = -1;
health = topHealth;
healthMultiplier = 100 / health;
flightJuice = topFlightJuice;
flightMultiplier = 100 / flightJuice;
mouse.maxWidth = 62.1;
landWidth = 188;
onLandNum = 0;
globalX = 0;
globalY = 0;
win = false;
mousehitsbuttons = false;
topsmoke = 5;
smoke = 0;
thrustsoundpauser = 0;
totalforthruster = 4;
fadein = true;
loading = true;
stop();
mouse = eval (type);
mouse._x = startX._x;
mouse._y = startX._y;
startX._x = -100;
startX._y = -100;
mouse.dy = 0;
mouse.dx = 0;
mouse.oX = mouse._x;
mouse.oY = mouse._y;
explosion.oX = -10000;
explosion.oY = -10000;
leftbarrier.oX = leftbarrier._x;
leftbarrier.oY = leftbarrier._y;
rightbarrier.oX = rightbarrier._x;
rightbarrier.oY = rightbarrier._y;
topbarrier.oX = topbarrier._x;
topbarrier.oY = topbarrier._y;
bottombarrier.oX = bottombarrier._x;
bottombarrier.oY = bottombarrier._y;
end.oX = end._x;
end.oY = end._y;
enemy1.tower = false;
enemy2.tower = false;
enemy3.tower = false;
enemy4.tower = false;
enemy5.tower = true;
enemy6.tower = true;
enemy7.tower = true;
enemy8.tower = true;
i = 0;
while (i <= objects) {
currentObject = eval ("object" + i);
currentObject.oX = currentObject._x;
currentObject.oY = currentObject._y;
i++;
}
enemy1.gotoLeft = true;
i = 1;
while (i <= enemies) {
currentEnemy = eval ("enemy" + i);
currentEnemy.health = 8;
currentEnemy.speed = 2;
firstFlag = eval ("firstPatrolMarker" + i);
secondFlag = eval ("secondPatrolMarker" + i);
currentEnemy.patrolLength = secondFlag._x - firstFlag._x;
currentEnemy.patrolPoint = currentEnemy._x - firstFlag._x;
firstFlag._x = -100;
secondFlag._x = -100;
currentEnemy.damage = 1;
currentEnemy.oX = currentEnemy._x;
currentEnemy.oY = currentEnemy._y;
currentEnemy.dead = false;
currentEnemy.gotoLeft = true;
i++;
}
i = 0;
while (i <= enemies) {
currentEnemy = eval ("enemy" + i);
if (currentEnemy.tower == true) {
currentEnemy.counter = 0;
currentEnemy.counterLimit = 60;
currentEnemy.launchSpeed = 2;
currentEnemy.health = 20;
}
i++;
}
i = 0;
while (i <= buttons) {
currentButton = eval ("button" + i);
currentButton.pressed = false;
currentButton.oX = currentButton._x;
currentButton.oY = currentButton._y;
currentResponder = eval ("responder" + i);
currentResponder.oX = currentResponder._x;
currentResponder.oY = currentResponder._y;
currentResponder.fadeOut = false;
currentResponder.alpha = 100;
currentResponder.speed = 6;
i++;
}
i = 0;
while (i <= rocks) {
currentRock = eval ("rock" + i);
currentRock.oX = currentRock._x;
currentRock.oY = currentRock._y;
currentRock.dx = 0;
currentRock.dy = 0;
currentRock.originX = currentRock._x;
currentRock.originY = currentRock._y;
i++;
}
i = 0;
while (i <= lands) {
currentLand = eval ("land" + i);
currentLand.oX = currentLand._x;
currentLand.oY = currentLand._y;
i++;
}
mouse.onEnterFrame = function () {
if (fadein == true) {
fadeIn();
} else {
fadeOut();
}
mouse.dy = mouse.dy + gravity;
mouse._y = mouse._y + mouse.dy;
mouse._x = mouse._x + mouse.dx;
healthbar._xscale = health * healthMultiplier;
if (flightJuice > 0) {
flightbar._xscale = flightJuice * flightMultiplier;
}
if (health <= 0) {
fadein = false;
loading = false;
}
if (health < topHealth) {
health = health + (regenerateRate / 5);
}
if (flightJuice < topFlightJuice) {
flightJuice = flightJuice + regenerateRate;
}
dx = (Stage.width / 2) - mouse._x;
dy = (Stage.width / 2) - mouse._y;
dx = dx / 4;
dy = dy / 4;
if (mouse.dx > topspeed) {
mouse.dx = topspeed;
}
if (mouse.dx < (-topspeed)) {
mouse.dx = -topspeed;
}
if (mouse.dy > topspeed) {
mouse.dy = topspeed;
}
if (mouse.dy < (-topspeed)) {
mouse.dy = -topspeed;
}
globalX = globalX + dx;
globalY = globalY + dy;
i = 1;
while (i <= lands) {
currentLand = eval ("land" + i);
currentLand._x = currentLand.oX + globalX;
currentLand._y = currentLand.oY + globalY;
i++;
}
i = 1;
while (i <= rocks) {
currentRock = eval ("rock" + i);
currentRock._x = currentRock.oX + globalX;
currentRock._y = currentRock.oY + globalY;
i++;
}
i = 1;
while (i <= enemies) {
currentEnemy = eval ("enemy" + i);
currentEnemy._x = currentEnemy.oX + globalX;
currentEnemy._y = currentEnemy.oY + globalY;
if (currentEnemy.tower) {
currentBullet = eval ("bullet" + i);
currentBullet._x = currentBullet.oX + globalX;
currentBullet._y = currentBullet.oY + globalY;
}
i++;
}
explosion._x = explosion.oX + globalX;
explosion._y = explosion.oY + globalY;
i = 0;
while (i <= buttons) {
currentButton = eval ("button" + i);
currentResponder = eval ("responder" + i);
currentButton._x = currentButton.oX + globalX;
currentButton._y = currentButton.oY + globalY;
currentResponder._x = currentResponder.oX + globalX;
currentResponder._y = currentResponder.oY + globalY;
i++;
}
i = 0;
while (i <= objects) {
currentObject = eval ("object" + i);
currentObject._x = currentObject.oX + globalX;
currentObject._y = currentObject.oY + globalY;
i++;
}
leftbarrier._x = leftbarrier.oX + globalX;
leftbarrier._y = leftbarrier.oY + globalY;
rightbarrier._x = rightbarrier.oX + globalX;
rightbarrier._y = rightbarrier.oY + globalY;
topbarrier._x = topbarrier.oX + globalX;
topbarrier._y = topbarrier.oY + globalY;
bottombarrier._x = bottombarrier.oX + globalX;
bottombarrier._y = bottombarrier.oY + globalY;
end._x = end.oX + globalX;
end._y = end.oY + globalY;
mouse.oX = mouse.oX + dx;
mouse.oY = mouse.oY + dy;
mouse._y = mouse._y + dy;
mouse._x = mouse._x + dx;
bg._x = bg._x + (dx / 3);
bg._y = bg._y + (dy / 3);
if (notputdown != -1) {
currentRock = eval ("rock" + notputdown);
currentRock._x = mouse._x;
currentRock._y = mouse._y + 25;
currentRock.dx = mouse.dx;
currentRock.dy = mouse.dy;
}
onLand = false;
i = 1;
while (i <= lands) {
currentLand = eval ("land" + i);
if (mouse.hitTest(currentLand)) {
if (mouse._y < (currentLand._y + (mouse.dy * 1.2))) {
mouse.dy = 0;
mouse._y = currentLand._y;
onLand = true;
onLandNum = i;
} else if (mouse._y > (((currentLand._y + 35.5) + 25.4) + (mouse.dy * 1.2))) {
mouse.dy = mouse.dy * -1;
mouse._y = mouse._y + (mouse.dy * 1.5);
} else {
mouse.dx = mouse.dx * -1;
mouse._x = mouse._x + (mouse.dx * 2);
}
}
i++;
}
if (notputdown != -1) {
currentRock = eval ("rock" + notputdown);
i = 1;
while (i <= lands) {
currentLand = eval ("land" + i);
if (currentRock.hitTest(currentLand)) {
if (currentRock._y < (currentLand._y + (mouse.dy * 1.2))) {
mouse.dy = 0;
mouse._y = currentLand._y - 25;
onLand = true;
onLandNum = i;
} else if (currentRock._y > (((currentLand._y + 35) + 27) + (mouse.dy * 1.2))) {
mouse.dy = mouse.dy * -1;
mouse._y = mouse._y + (mouse.dy * 1.5);
} else {
mouse.dx = mouse.dx * -1;
mouse._x = mouse._x + (mouse.dx * 2);
}
}
i++;
}
notDropRock = eval ("rock" + notputdown);
i = 1;
while (i <= rocks) {
if (i != notputdown) {
currentRock = eval ("rock" + i);
if (notDropRock.hitTest(currentRock)) {
if (notDropRock._y < ((currentRock._y - 25) + (mouse.dy * 1.2))) {
mouse.dy = 0;
mouse._y = currentRock._y - 54;
onLand = true;
} else {
mouse.dx = mouse.dx * -1;
mouse._x = mouse._x + (mouse.dx * 2);
}
}
}
i++;
}
}
if (mouse.hitTest(leftbarrier)) {
mouse.dx = mouse.dx * -1;
mouse.oX = mouse.oX + (mouse.dx * 6);
}
if (mouse.hitTest(rightbarrier)) {
mouse.dx = mouse.dx * -1;
mouse.oX = mouse.oX + (mouse.dx * 6);
}
if (mouse.hitTest(topbarrier)) {
mouse.dy = mouse.dy * -1;
mouse.oY = mouse.oY + (mouse.dy * 6);
}
if (mouse.hitTest(bottombarrier)) {
mouse.dy = mouse.dy * -1;
mouse.oY = mouse.oY + (mouse.dy * 6);
}
i = 0;
while (i <= rocks) {
currentRock = eval ("rock" + i);
if (currentRock.hitTest(leftbarrier)) {
currentRock.dx = currentRock.dx * -1;
currentRock.oX = currentRock.oX + (currentRock.dx * 6);
}
if (currentRock.hitTest(rightbarrier)) {
currentRock.dx = currentRock.dx * -1;
currentRock.oX = currentRock.oX + (currentRock.dx * 6);
}
if (currentRock.hitTest(topbarrier)) {
currentRock.dy = currentRock.dy * -1;
currentRock.oY = currentRock.oY + (currentRock.dy * 6);
}
if (currentRock.hitTest(bottombarrier)) {
currentRock.dy = currentRock.dy * -1;
currentRock.oX = currentRock.oX + (currentRock.dy * 6);
}
i++;
}
i = 1;
while (i <= rocks) {
currentRock = eval ("rock" + i);
e = 1;
while (e <= enemies) {
currentEnemy = eval ("enemy" + e);
if (currentRock.hitTest(currentEnemy)) {
if (currentRock._y < currentEnemy._y) {
if (currentRock.dy > 0) {
if (playsounds) {
}
currentEnemy.health = currentEnemy.health - currentRock.dy;
if (currentEnemy.tower == false) {
currentEnemy._yscale = currentEnemy.health * 10;
} else {
currentEnemy._yscale = currentEnemy.health * 5;
}
currentEnemy.speed = 0;
currentRock.dy = 0;
currentRock.dx = 0;
if (notputdown == i) {
mouse._y = mouse._y - 5;
mouse.dy = mouse.dy - 1;
currentX = currentRock.oX + globalX;
currentY = currentRock.oY + globalY;
dx = mouse._x - currentX;
dy = mouse._y - currentY;
currentRock.oX = currentRock.oX + dx;
currentRock.oY = currentRock.oY + (dy + 27);
notputdown = -1;
}
if (currentEnemy.health <= 1) {
if (i != notputdown) {
if (playsounds) {
explosionS.start(0, 1);
}
explosion.oX = currentEnemy.oX;
explosion.oY = currentEnemy.oY;
if (currentEnemy.tower == true) {
explosion._yscale = 200;
explosion._xscale = 100;
} else {
explosion._yscale = 65;
explosion._xscale = 65;
}
explosion.gotoAndPlay(1);
currentEnemy.oX = -1000;
currentEnemy.oY = -1000;
} else {
if (playsounds) {
explosionS.start(0, 1);
}
if (currentEnemy.tower == true) {
explosion._yscale = 200;
explosion._xscale = 100;
} else {
explosion._yscale = 65;
explosion._xscale = 65;
}
explosion.gotoAndPlay(1);
currentEnemy.oX = -1000;
currentEnemy.oY = -1000;
mouse._y = mouse._y - 5;
mouse.dy = mouse.dy - 1;
currentX = currentRock.oX + globalX;
currentY = currentRock.oY + globalY;
dx = mouse._x - currentX;
dy = mouse._y - currentY;
currentRock.oX = currentRock.oX + dx;
currentRock.oY = currentRock.oY + (dy + 27);
notputdown = -1;
}
currentEnemy.dead = true;
}
}
}
}
e++;
}
i++;
}
i = 1;
while (i <= rocks) {
if (i != notputdown) {
currentRock = eval ("rock" + i);
if (mouse.hitTest(currentRock)) {
if (mouse._y < ((currentRock._y - 25) + (mouse.dy * 1.2))) {
mouse.dy = 0;
mouse._y = (currentRock.oY + globalY) - 26;
onLand = true;
} else {
mouse.dx = mouse.dx * -1;
mouse._x = mouse._x + (mouse.dx * 2);
}
}
}
i++;
}
i = 0;
while (i <= buttons) {
currentResponder = eval ("responder" + i);
if (mouse.hitTest(currentResponder)) {
mouse.dx = mouse.dx * -1;
mouse._x = mouse._x + (mouse.dx * 2);
}
i++;
}
pressed = false;
if (Key.isDown(38)) {
if (onLand) {
mouse.dy = -2;
mouse._y = mouse._y + mouse.dy;
} else if (flightJuice > 0) {
pressed = true;
mouse.gotoAndStop("up");
mouse.dy = mouse.dy - thrust;
flightJuice = flightJuice - 1;
}
}
if (Key.isDown(40)) {
if (onLand) {
} else if (flightJuice > 0) {
pressed = true;
mouse.gotoAndStop("down");
mouse.dy = mouse.dy + thrust;
flightJuice = flightJuice - 1;
}
if (mouse.hitTest(topbarrier)) {
mouse._y = mouse._y + 7;
}
i = 0;
while (i <= lands) {
currentLand = eval ("land" + i);
if (mouse.hitTest(currentLand)) {
if (currentLand._y < (mouse._y - 5)) {
mouse._y = mouse._y + 7;
}
}
i++;
}
}
if (Key.isDown(37)) {
pressed = true;
if (onLand) {
mouse.dx = mouse.dx - thrust;
mouse.gotoAndStop("left");
} else if (flightJuice > 0) {
pressed = true;
mouse.dx = mouse.dx - thrust;
mouse.gotoAndStop("left");
flightJuice = flightJuice - 1;
}
i = 1;
while (i <= lands) {
currentLand = eval ("land" + i);
if (mouse.hitTest(currentLand)) {
if (i != onLandNum) {
if (mouse._y > currentLand._y) {
mouse._x = mouse._x - 7;
}
}
}
i++;
}
i = 1;
while (i <= rocks) {
currentRock = eval ("rock" + i);
if (mouse.hitTest(currentRock)) {
if (mouse._y > (currentRock._y - 26)) {
if (i != notputdown) {
mouse._x = mouse._x - 7;
}
}
}
i++;
}
i = 0;
while (i <= buttons) {
currentResponder = eval ("responder" + i);
if (mouse.hitTest(currentResponder)) {
mouse._x = mouse._x - 7;
}
i++;
}
if (mouse.hitTest(rightbarrier)) {
mouse._x = mouse._x - 7;
}
} else if (Key.isDown(39)) {
pressed = true;
if (onLand) {
mouse.dx = mouse.dx + thrust;
mouse.gotoAndStop("left");
} else if (flightJuice > 0) {
pressed = true;
mouse.dx = mouse.dx + thrust;
mouse.gotoAndStop("left");
flightJuice = flightJuice - 1;
}
mouse.gotoAndStop("right");
i = 1;
while (i <= lands) {
currentLand = eval ("land" + i);
if (mouse.hitTest(currentLand)) {
if (i != onLandNum) {
if (mouse._y > currentLand._y) {
mouse._x = mouse._x + 7;
}
}
}
i++;
}
i = 1;
while (i <= rocks) {
currentRock = eval ("rock" + i);
if (mouse.hitTest(currentRock)) {
if (mouse._y > (currentRock._y - 26)) {
if (i != notputdown) {
mouse._x = mouse._x + 7;
}
}
}
i++;
}
i = 0;
while (i <= buttons) {
currentResponder = eval ("responder" + i);
if (mouse.hitTest(currentResponder)) {
mouse._x = mouse._x + 7;
}
i++;
}
if (mouse.hitTest(leftbarrier)) {
mouse._x = mouse._x + 7;
}
} else if (mouse.dx < 0) {
mouse.dx = mouse.dx + thrust;
} else if (mouse.dx > 0) {
mouse.dx = mouse.dx - thrust;
}
if (mouse.dx < 0.1) {
if (mouse.dx > 0) {
mouse.dx = 0;
}
}
if (mouse.dx > -0.1) {
if (mouse.dx < 0) {
mouse.dx = 0;
}
}
if (pressed == false) {
mouse.gotoAndStop("center");
}
if (pressed == true) {
if (playsounds) {
thrustsoundpauser++;
if (thrustsoundpauser == totalforthruster) {
thruster.start(0, 1);
thrustsoundpauser = 0;
}
}
}
if (Key.isDown(32)) {
if (donePressSpace) {
donePressSpace = false;
if (notputdown == -1) {
i = 1;
while (i <= rocks) {
currentRock = eval ("rock" + i);
if (mouse.hitTest(currentRock)) {
if (playsounds) {
pickup.start(0, 1);
}
notputdown = i;
dx = mouse._x - currentRock._x;
dy = mouse._y - currentRock._y;
currentRock.oX = currentRock.oX + dx;
currentRock.oY = currentRock.oY + (dy + 27);
}
i++;
}
} else {
mouse._y = mouse._y - 5;
mouse.dy = mouse.dy - 1;
if (playsounds) {
pickup.start(0, 1);
}
currentRock = eval ("rock" + notputdown);
currentX = currentRock.oX + globalX;
currentY = currentRock.oY + globalY;
dx = mouse._x - currentX;
dy = mouse._y - currentY;
currentRock.oX = currentRock.oX + dx;
currentRock.oY = currentRock.oY + (dy + 27);
notputdown = -1;
}
}
} else {
donePressSpace = true;
}
i = 1;
while (i <= rocks) {
currentRock = eval ("rock" + i);
if (i != notputdown) {
currentRock.dy = currentRock.dy + gravity;
currentRock.oX = currentRock.oX + currentRock.dx;
currentRock.oY = currentRock.oY + currentRock.dy;
}
l = 1;
while (l <= lands) {
currentLand = eval ("land" + l);
if (currentRock.hitTest(currentLand)) {
if (currentRock._y < ((currentLand._y + currentRock.dy) + 0.5)) {
currentRock.oY = currentLand.oY;
currentRock.dy = 0;
currentRock.dx = 0;
} else if (currentRock._y > (currentLand._y + 25.5)) {
currentRock.dy = currentRock.dy * -1;
currentRock.oY = currentRock.oY + (currentRock.dy * 2);
} else {
currentRock.dx = currentRock.dx * -1;
currentRock.oX = currentRock.oX + (currentRock.dx * 4);
}
}
l++;
}
b = 1;
while (b <= rocks) {
otherRock = eval ("rock" + b);
if (b != i) {
if (currentRock.hitTest(otherRock)) {
if (currentRock.oY < otherRock.oY) {
currentRock.oY = otherRock.oY - 29;
currentRock.dy = 0;
currentRock.dx = 0;
}
}
}
b++;
}
b = 0;
while (b <= buttons) {
currentResponder = eval ("responder" + b);
if (currentRock.hitTest(currentResponder)) {
currentRock.dx = currentRock.dx * -1;
currentRock.oX = currentRock.oX + (currentRock.dx * 6);
}
b++;
}
i++;
}
i = 1;
while (i <= enemies) {
currentEnemy = eval ("enemy" + i);
if (currentEnemy.tower == false) {
if (currentEnemy.gotoLeft == true) {
if (currentEnemy.patrolPoint < currentEnemy.patrolLength) {
currentEnemy.oX = currentEnemy.oX + currentEnemy.speed;
currentEnemy.patrolPoint = currentEnemy.patrolPoint + currentEnemy.speed;
} else {
currentEnemy.gotoLeft = false;
currentEnemy.gotoAndPlay("turn");
}
} else if (currentEnemy.patrolPoint > 0) {
currentEnemy.oX = currentEnemy.oX - currentEnemy.speed;
currentEnemy.patrolPoint = currentEnemy.patrolPoint - currentEnemy.speed;
} else {
currentEnemy.gotoLeft = true;
currentEnemy.gotoAndPlay("turn");
}
}
i++;
}
i = 0;
while (i <= enemies) {
currentEnemy = eval ("enemy" + i);
if (mouse.hitTest(currentEnemy)) {
if (currentEnemy.tower == false) {
health = health - currentEnemy.damage;
}
}
if (currentEnemy.tower == true) {
currentBullet = eval ("bullet" + i);
if (mouse.hitTest(currentBullet)) {
health = health - currentEnemy.damage;
}
}
i++;
}
i = 0;
while (i <= buttons) {
currentButton = eval ("button" + i);
currentResponder = eval ("responder" + i);
hit = false;
r = 0;
while (r <= rocks) {
currentRock = eval ("rock" + r);
if (currentButton.hitTest(currentRock)) {
hit = true;
if (currentButton.pressed == false) {
currentButton.pressed = true;
currentResponder.oX = currentResponder.oX + 10000;
}
}
r++;
}
if (mousehitsbuttons == true) {
if (mouse.hitTest(currentButton)) {
hit = true;
if (currentButton.pressed == false) {
currentButton.pressed = true;
currentResponder.oX = currentResponder.oX + 10000;
}
}
}
if (hit == false) {
if (currentButton.pressed == true) {
currentButton.pressed = false;
currentResponder.oX = currentResponder.oX - 10000;
currentResponder.alpha = 0;
}
}
i++;
}
currentResponder.fadeOut = false;
currentResponder.alpha = 100;
currentResponder.speed = 6;
if (mouse.hitTest(end)) {
if (win == false) {
level++;
winS.start(0, 1);
end.gotoAndPlay("win");
win = true;
}
}
i = 0;
while (i <= enemies) {
currentTower = eval ("enemy" + i);
if (currentTower.tower == true) {
currentTop = eval ("towertop" + i);
currentBullet = eval ("bullet" + i);
currentTop._x = currentTower._x;
currentTop._y = currentTower._y - (95 * (currentTower._yscale / 100));
currentTop._yscale = currentTower._yscale;
dx = currentTop._x - mouse._x;
dy = currentTop._y - mouse._y;
radians = Math.atan(dy / dx);
degrees = (radians * 180) / Math.PI;
if (dx > 0) {
degrees = degrees + 180;
}
radians = (degrees / 180) * Math.PI;
degrees = degrees + 90;
currentTop._rotation = degrees;
distance = Math.sqrt((dx * dx) + (dy * dy));
currentTower.counter++;
if (currentTower.counter >= currentTower.counterLimit) {
currentTower.counter = 0;
currentBullet.oX = currentTower.oX;
currentBullet.oY = currentTower.oY - (95 * (currentTower._yscale / 100));
currentBullet.dx = Math.cos(radians) * currentTower.launchSpeed;
currentBullet.dy = Math.sin(radians) * currentTower.launchSpeed;
}
currentBullet.oX = currentBullet.oX + currentBullet.dx;
currentBullet.oY = currentBullet.oY + currentBullet.dy;
}
i++;
}
};
menu.onRelease = function () {
gotoAndStop ("menu");
};
currentAlpha = 100;
faderbox._alpha = currentAlpha;
fadeOut = function () {
if (loading == true) {
faderbox.gotoAndStop("blue");
}
if (loading == false) {
faderbox.gotoAndStop("red");
}
currentAlpha = currentAlpha + speed;
if (currentAlpha >= 100) {
currentAlpha = 100;
if (loading == true) {
gotoAndStop ("loading");
}
if (loading == false) {
gotoAndStop ("lose");
}
}
faderbox._x = 0;
faderbox._y = 0;
faderbox._alpha = currentAlpha;
};
fadeIn = function () {
faderbox.gotoAndStop("blue");
currentAlpha = currentAlpha - speed;
if (currentAlpha <= 0) {
currentAlpha = 0;
faderbox._x = -10000;
faderbox._y = -10000;
}
faderbox._alpha = currentAlpha;
if (health < topHealth) {
faderbox.gotoAndStop("red");
faderbox._x = 0;
faderbox._y = 0;
faderbox._alpha = (100 - (health * healthMultiplier)) - 20;
if (faderbox._alpha < 0) {
faderbox._alpha = 0;
}
currentAlpha = faderbox._alpha;
}
};
Frame 91
lands = 12;
total = 0;
rocks = 6;
objects = 5;
buttons = 3;
enemies = 8;
notputdown = -1;
health = topHealth;
healthMultiplier = 100 / health;
flightJuice = topFlightJuice;
flightMultiplier = 100 / flightJuice;
mouse.maxWidth = 62.1;
landWidth = 188;
onLandNum = 0;
globalX = 0;
globalY = 0;
win = false;
mousehitsbuttons = false;
topsmoke = 5;
smoke = 0;
thrustsoundpauser = 0;
totalforthruster = 4;
fadein = true;
loading = true;
stop();
mouse = eval (type);
mouse._x = startX._x;
mouse._y = startX._y;
startX._x = -100;
startX._y = -100;
mouse.dy = 0;
mouse.dx = 0;
mouse.oX = mouse._x;
mouse.oY = mouse._y;
explosion.oX = -10000;
explosion.oY = -10000;
leftbarrier.oX = leftbarrier._x;
leftbarrier.oY = leftbarrier._y;
rightbarrier.oX = rightbarrier._x;
rightbarrier.oY = rightbarrier._y;
topbarrier.oX = topbarrier._x;
topbarrier.oY = topbarrier._y;
bottombarrier.oX = bottombarrier._x;
bottombarrier.oY = bottombarrier._y;
end.oX = end._x;
end.oY = end._y;
enemy1.tower = false;
enemy2.tower = false;
enemy3.tower = false;
enemy4.tower = false;
enemy5.tower = true;
enemy6.tower = true;
enemy7.tower = true;
enemy8.tower = true;
i = 0;
while (i <= objects) {
currentObject = eval ("object" + i);
currentObject.oX = currentObject._x;
currentObject.oY = currentObject._y;
i++;
}
enemy1.gotoLeft = true;
i = 1;
while (i <= enemies) {
currentEnemy = eval ("enemy" + i);
currentEnemy.health = 8;
currentEnemy.speed = 2;
firstFlag = eval ("firstPatrolMarker" + i);
secondFlag = eval ("secondPatrolMarker" + i);
currentEnemy.patrolLength = secondFlag._x - firstFlag._x;
currentEnemy.patrolPoint = currentEnemy._x - firstFlag._x;
firstFlag._x = -100;
secondFlag._x = -100;
currentEnemy.damage = 1;
currentEnemy.oX = currentEnemy._x;
currentEnemy.oY = currentEnemy._y;
currentEnemy.dead = false;
currentEnemy.gotoLeft = true;
i++;
}
i = 0;
while (i <= enemies) {
currentEnemy = eval ("enemy" + i);
if (currentEnemy.tower == true) {
currentEnemy.counter = 0;
currentEnemy.counterLimit = 60;
currentEnemy.launchSpeed = 2;
currentEnemy.health = 20;
}
i++;
}
i = 0;
while (i <= buttons) {
currentButton = eval ("button" + i);
currentButton.pressed = false;
currentButton.oX = currentButton._x;
currentButton.oY = currentButton._y;
currentResponder = eval ("responder" + i);
currentResponder.oX = currentResponder._x;
currentResponder.oY = currentResponder._y;
currentResponder.fadeOut = false;
currentResponder.alpha = 100;
currentResponder.speed = 6;
i++;
}
i = 0;
while (i <= rocks) {
currentRock = eval ("rock" + i);
currentRock.oX = currentRock._x;
currentRock.oY = currentRock._y;
currentRock.dx = 0;
currentRock.dy = 0;
currentRock.originX = currentRock._x;
currentRock.originY = currentRock._y;
i++;
}
i = 0;
while (i <= lands) {
currentLand = eval ("land" + i);
currentLand.oX = currentLand._x;
currentLand.oY = currentLand._y;
i++;
}
mouse.onEnterFrame = function () {
if (fadein == true) {
fadeIn();
} else {
fadeOut();
}
mouse.dy = mouse.dy + gravity;
mouse._y = mouse._y + mouse.dy;
mouse._x = mouse._x + mouse.dx;
healthbar._xscale = health * healthMultiplier;
if (flightJuice > 0) {
flightbar._xscale = flightJuice * flightMultiplier;
}
if (health <= 0) {
fadein = false;
loading = false;
}
if (health < topHealth) {
health = health + (regenerateRate / 5);
}
if (flightJuice < topFlightJuice) {
flightJuice = flightJuice + regenerateRate;
}
dx = (Stage.width / 2) - mouse._x;
dy = (Stage.width / 2) - mouse._y;
dx = dx / 4;
dy = dy / 4;
if (mouse.dx > topspeed) {
mouse.dx = topspeed;
}
if (mouse.dx < (-topspeed)) {
mouse.dx = -topspeed;
}
if (mouse.dy > topspeed) {
mouse.dy = topspeed;
}
if (mouse.dy < (-topspeed)) {
mouse.dy = -topspeed;
}
globalX = globalX + dx;
globalY = globalY + dy;
i = 1;
while (i <= lands) {
currentLand = eval ("land" + i);
currentLand._x = currentLand.oX + globalX;
currentLand._y = currentLand.oY + globalY;
i++;
}
i = 1;
while (i <= rocks) {
currentRock = eval ("rock" + i);
currentRock._x = currentRock.oX + globalX;
currentRock._y = currentRock.oY + globalY;
i++;
}
i = 1;
while (i <= enemies) {
currentEnemy = eval ("enemy" + i);
currentEnemy._x = currentEnemy.oX + globalX;
currentEnemy._y = currentEnemy.oY + globalY;
if (currentEnemy.tower) {
currentBullet = eval ("bullet" + i);
currentBullet._x = currentBullet.oX + globalX;
currentBullet._y = currentBullet.oY + globalY;
}
i++;
}
explosion._x = explosion.oX + globalX;
explosion._y = explosion.oY + globalY;
i = 0;
while (i <= buttons) {
currentButton = eval ("button" + i);
currentResponder = eval ("responder" + i);
currentButton._x = currentButton.oX + globalX;
currentButton._y = currentButton.oY + globalY;
currentResponder._x = currentResponder.oX + globalX;
currentResponder._y = currentResponder.oY + globalY;
i++;
}
i = 0;
while (i <= objects) {
currentObject = eval ("object" + i);
currentObject._x = currentObject.oX + globalX;
currentObject._y = currentObject.oY + globalY;
i++;
}
leftbarrier._x = leftbarrier.oX + globalX;
leftbarrier._y = leftbarrier.oY + globalY;
rightbarrier._x = rightbarrier.oX + globalX;
rightbarrier._y = rightbarrier.oY + globalY;
topbarrier._x = topbarrier.oX + globalX;
topbarrier._y = topbarrier.oY + globalY;
bottombarrier._x = bottombarrier.oX + globalX;
bottombarrier._y = bottombarrier.oY + globalY;
end._x = end.oX + globalX;
end._y = end.oY + globalY;
mouse.oX = mouse.oX + dx;
mouse.oY = mouse.oY + dy;
mouse._y = mouse._y + dy;
mouse._x = mouse._x + dx;
bg._x = bg._x + (dx / 3);
bg._y = bg._y + (dy / 3);
if (notputdown != -1) {
currentRock = eval ("rock" + notputdown);
currentRock._x = mouse._x;
currentRock._y = mouse._y + 25;
currentRock.dx = mouse.dx;
currentRock.dy = mouse.dy;
}
onLand = false;
i = 1;
while (i <= lands) {
currentLand = eval ("land" + i);
if (mouse.hitTest(currentLand)) {
if (mouse._y < (currentLand._y + (mouse.dy * 1.2))) {
mouse.dy = 0;
mouse._y = currentLand._y;
onLand = true;
onLandNum = i;
} else if (mouse._y > (((currentLand._y + 35.5) + 25.4) + (mouse.dy * 1.2))) {
mouse.dy = mouse.dy * -1;
mouse._y = mouse._y + (mouse.dy * 1.5);
} else {
mouse.dx = mouse.dx * -1;
mouse._x = mouse._x + (mouse.dx * 2);
}
}
i++;
}
if (notputdown != -1) {
currentRock = eval ("rock" + notputdown);
i = 1;
while (i <= lands) {
currentLand = eval ("land" + i);
if (currentRock.hitTest(currentLand)) {
if (currentRock._y < (currentLand._y + (mouse.dy * 1.2))) {
mouse.dy = 0;
mouse._y = currentLand._y - 25;
onLand = true;
onLandNum = i;
} else if (currentRock._y > (((currentLand._y + 35) + 27) + (mouse.dy * 1.2))) {
mouse.dy = mouse.dy * -1;
mouse._y = mouse._y + (mouse.dy * 1.5);
} else {
mouse.dx = mouse.dx * -1;
mouse._x = mouse._x + (mouse.dx * 2);
}
}
i++;
}
notDropRock = eval ("rock" + notputdown);
i = 1;
while (i <= rocks) {
if (i != notputdown) {
currentRock = eval ("rock" + i);
if (notDropRock.hitTest(currentRock)) {
if (notDropRock._y < ((currentRock._y - 25) + (mouse.dy * 1.2))) {
mouse.dy = 0;
mouse._y = currentRock._y - 54;
onLand = true;
} else {
mouse.dx = mouse.dx * -1;
mouse._x = mouse._x + (mouse.dx * 2);
}
}
}
i++;
}
}
if (mouse.hitTest(leftbarrier)) {
mouse.dx = mouse.dx * -1;
mouse.oX = mouse.oX + (mouse.dx * 6);
}
if (mouse.hitTest(rightbarrier)) {
mouse.dx = mouse.dx * -1;
mouse.oX = mouse.oX + (mouse.dx * 6);
}
if (mouse.hitTest(topbarrier)) {
mouse.dy = mouse.dy * -1;
mouse.oY = mouse.oY + (mouse.dy * 6);
}
if (mouse.hitTest(bottombarrier)) {
mouse.dy = mouse.dy * -1;
mouse.oY = mouse.oY + (mouse.dy * 6);
}
i = 0;
while (i <= rocks) {
currentRock = eval ("rock" + i);
if (currentRock.hitTest(leftbarrier)) {
currentRock.dx = currentRock.dx * -1;
currentRock.oX = currentRock.oX + (currentRock.dx * 6);
}
if (currentRock.hitTest(rightbarrier)) {
currentRock.dx = currentRock.dx * -1;
currentRock.oX = currentRock.oX + (currentRock.dx * 6);
}
if (currentRock.hitTest(topbarrier)) {
currentRock.dy = currentRock.dy * -1;
currentRock.oY = currentRock.oY + (currentRock.dy * 6);
}
if (currentRock.hitTest(bottombarrier)) {
currentRock.dy = currentRock.dy * -1;
currentRock.oX = currentRock.oX + (currentRock.dy * 6);
}
i++;
}
i = 1;
while (i <= rocks) {
currentRock = eval ("rock" + i);
e = 1;
while (e <= enemies) {
currentEnemy = eval ("enemy" + e);
if (currentRock.hitTest(currentEnemy)) {
if (currentRock._y < currentEnemy._y) {
if (currentRock.dy > 0) {
if (playsounds) {
}
currentEnemy.health = currentEnemy.health - currentRock.dy;
if (currentEnemy.tower == false) {
currentEnemy._yscale = currentEnemy.health * 10;
} else {
currentEnemy._yscale = currentEnemy.health * 5;
}
currentEnemy.speed = 0;
currentRock.dy = 0;
currentRock.dx = 0;
if (notputdown == i) {
mouse._y = mouse._y - 5;
mouse.dy = mouse.dy - 1;
currentX = currentRock.oX + globalX;
currentY = currentRock.oY + globalY;
dx = mouse._x - currentX;
dy = mouse._y - currentY;
currentRock.oX = currentRock.oX + dx;
currentRock.oY = currentRock.oY + (dy + 27);
notputdown = -1;
}
if (currentEnemy.health <= 1) {
if (i != notputdown) {
if (playsounds) {
explosionS.start(0, 1);
}
explosion.oX = currentEnemy.oX;
explosion.oY = currentEnemy.oY;
if (currentEnemy.tower == true) {
explosion._yscale = 200;
explosion._xscale = 100;
} else {
explosion._yscale = 65;
explosion._xscale = 65;
}
explosion.gotoAndPlay(1);
currentEnemy.oX = -1000;
currentEnemy.oY = -1000;
} else {
if (playsounds) {
explosionS.start(0, 1);
}
if (currentEnemy.tower == true) {
explosion._yscale = 200;
explosion._xscale = 100;
} else {
explosion._yscale = 65;
explosion._xscale = 65;
}
explosion.gotoAndPlay(1);
currentEnemy.oX = -1000;
currentEnemy.oY = -1000;
mouse._y = mouse._y - 5;
mouse.dy = mouse.dy - 1;
currentX = currentRock.oX + globalX;
currentY = currentRock.oY + globalY;
dx = mouse._x - currentX;
dy = mouse._y - currentY;
currentRock.oX = currentRock.oX + dx;
currentRock.oY = currentRock.oY + (dy + 27);
notputdown = -1;
}
currentEnemy.dead = true;
}
}
}
}
e++;
}
i++;
}
i = 1;
while (i <= rocks) {
if (i != notputdown) {
currentRock = eval ("rock" + i);
if (mouse.hitTest(currentRock)) {
if (mouse._y < ((currentRock._y - 25) + (mouse.dy * 1.2))) {
mouse.dy = 0;
mouse._y = (currentRock.oY + globalY) - 26;
onLand = true;
} else {
mouse.dx = mouse.dx * -1;
mouse._x = mouse._x + (mouse.dx * 2);
}
}
}
i++;
}
i = 0;
while (i <= buttons) {
currentResponder = eval ("responder" + i);
if (mouse.hitTest(currentResponder)) {
mouse.dx = mouse.dx * -1;
mouse._x = mouse._x + (mouse.dx * 2);
}
i++;
}
pressed = false;
if (Key.isDown(38)) {
if (onLand) {
mouse.dy = -2;
mouse._y = mouse._y + mouse.dy;
} else if (flightJuice > 0) {
pressed = true;
mouse.gotoAndStop("up");
mouse.dy = mouse.dy - thrust;
flightJuice = flightJuice - 1;
}
}
if (Key.isDown(40)) {
if (onLand) {
} else if (flightJuice > 0) {
pressed = true;
mouse.gotoAndStop("down");
mouse.dy = mouse.dy + thrust;
flightJuice = flightJuice - 1;
}
if (mouse.hitTest(topbarrier)) {
mouse._y = mouse._y + 7;
}
i = 0;
while (i <= lands) {
currentLand = eval ("land" + i);
if (mouse.hitTest(currentLand)) {
if (currentLand._y < (mouse._y - 5)) {
mouse._y = mouse._y + 7;
}
}
i++;
}
}
if (Key.isDown(37)) {
pressed = true;
if (onLand) {
mouse.dx = mouse.dx - thrust;
mouse.gotoAndStop("left");
} else if (flightJuice > 0) {
pressed = true;
mouse.dx = mouse.dx - thrust;
mouse.gotoAndStop("left");
flightJuice = flightJuice - 1;
}
i = 1;
while (i <= lands) {
currentLand = eval ("land" + i);
if (mouse.hitTest(currentLand)) {
if (i != onLandNum) {
if (mouse._y > currentLand._y) {
mouse._x = mouse._x - 7;
}
}
}
i++;
}
i = 1;
while (i <= rocks) {
currentRock = eval ("rock" + i);
if (mouse.hitTest(currentRock)) {
if (mouse._y > (currentRock._y - 26)) {
if (i != notputdown) {
mouse._x = mouse._x - 7;
}
}
}
i++;
}
i = 0;
while (i <= buttons) {
currentResponder = eval ("responder" + i);
if (mouse.hitTest(currentResponder)) {
mouse._x = mouse._x - 7;
}
i++;
}
if (mouse.hitTest(rightbarrier)) {
mouse._x = mouse._x - 7;
}
} else if (Key.isDown(39)) {
pressed = true;
if (onLand) {
mouse.dx = mouse.dx + thrust;
mouse.gotoAndStop("left");
} else if (flightJuice > 0) {
pressed = true;
mouse.dx = mouse.dx + thrust;
mouse.gotoAndStop("left");
flightJuice = flightJuice - 1;
}
mouse.gotoAndStop("right");
i = 1;
while (i <= lands) {
currentLand = eval ("land" + i);
if (mouse.hitTest(currentLand)) {
if (i != onLandNum) {
if (mouse._y > currentLand._y) {
mouse._x = mouse._x + 7;
}
}
}
i++;
}
i = 1;
while (i <= rocks) {
currentRock = eval ("rock" + i);
if (mouse.hitTest(currentRock)) {
if (mouse._y > (currentRock._y - 26)) {
if (i != notputdown) {
mouse._x = mouse._x + 7;
}
}
}
i++;
}
i = 0;
while (i <= buttons) {
currentResponder = eval ("responder" + i);
if (mouse.hitTest(currentResponder)) {
mouse._x = mouse._x + 7;
}
i++;
}
if (mouse.hitTest(leftbarrier)) {
mouse._x = mouse._x + 7;
}
} else if (mouse.dx < 0) {
mouse.dx = mouse.dx + thrust;
} else if (mouse.dx > 0) {
mouse.dx = mouse.dx - thrust;
}
if (mouse.dx < 0.1) {
if (mouse.dx > 0) {
mouse.dx = 0;
}
}
if (mouse.dx > -0.1) {
if (mouse.dx < 0) {
mouse.dx = 0;
}
}
if (pressed == false) {
mouse.gotoAndStop("center");
}
if (pressed == true) {
if (playsounds) {
thrustsoundpauser++;
if (thrustsoundpauser == totalforthruster) {
thruster.start(0, 1);
thrustsoundpauser = 0;
}
}
}
if (Key.isDown(32)) {
if (donePressSpace) {
donePressSpace = false;
if (notputdown == -1) {
i = 1;
while (i <= rocks) {
currentRock = eval ("rock" + i);
if (mouse.hitTest(currentRock)) {
if (playsounds) {
pickup.start(0, 1);
}
notputdown = i;
dx = mouse._x - currentRock._x;
dy = mouse._y - currentRock._y;
currentRock.oX = currentRock.oX + dx;
currentRock.oY = currentRock.oY + (dy + 27);
}
i++;
}
} else {
mouse._y = mouse._y - 5;
mouse.dy = mouse.dy - 1;
if (playsounds) {
pickup.start(0, 1);
}
currentRock = eval ("rock" + notputdown);
currentX = currentRock.oX + globalX;
currentY = currentRock.oY + globalY;
dx = mouse._x - currentX;
dy = mouse._y - currentY;
currentRock.oX = currentRock.oX + dx;
currentRock.oY = currentRock.oY + (dy + 27);
notputdown = -1;
}
}
} else {
donePressSpace = true;
}
i = 1;
while (i <= rocks) {
currentRock = eval ("rock" + i);
if (i != notputdown) {
currentRock.dy = currentRock.dy + gravity;
currentRock.oX = currentRock.oX + currentRock.dx;
currentRock.oY = currentRock.oY + currentRock.dy;
}
l = 1;
while (l <= lands) {
currentLand = eval ("land" + l);
if (currentRock.hitTest(currentLand)) {
if (currentRock._y < ((currentLand._y + currentRock.dy) + 0.5)) {
currentRock.oY = currentLand.oY;
currentRock.dy = 0;
currentRock.dx = 0;
} else if (currentRock._y > (currentLand._y + 25.5)) {
currentRock.dy = currentRock.dy * -1;
currentRock.oY = currentRock.oY + (currentRock.dy * 2);
} else {
currentRock.dx = currentRock.dx * -1;
currentRock.oX = currentRock.oX + (currentRock.dx * 4);
}
}
l++;
}
b = 1;
while (b <= rocks) {
otherRock = eval ("rock" + b);
if (b != i) {
if (currentRock.hitTest(otherRock)) {
if (currentRock.oY < otherRock.oY) {
currentRock.oY = otherRock.oY - 29;
currentRock.dy = 0;
currentRock.dx = 0;
}
}
}
b++;
}
b = 0;
while (b <= buttons) {
currentResponder = eval ("responder" + b);
if (currentRock.hitTest(currentResponder)) {
currentRock.dx = currentRock.dx * -1;
currentRock.oX = currentRock.oX + (currentRock.dx * 6);
}
b++;
}
i++;
}
i = 1;
while (i <= enemies) {
currentEnemy = eval ("enemy" + i);
if (currentEnemy.tower == false) {
if (currentEnemy.gotoLeft == true) {
if (currentEnemy.patrolPoint < currentEnemy.patrolLength) {
currentEnemy.oX = currentEnemy.oX + currentEnemy.speed;
currentEnemy.patrolPoint = currentEnemy.patrolPoint + currentEnemy.speed;
} else {
currentEnemy.gotoLeft = false;
currentEnemy.gotoAndPlay("turn");
}
} else if (currentEnemy.patrolPoint > 0) {
currentEnemy.oX = currentEnemy.oX - currentEnemy.speed;
currentEnemy.patrolPoint = currentEnemy.patrolPoint - currentEnemy.speed;
} else {
currentEnemy.gotoLeft = true;
currentEnemy.gotoAndPlay("turn");
}
}
i++;
}
i = 0;
while (i <= enemies) {
currentEnemy = eval ("enemy" + i);
if (mouse.hitTest(currentEnemy)) {
if (currentEnemy.tower == false) {
health = health - currentEnemy.damage;
}
}
if (currentEnemy.tower == true) {
currentBullet = eval ("bullet" + i);
if (mouse.hitTest(currentBullet)) {
health = health - currentEnemy.damage;
}
}
i++;
}
i = 0;
while (i <= buttons) {
currentButton = eval ("button" + i);
currentResponder = eval ("responder" + i);
hit = false;
r = 0;
while (r <= rocks) {
currentRock = eval ("rock" + r);
if (currentButton.hitTest(currentRock)) {
hit = true;
if (currentButton.pressed == false) {
currentButton.pressed = true;
currentResponder.oX = currentResponder.oX + 10000;
}
}
r++;
}
if (mousehitsbuttons == true) {
if (mouse.hitTest(currentButton)) {
hit = true;
if (currentButton.pressed == false) {
currentButton.pressed = true;
currentResponder.oX = currentResponder.oX + 10000;
}
}
}
if (hit == false) {
if (currentButton.pressed == true) {
currentButton.pressed = false;
currentResponder.oX = currentResponder.oX - 10000;
currentResponder.alpha = 0;
}
}
i++;
}
currentResponder.fadeOut = false;
currentResponder.alpha = 100;
currentResponder.speed = 6;
if (mouse.hitTest(end)) {
if (win == false) {
level++;
winS.start(0, 1);
end.gotoAndPlay("win");
win = true;
}
}
i = 0;
while (i <= enemies) {
currentTower = eval ("enemy" + i);
if (currentTower.tower == true) {
currentTop = eval ("towertop" + i);
currentBullet = eval ("bullet" + i);
currentTop._x = currentTower._x;
currentTop._y = currentTower._y - (95 * (currentTower._yscale / 100));
currentTop._yscale = currentTower._yscale;
dx = currentTop._x - mouse._x;
dy = currentTop._y - mouse._y;
radians = Math.atan(dy / dx);
degrees = (radians * 180) / Math.PI;
if (dx > 0) {
degrees = degrees + 180;
}
radians = (degrees / 180) * Math.PI;
degrees = degrees + 90;
currentTop._rotation = degrees;
distance = Math.sqrt((dx * dx) + (dy * dy));
currentTower.counter++;
if (currentTower.counter >= currentTower.counterLimit) {
currentTower.counter = 0;
currentBullet.oX = currentTower.oX;
currentBullet.oY = currentTower.oY - (95 * (currentTower._yscale / 100));
currentBullet.dx = Math.cos(radians) * currentTower.launchSpeed;
currentBullet.dy = Math.sin(radians) * currentTower.launchSpeed;
}
currentBullet.oX = currentBullet.oX + currentBullet.dx;
currentBullet.oY = currentBullet.oY + currentBullet.dy;
}
i++;
}
};
menu.onRelease = function () {
gotoAndStop ("menu");
};
currentAlpha = 100;
faderbox._alpha = currentAlpha;
fadeOut = function () {
if (loading == true) {
faderbox.gotoAndStop("blue");
}
if (loading == false) {
faderbox.gotoAndStop("red");
}
currentAlpha = currentAlpha + speed;
if (currentAlpha >= 100) {
currentAlpha = 100;
if (loading == true) {
gotoAndStop ("loading");
}
if (loading == false) {
gotoAndStop ("lose");
}
}
faderbox._x = 0;
faderbox._y = 0;
faderbox._alpha = currentAlpha;
};
fadeIn = function () {
faderbox.gotoAndStop("blue");
currentAlpha = currentAlpha - speed;
if (currentAlpha <= 0) {
currentAlpha = 0;
faderbox._x = -10000;
faderbox._y = -10000;
}
faderbox._alpha = currentAlpha;
if (health < topHealth) {
faderbox.gotoAndStop("red");
faderbox._x = 0;
faderbox._y = 0;
faderbox._alpha = (100 - (health * healthMultiplier)) - 20;
if (faderbox._alpha < 0) {
faderbox._alpha = 0;
}
currentAlpha = faderbox._alpha;
}
};
Frame 92
lands = 12;
total = 0;
rocks = 6;
objects = 5;
buttons = 3;
enemies = 8;
notputdown = -1;
health = topHealth;
healthMultiplier = 100 / health;
flightJuice = topFlightJuice;
flightMultiplier = 100 / flightJuice;
mouse.maxWidth = 62.1;
landWidth = 188;
onLandNum = 0;
globalX = 0;
globalY = 0;
win = false;
mousehitsbuttons = false;
topsmoke = 5;
smoke = 0;
thrustsoundpauser = 0;
totalforthruster = 4;
fadein = true;
loading = true;
stop();
mouse = eval (type);
mouse._x = startX._x;
mouse._y = startX._y;
startX._x = -100;
startX._y = -100;
mouse.dy = 0;
mouse.dx = 0;
mouse.oX = mouse._x;
mouse.oY = mouse._y;
explosion.oX = -10000;
explosion.oY = -10000;
leftbarrier.oX = leftbarrier._x;
leftbarrier.oY = leftbarrier._y;
rightbarrier.oX = rightbarrier._x;
rightbarrier.oY = rightbarrier._y;
topbarrier.oX = topbarrier._x;
topbarrier.oY = topbarrier._y;
bottombarrier.oX = bottombarrier._x;
bottombarrier.oY = bottombarrier._y;
end.oX = end._x;
end.oY = end._y;
enemy1.tower = false;
enemy2.tower = false;
enemy3.tower = false;
enemy4.tower = false;
enemy5.tower = true;
enemy6.tower = true;
enemy7.tower = true;
enemy8.tower = true;
i = 0;
while (i <= objects) {
currentObject = eval ("object" + i);
currentObject.oX = currentObject._x;
currentObject.oY = currentObject._y;
i++;
}
enemy1.gotoLeft = true;
i = 1;
while (i <= enemies) {
currentEnemy = eval ("enemy" + i);
currentEnemy.health = 8;
currentEnemy.speed = 2;
firstFlag = eval ("firstPatrolMarker" + i);
secondFlag = eval ("secondPatrolMarker" + i);
currentEnemy.patrolLength = secondFlag._x - firstFlag._x;
currentEnemy.patrolPoint = currentEnemy._x - firstFlag._x;
firstFlag._x = -100;
secondFlag._x = -100;
currentEnemy.damage = 1;
currentEnemy.oX = currentEnemy._x;
currentEnemy.oY = currentEnemy._y;
currentEnemy.dead = false;
currentEnemy.gotoLeft = true;
i++;
}
i = 0;
while (i <= enemies) {
currentEnemy = eval ("enemy" + i);
if (currentEnemy.tower == true) {
currentEnemy.counter = 0;
currentEnemy.counterLimit = 60;
currentEnemy.launchSpeed = 2;
currentEnemy.health = 20;
}
i++;
}
i = 0;
while (i <= buttons) {
currentButton = eval ("button" + i);
currentButton.pressed = false;
currentButton.oX = currentButton._x;
currentButton.oY = currentButton._y;
currentResponder = eval ("responder" + i);
currentResponder.oX = currentResponder._x;
currentResponder.oY = currentResponder._y;
currentResponder.fadeOut = false;
currentResponder.alpha = 100;
currentResponder.speed = 6;
i++;
}
i = 0;
while (i <= rocks) {
currentRock = eval ("rock" + i);
currentRock.oX = currentRock._x;
currentRock.oY = currentRock._y;
currentRock.dx = 0;
currentRock.dy = 0;
currentRock.originX = currentRock._x;
currentRock.originY = currentRock._y;
i++;
}
i = 0;
while (i <= lands) {
currentLand = eval ("land" + i);
currentLand.oX = currentLand._x;
currentLand.oY = currentLand._y;
i++;
}
mouse.onEnterFrame = function () {
if (fadein == true) {
fadeIn();
} else {
fadeOut();
}
mouse.dy = mouse.dy + gravity;
mouse._y = mouse._y + mouse.dy;
mouse._x = mouse._x + mouse.dx;
healthbar._xscale = health * healthMultiplier;
if (flightJuice > 0) {
flightbar._xscale = flightJuice * flightMultiplier;
}
if (health <= 0) {
fadein = false;
loading = false;
}
if (health < topHealth) {
health = health + (regenerateRate / 5);
}
if (flightJuice < topFlightJuice) {
flightJuice = flightJuice + regenerateRate;
}
dx = (Stage.width / 2) - mouse._x;
dy = (Stage.width / 2) - mouse._y;
dx = dx / 4;
dy = dy / 4;
if (mouse.dx > topspeed) {
mouse.dx = topspeed;
}
if (mouse.dx < (-topspeed)) {
mouse.dx = -topspeed;
}
if (mouse.dy > topspeed) {
mouse.dy = topspeed;
}
if (mouse.dy < (-topspeed)) {
mouse.dy = -topspeed;
}
globalX = globalX + dx;
globalY = globalY + dy;
i = 1;
while (i <= lands) {
currentLand = eval ("land" + i);
currentLand._x = currentLand.oX + globalX;
currentLand._y = currentLand.oY + globalY;
i++;
}
i = 1;
while (i <= rocks) {
currentRock = eval ("rock" + i);
currentRock._x = currentRock.oX + globalX;
currentRock._y = currentRock.oY + globalY;
i++;
}
i = 1;
while (i <= enemies) {
currentEnemy = eval ("enemy" + i);
currentEnemy._x = currentEnemy.oX + globalX;
currentEnemy._y = currentEnemy.oY + globalY;
if (currentEnemy.tower) {
currentBullet = eval ("bullet" + i);
currentBullet._x = currentBullet.oX + globalX;
currentBullet._y = currentBullet.oY + globalY;
}
i++;
}
explosion._x = explosion.oX + globalX;
explosion._y = explosion.oY + globalY;
i = 0;
while (i <= buttons) {
currentButton = eval ("button" + i);
currentResponder = eval ("responder" + i);
currentButton._x = currentButton.oX + globalX;
currentButton._y = currentButton.oY + globalY;
currentResponder._x = currentResponder.oX + globalX;
currentResponder._y = currentResponder.oY + globalY;
i++;
}
i = 0;
while (i <= objects) {
currentObject = eval ("object" + i);
currentObject._x = currentObject.oX + globalX;
currentObject._y = currentObject.oY + globalY;
i++;
}
leftbarrier._x = leftbarrier.oX + globalX;
leftbarrier._y = leftbarrier.oY + globalY;
rightbarrier._x = rightbarrier.oX + globalX;
rightbarrier._y = rightbarrier.oY + globalY;
topbarrier._x = topbarrier.oX + globalX;
topbarrier._y = topbarrier.oY + globalY;
bottombarrier._x = bottombarrier.oX + globalX;
bottombarrier._y = bottombarrier.oY + globalY;
end._x = end.oX + globalX;
end._y = end.oY + globalY;
mouse.oX = mouse.oX + dx;
mouse.oY = mouse.oY + dy;
mouse._y = mouse._y + dy;
mouse._x = mouse._x + dx;
bg._x = bg._x + (dx / 3);
bg._y = bg._y + (dy / 3);
if (notputdown != -1) {
currentRock = eval ("rock" + notputdown);
currentRock._x = mouse._x;
currentRock._y = mouse._y + 25;
currentRock.dx = mouse.dx;
currentRock.dy = mouse.dy;
}
onLand = false;
i = 1;
while (i <= lands) {
currentLand = eval ("land" + i);
if (mouse.hitTest(currentLand)) {
if (mouse._y < (currentLand._y + (mouse.dy * 1.2))) {
mouse.dy = 0;
mouse._y = currentLand._y;
onLand = true;
onLandNum = i;
} else if (mouse._y > (((currentLand._y + 35.5) + 25.4) + (mouse.dy * 1.2))) {
mouse.dy = mouse.dy * -1;
mouse._y = mouse._y + (mouse.dy * 1.5);
} else {
mouse.dx = mouse.dx * -1;
mouse._x = mouse._x + (mouse.dx * 2);
}
}
i++;
}
if (notputdown != -1) {
currentRock = eval ("rock" + notputdown);
i = 1;
while (i <= lands) {
currentLand = eval ("land" + i);
if (currentRock.hitTest(currentLand)) {
if (currentRock._y < (currentLand._y + (mouse.dy * 1.2))) {
mouse.dy = 0;
mouse._y = currentLand._y - 25;
onLand = true;
onLandNum = i;
} else if (currentRock._y > (((currentLand._y + 35) + 27) + (mouse.dy * 1.2))) {
mouse.dy = mouse.dy * -1;
mouse._y = mouse._y + (mouse.dy * 1.5);
} else {
mouse.dx = mouse.dx * -1;
mouse._x = mouse._x + (mouse.dx * 2);
}
}
i++;
}
notDropRock = eval ("rock" + notputdown);
i = 1;
while (i <= rocks) {
if (i != notputdown) {
currentRock = eval ("rock" + i);
if (notDropRock.hitTest(currentRock)) {
if (notDropRock._y < ((currentRock._y - 25) + (mouse.dy * 1.2))) {
mouse.dy = 0;
mouse._y = currentRock._y - 54;
onLand = true;
} else {
mouse.dx = mouse.dx * -1;
mouse._x = mouse._x + (mouse.dx * 2);
}
}
}
i++;
}
}
if (mouse.hitTest(leftbarrier)) {
mouse.dx = mouse.dx * -1;
mouse.oX = mouse.oX + (mouse.dx * 6);
}
if (mouse.hitTest(rightbarrier)) {
mouse.dx = mouse.dx * -1;
mouse.oX = mouse.oX + (mouse.dx * 6);
}
if (mouse.hitTest(topbarrier)) {
mouse.dy = mouse.dy * -1;
mouse.oY = mouse.oY + (mouse.dy * 6);
}
if (mouse.hitTest(bottombarrier)) {
mouse.dy = mouse.dy * -1;
mouse.oY = mouse.oY + (mouse.dy * 6);
}
i = 0;
while (i <= rocks) {
currentRock = eval ("rock" + i);
if (currentRock.hitTest(leftbarrier)) {
currentRock.dx = currentRock.dx * -1;
currentRock.oX = currentRock.oX + (currentRock.dx * 6);
}
if (currentRock.hitTest(rightbarrier)) {
currentRock.dx = currentRock.dx * -1;
currentRock.oX = currentRock.oX + (currentRock.dx * 6);
}
if (currentRock.hitTest(topbarrier)) {
currentRock.dy = currentRock.dy * -1;
currentRock.oY = currentRock.oY + (currentRock.dy * 6);
}
if (currentRock.hitTest(bottombarrier)) {
currentRock.dy = currentRock.dy * -1;
currentRock.oX = currentRock.oX + (currentRock.dy * 6);
}
i++;
}
i = 1;
while (i <= rocks) {
currentRock = eval ("rock" + i);
e = 1;
while (e <= enemies) {
currentEnemy = eval ("enemy" + e);
if (currentRock.hitTest(currentEnemy)) {
if (currentRock._y < currentEnemy._y) {
if (currentRock.dy > 0) {
if (playsounds) {
}
currentEnemy.health = currentEnemy.health - currentRock.dy;
if (currentEnemy.tower == false) {
currentEnemy._yscale = currentEnemy.health * 10;
} else {
currentEnemy._yscale = currentEnemy.health * 5;
}
currentEnemy.speed = 0;
currentRock.dy = 0;
currentRock.dx = 0;
if (notputdown == i) {
mouse._y = mouse._y - 5;
mouse.dy = mouse.dy - 1;
currentX = currentRock.oX + globalX;
currentY = currentRock.oY + globalY;
dx = mouse._x - currentX;
dy = mouse._y - currentY;
currentRock.oX = currentRock.oX + dx;
currentRock.oY = currentRock.oY + (dy + 27);
notputdown = -1;
}
if (currentEnemy.health <= 1) {
if (i != notputdown) {
if (playsounds) {
explosionS.start(0, 1);
}
explosion.oX = currentEnemy.oX;
explosion.oY = currentEnemy.oY;
if (currentEnemy.tower == true) {
explosion._yscale = 200;
explosion._xscale = 100;
} else {
explosion._yscale = 65;
explosion._xscale = 65;
}
explosion.gotoAndPlay(1);
currentEnemy.oX = -1000;
currentEnemy.oY = -1000;
} else {
if (playsounds) {
explosionS.start(0, 1);
}
if (currentEnemy.tower == true) {
explosion._yscale = 200;
explosion._xscale = 100;
} else {
explosion._yscale = 65;
explosion._xscale = 65;
}
explosion.gotoAndPlay(1);
currentEnemy.oX = -1000;
currentEnemy.oY = -1000;
mouse._y = mouse._y - 5;
mouse.dy = mouse.dy - 1;
currentX = currentRock.oX + globalX;
currentY = currentRock.oY + globalY;
dx = mouse._x - currentX;
dy = mouse._y - currentY;
currentRock.oX = currentRock.oX + dx;
currentRock.oY = currentRock.oY + (dy + 27);
notputdown = -1;
}
currentEnemy.dead = true;
}
}
}
}
e++;
}
i++;
}
i = 1;
while (i <= rocks) {
if (i != notputdown) {
currentRock = eval ("rock" + i);
if (mouse.hitTest(currentRock)) {
if (mouse._y < ((currentRock._y - 25) + (mouse.dy * 1.2))) {
mouse.dy = 0;
mouse._y = (currentRock.oY + globalY) - 26;
onLand = true;
} else {
mouse.dx = mouse.dx * -1;
mouse._x = mouse._x + (mouse.dx * 2);
}
}
}
i++;
}
i = 0;
while (i <= buttons) {
currentResponder = eval ("responder" + i);
if (mouse.hitTest(currentResponder)) {
mouse.dx = mouse.dx * -1;
mouse._x = mouse._x + (mouse.dx * 2);
}
i++;
}
pressed = false;
if (Key.isDown(38)) {
if (onLand) {
mouse.dy = -2;
mouse._y = mouse._y + mouse.dy;
} else if (flightJuice > 0) {
pressed = true;
mouse.gotoAndStop("up");
mouse.dy = mouse.dy - thrust;
flightJuice = flightJuice - 1;
}
}
if (Key.isDown(40)) {
if (onLand) {
} else if (flightJuice > 0) {
pressed = true;
mouse.gotoAndStop("down");
mouse.dy = mouse.dy + thrust;
flightJuice = flightJuice - 1;
}
if (mouse.hitTest(topbarrier)) {
mouse._y = mouse._y + 7;
}
i = 0;
while (i <= lands) {
currentLand = eval ("land" + i);
if (mouse.hitTest(currentLand)) {
if (currentLand._y < (mouse._y - 5)) {
mouse._y = mouse._y + 7;
}
}
i++;
}
}
if (Key.isDown(37)) {
pressed = true;
if (onLand) {
mouse.dx = mouse.dx - thrust;
mouse.gotoAndStop("left");
} else if (flightJuice > 0) {
pressed = true;
mouse.dx = mouse.dx - thrust;
mouse.gotoAndStop("left");
flightJuice = flightJuice - 1;
}
i = 1;
while (i <= lands) {
currentLand = eval ("land" + i);
if (mouse.hitTest(currentLand)) {
if (i != onLandNum) {
if (mouse._y > currentLand._y) {
mouse._x = mouse._x - 7;
}
}
}
i++;
}
i = 1;
while (i <= rocks) {
currentRock = eval ("rock" + i);
if (mouse.hitTest(currentRock)) {
if (mouse._y > (currentRock._y - 26)) {
if (i != notputdown) {
mouse._x = mouse._x - 7;
}
}
}
i++;
}
i = 0;
while (i <= buttons) {
currentResponder = eval ("responder" + i);
if (mouse.hitTest(currentResponder)) {
mouse._x = mouse._x - 7;
}
i++;
}
if (mouse.hitTest(rightbarrier)) {
mouse._x = mouse._x - 7;
}
} else if (Key.isDown(39)) {
pressed = true;
if (onLand) {
mouse.dx = mouse.dx + thrust;
mouse.gotoAndStop("left");
} else if (flightJuice > 0) {
pressed = true;
mouse.dx = mouse.dx + thrust;
mouse.gotoAndStop("left");
flightJuice = flightJuice - 1;
}
mouse.gotoAndStop("right");
i = 1;
while (i <= lands) {
currentLand = eval ("land" + i);
if (mouse.hitTest(currentLand)) {
if (i != onLandNum) {
if (mouse._y > currentLand._y) {
mouse._x = mouse._x + 7;
}
}
}
i++;
}
i = 1;
while (i <= rocks) {
currentRock = eval ("rock" + i);
if (mouse.hitTest(currentRock)) {
if (mouse._y > (currentRock._y - 26)) {
if (i != notputdown) {
mouse._x = mouse._x + 7;
}
}
}
i++;
}
i = 0;
while (i <= buttons) {
currentResponder = eval ("responder" + i);
if (mouse.hitTest(currentResponder)) {
mouse._x = mouse._x + 7;
}
i++;
}
if (mouse.hitTest(leftbarrier)) {
mouse._x = mouse._x + 7;
}
} else if (mouse.dx < 0) {
mouse.dx = mouse.dx + thrust;
} else if (mouse.dx > 0) {
mouse.dx = mouse.dx - thrust;
}
if (mouse.dx < 0.1) {
if (mouse.dx > 0) {
mouse.dx = 0;
}
}
if (mouse.dx > -0.1) {
if (mouse.dx < 0) {
mouse.dx = 0;
}
}
if (pressed == false) {
mouse.gotoAndStop("center");
}
if (pressed == true) {
if (playsounds) {
thrustsoundpauser++;
if (thrustsoundpauser == totalforthruster) {
thruster.start(0, 1);
thrustsoundpauser = 0;
}
}
}
if (Key.isDown(32)) {
if (donePressSpace) {
donePressSpace = false;
if (notputdown == -1) {
i = 1;
while (i <= rocks) {
currentRock = eval ("rock" + i);
if (mouse.hitTest(currentRock)) {
if (playsounds) {
pickup.start(0, 1);
}
notputdown = i;
dx = mouse._x - currentRock._x;
dy = mouse._y - currentRock._y;
currentRock.oX = currentRock.oX + dx;
currentRock.oY = currentRock.oY + (dy + 27);
}
i++;
}
} else {
mouse._y = mouse._y - 5;
mouse.dy = mouse.dy - 1;
if (playsounds) {
pickup.start(0, 1);
}
currentRock = eval ("rock" + notputdown);
currentX = currentRock.oX + globalX;
currentY = currentRock.oY + globalY;
dx = mouse._x - currentX;
dy = mouse._y - currentY;
currentRock.oX = currentRock.oX + dx;
currentRock.oY = currentRock.oY + (dy + 27);
notputdown = -1;
}
}
} else {
donePressSpace = true;
}
i = 1;
while (i <= rocks) {
currentRock = eval ("rock" + i);
if (i != notputdown) {
currentRock.dy = currentRock.dy + gravity;
currentRock.oX = currentRock.oX + currentRock.dx;
currentRock.oY = currentRock.oY + currentRock.dy;
}
l = 1;
while (l <= lands) {
currentLand = eval ("land" + l);
if (currentRock.hitTest(currentLand)) {
if (currentRock._y < ((currentLand._y + currentRock.dy) + 0.5)) {
currentRock.oY = currentLand.oY;
currentRock.dy = 0;
currentRock.dx = 0;
} else if (currentRock._y > (currentLand._y + 25.5)) {
currentRock.dy = currentRock.dy * -1;
currentRock.oY = currentRock.oY + (currentRock.dy * 2);
} else {
currentRock.dx = currentRock.dx * -1;
currentRock.oX = currentRock.oX + (currentRock.dx * 4);
}
}
l++;
}
b = 1;
while (b <= rocks) {
otherRock = eval ("rock" + b);
if (b != i) {
if (currentRock.hitTest(otherRock)) {
if (currentRock.oY < otherRock.oY) {
currentRock.oY = otherRock.oY - 29;
currentRock.dy = 0;
currentRock.dx = 0;
}
}
}
b++;
}
b = 0;
while (b <= buttons) {
currentResponder = eval ("responder" + b);
if (currentRock.hitTest(currentResponder)) {
currentRock.dx = currentRock.dx * -1;
currentRock.oX = currentRock.oX + (currentRock.dx * 6);
}
b++;
}
i++;
}
i = 1;
while (i <= enemies) {
currentEnemy = eval ("enemy" + i);
if (currentEnemy.tower == false) {
if (currentEnemy.gotoLeft == true) {
if (currentEnemy.patrolPoint < currentEnemy.patrolLength) {
currentEnemy.oX = currentEnemy.oX + currentEnemy.speed;
currentEnemy.patrolPoint = currentEnemy.patrolPoint + currentEnemy.speed;
} else {
currentEnemy.gotoLeft = false;
currentEnemy.gotoAndPlay("turn");
}
} else if (currentEnemy.patrolPoint > 0) {
currentEnemy.oX = currentEnemy.oX - currentEnemy.speed;
currentEnemy.patrolPoint = currentEnemy.patrolPoint - currentEnemy.speed;
} else {
currentEnemy.gotoLeft = true;
currentEnemy.gotoAndPlay("turn");
}
}
i++;
}
i = 0;
while (i <= enemies) {
currentEnemy = eval ("enemy" + i);
if (mouse.hitTest(currentEnemy)) {
if (currentEnemy.tower == false) {
health = health - currentEnemy.damage;
}
}
if (currentEnemy.tower == true) {
currentBullet = eval ("bullet" + i);
if (mouse.hitTest(currentBullet)) {
health = health - currentEnemy.damage;
}
}
i++;
}
i = 0;
while (i <= buttons) {
currentButton = eval ("button" + i);
currentResponder = eval ("responder" + i);
hit = false;
r = 0;
while (r <= rocks) {
currentRock = eval ("rock" + r);
if (currentButton.hitTest(currentRock)) {
hit = true;
if (currentButton.pressed == false) {
currentButton.pressed = true;
currentResponder.oX = currentResponder.oX + 10000;
}
}
r++;
}
if (mousehitsbuttons == true) {
if (mouse.hitTest(currentButton)) {
hit = true;
if (currentButton.pressed == false) {
currentButton.pressed = true;
currentResponder.oX = currentResponder.oX + 10000;
}
}
}
if (hit == false) {
if (currentButton.pressed == true) {
currentButton.pressed = false;
currentResponder.oX = currentResponder.oX - 10000;
currentResponder.alpha = 0;
}
}
i++;
}
currentResponder.fadeOut = false;
currentResponder.alpha = 100;
currentResponder.speed = 6;
if (mouse.hitTest(end)) {
if (win == false) {
level++;
winS.start(0, 1);
end.gotoAndPlay("win");
win = true;
}
}
i = 0;
while (i <= enemies) {
currentTower = eval ("enemy" + i);
if (currentTower.tower == true) {
currentTop = eval ("towertop" + i);
currentBullet = eval ("bullet" + i);
currentTop._x = currentTower._x;
currentTop._y = currentTower._y - (95 * (currentTower._yscale / 100));
currentTop._yscale = currentTower._yscale;
dx = currentTop._x - mouse._x;
dy = currentTop._y - mouse._y;
radians = Math.atan(dy / dx);
degrees = (radians * 180) / Math.PI;
if (dx > 0) {
degrees = degrees + 180;
}
radians = (degrees / 180) * Math.PI;
degrees = degrees + 90;
currentTop._rotation = degrees;
distance = Math.sqrt((dx * dx) + (dy * dy));
currentTower.counter++;
if (currentTower.counter >= currentTower.counterLimit) {
currentTower.counter = 0;
currentBullet.oX = currentTower.oX;
currentBullet.oY = currentTower.oY - (95 * (currentTower._yscale / 100));
currentBullet.dx = Math.cos(radians) * currentTower.launchSpeed;
currentBullet.dy = Math.sin(radians) * currentTower.launchSpeed;
}
currentBullet.oX = currentBullet.oX + currentBullet.dx;
currentBullet.oY = currentBullet.oY + currentBullet.dy;
}
i++;
}
};
menu.onRelease = function () {
gotoAndStop ("menu");
};
currentAlpha = 100;
faderbox._alpha = currentAlpha;
fadeOut = function () {
if (loading == true) {
faderbox.gotoAndStop("blue");
}
if (loading == false) {
faderbox.gotoAndStop("red");
}
currentAlpha = currentAlpha + speed;
if (currentAlpha >= 100) {
currentAlpha = 100;
if (loading == true) {
gotoAndStop ("loading");
}
if (loading == false) {
gotoAndStop ("lose");
}
}
faderbox._x = 0;
faderbox._y = 0;
faderbox._alpha = currentAlpha;
};
fadeIn = function () {
faderbox.gotoAndStop("blue");
currentAlpha = currentAlpha - speed;
if (currentAlpha <= 0) {
currentAlpha = 0;
faderbox._x = -10000;
faderbox._y = -10000;
}
faderbox._alpha = currentAlpha;
if (health < topHealth) {
faderbox.gotoAndStop("red");
faderbox._x = 0;
faderbox._y = 0;
faderbox._alpha = (100 - (health * healthMultiplier)) - 20;
if (faderbox._alpha < 0) {
faderbox._alpha = 0;
}
currentAlpha = faderbox._alpha;
}
};
Frame 93
lands = 12;
total = 0;
rocks = 6;
objects = 5;
buttons = 3;
enemies = 8;
notputdown = -1;
health = topHealth;
healthMultiplier = 100 / health;
flightJuice = topFlightJuice;
flightMultiplier = 100 / flightJuice;
mouse.maxWidth = 62.1;
landWidth = 188;
onLandNum = 0;
globalX = 0;
globalY = 0;
win = false;
mousehitsbuttons = false;
topsmoke = 5;
smoke = 0;
thrustsoundpauser = 0;
totalforthruster = 4;
fadein = true;
loading = true;
stop();
mouse = eval (type);
mouse._x = startX._x;
mouse._y = startX._y;
startX._x = -100;
startX._y = -100;
mouse.dy = 0;
mouse.dx = 0;
mouse.oX = mouse._x;
mouse.oY = mouse._y;
explosion.oX = -10000;
explosion.oY = -10000;
leftbarrier.oX = leftbarrier._x;
leftbarrier.oY = leftbarrier._y;
rightbarrier.oX = rightbarrier._x;
rightbarrier.oY = rightbarrier._y;
topbarrier.oX = topbarrier._x;
topbarrier.oY = topbarrier._y;
bottombarrier.oX = bottombarrier._x;
bottombarrier.oY = bottombarrier._y;
end.oX = end._x;
end.oY = end._y;
enemy1.tower = false;
enemy2.tower = false;
enemy3.tower = false;
enemy4.tower = false;
enemy5.tower = true;
enemy6.tower = true;
enemy7.tower = true;
enemy8.tower = true;
i = 0;
while (i <= objects) {
currentObject = eval ("object" + i);
currentObject.oX = currentObject._x;
currentObject.oY = currentObject._y;
i++;
}
enemy1.gotoLeft = true;
i = 1;
while (i <= enemies) {
currentEnemy = eval ("enemy" + i);
currentEnemy.health = 8;
currentEnemy.speed = 2;
firstFlag = eval ("firstPatrolMarker" + i);
secondFlag = eval ("secondPatrolMarker" + i);
currentEnemy.patrolLength = secondFlag._x - firstFlag._x;
currentEnemy.patrolPoint = currentEnemy._x - firstFlag._x;
firstFlag._x = -100;
secondFlag._x = -100;
currentEnemy.damage = 1;
currentEnemy.oX = currentEnemy._x;
currentEnemy.oY = currentEnemy._y;
currentEnemy.dead = false;
currentEnemy.gotoLeft = true;
i++;
}
i = 0;
while (i <= enemies) {
currentEnemy = eval ("enemy" + i);
if (currentEnemy.tower == true) {
currentEnemy.counter = 0;
currentEnemy.counterLimit = 60;
currentEnemy.launchSpeed = 2;
currentEnemy.health = 20;
}
i++;
}
i = 0;
while (i <= buttons) {
currentButton = eval ("button" + i);
currentButton.pressed = false;
currentButton.oX = currentButton._x;
currentButton.oY = currentButton._y;
currentResponder = eval ("responder" + i);
currentResponder.oX = currentResponder._x;
currentResponder.oY = currentResponder._y;
currentResponder.fadeOut = false;
currentResponder.alpha = 100;
currentResponder.speed = 6;
i++;
}
i = 0;
while (i <= rocks) {
currentRock = eval ("rock" + i);
currentRock.oX = currentRock._x;
currentRock.oY = currentRock._y;
currentRock.dx = 0;
currentRock.dy = 0;
currentRock.originX = currentRock._x;
currentRock.originY = currentRock._y;
i++;
}
i = 0;
while (i <= lands) {
currentLand = eval ("land" + i);
currentLand.oX = currentLand._x;
currentLand.oY = currentLand._y;
i++;
}
mouse.onEnterFrame = function () {
if (fadein == true) {
fadeIn();
} else {
fadeOut();
}
mouse.dy = mouse.dy + gravity;
mouse._y = mouse._y + mouse.dy;
mouse._x = mouse._x + mouse.dx;
healthbar._xscale = health * healthMultiplier;
if (flightJuice > 0) {
flightbar._xscale = flightJuice * flightMultiplier;
}
if (health <= 0) {
fadein = false;
loading = false;
}
if (health < topHealth) {
health = health + (regenerateRate / 5);
}
if (flightJuice < topFlightJuice) {
flightJuice = flightJuice + regenerateRate;
}
dx = (Stage.width / 2) - mouse._x;
dy = (Stage.width / 2) - mouse._y;
dx = dx / 4;
dy = dy / 4;
if (mouse.dx > topspeed) {
mouse.dx = topspeed;
}
if (mouse.dx < (-topspeed)) {
mouse.dx = -topspeed;
}
if (mouse.dy > topspeed) {
mouse.dy = topspeed;
}
if (mouse.dy < (-topspeed)) {
mouse.dy = -topspeed;
}
globalX = globalX + dx;
globalY = globalY + dy;
i = 1;
while (i <= lands) {
currentLand = eval ("land" + i);
currentLand._x = currentLand.oX + globalX;
currentLand._y = currentLand.oY + globalY;
i++;
}
i = 1;
while (i <= rocks) {
currentRock = eval ("rock" + i);
currentRock._x = currentRock.oX + globalX;
currentRock._y = currentRock.oY + globalY;
i++;
}
i = 1;
while (i <= enemies) {
currentEnemy = eval ("enemy" + i);
currentEnemy._x = currentEnemy.oX + globalX;
currentEnemy._y = currentEnemy.oY + globalY;
if (currentEnemy.tower) {
currentBullet = eval ("bullet" + i);
currentBullet._x = currentBullet.oX + globalX;
currentBullet._y = currentBullet.oY + globalY;
}
i++;
}
explosion._x = explosion.oX + globalX;
explosion._y = explosion.oY + globalY;
i = 0;
while (i <= buttons) {
currentButton = eval ("button" + i);
currentResponder = eval ("responder" + i);
currentButton._x = currentButton.oX + globalX;
currentButton._y = currentButton.oY + globalY;
currentResponder._x = currentResponder.oX + globalX;
currentResponder._y = currentResponder.oY + globalY;
i++;
}
i = 0;
while (i <= objects) {
currentObject = eval ("object" + i);
currentObject._x = currentObject.oX + globalX;
currentObject._y = currentObject.oY + globalY;
i++;
}
leftbarrier._x = leftbarrier.oX + globalX;
leftbarrier._y = leftbarrier.oY + globalY;
rightbarrier._x = rightbarrier.oX + globalX;
rightbarrier._y = rightbarrier.oY + globalY;
topbarrier._x = topbarrier.oX + globalX;
topbarrier._y = topbarrier.oY + globalY;
bottombarrier._x = bottombarrier.oX + globalX;
bottombarrier._y = bottombarrier.oY + globalY;
end._x = end.oX + globalX;
end._y = end.oY + globalY;
mouse.oX = mouse.oX + dx;
mouse.oY = mouse.oY + dy;
mouse._y = mouse._y + dy;
mouse._x = mouse._x + dx;
bg._x = bg._x + (dx / 3);
bg._y = bg._y + (dy / 3);
if (notputdown != -1) {
currentRock = eval ("rock" + notputdown);
currentRock._x = mouse._x;
currentRock._y = mouse._y + 25;
currentRock.dx = mouse.dx;
currentRock.dy = mouse.dy;
}
onLand = false;
i = 1;
while (i <= lands) {
currentLand = eval ("land" + i);
if (mouse.hitTest(currentLand)) {
if (mouse._y < (currentLand._y + (mouse.dy * 1.2))) {
mouse.dy = 0;
mouse._y = currentLand._y;
onLand = true;
onLandNum = i;
} else if (mouse._y > (((currentLand._y + 35.5) + 25.4) + (mouse.dy * 1.2))) {
mouse.dy = mouse.dy * -1;
mouse._y = mouse._y + (mouse.dy * 1.5);
} else {
mouse.dx = mouse.dx * -1;
mouse._x = mouse._x + (mouse.dx * 2);
}
}
i++;
}
if (notputdown != -1) {
currentRock = eval ("rock" + notputdown);
i = 1;
while (i <= lands) {
currentLand = eval ("land" + i);
if (currentRock.hitTest(currentLand)) {
if (currentRock._y < (currentLand._y + (mouse.dy * 1.2))) {
mouse.dy = 0;
mouse._y = currentLand._y - 25;
onLand = true;
onLandNum = i;
} else if (currentRock._y > (((currentLand._y + 35) + 27) + (mouse.dy * 1.2))) {
mouse.dy = mouse.dy * -1;
mouse._y = mouse._y + (mouse.dy * 1.5);
} else {
mouse.dx = mouse.dx * -1;
mouse._x = mouse._x + (mouse.dx * 2);
}
}
i++;
}
notDropRock = eval ("rock" + notputdown);
i = 1;
while (i <= rocks) {
if (i != notputdown) {
currentRock = eval ("rock" + i);
if (notDropRock.hitTest(currentRock)) {
if (notDropRock._y < ((currentRock._y - 25) + (mouse.dy * 1.2))) {
mouse.dy = 0;
mouse._y = currentRock._y - 54;
onLand = true;
} else {
mouse.dx = mouse.dx * -1;
mouse._x = mouse._x + (mouse.dx * 2);
}
}
}
i++;
}
}
if (mouse.hitTest(leftbarrier)) {
mouse.dx = mouse.dx * -1;
mouse.oX = mouse.oX + (mouse.dx * 6);
}
if (mouse.hitTest(rightbarrier)) {
mouse.dx = mouse.dx * -1;
mouse.oX = mouse.oX + (mouse.dx * 6);
}
if (mouse.hitTest(topbarrier)) {
mouse.dy = mouse.dy * -1;
mouse.oY = mouse.oY + (mouse.dy * 6);
}
if (mouse.hitTest(bottombarrier)) {
mouse.dy = mouse.dy * -1;
mouse.oY = mouse.oY + (mouse.dy * 6);
}
i = 0;
while (i <= rocks) {
currentRock = eval ("rock" + i);
if (currentRock.hitTest(leftbarrier)) {
currentRock.dx = currentRock.dx * -1;
currentRock.oX = currentRock.oX + (currentRock.dx * 6);
}
if (currentRock.hitTest(rightbarrier)) {
currentRock.dx = currentRock.dx * -1;
currentRock.oX = currentRock.oX + (currentRock.dx * 6);
}
if (currentRock.hitTest(topbarrier)) {
currentRock.dy = currentRock.dy * -1;
currentRock.oY = currentRock.oY + (currentRock.dy * 6);
}
if (currentRock.hitTest(bottombarrier)) {
currentRock.dy = currentRock.dy * -1;
currentRock.oX = currentRock.oX + (currentRock.dy * 6);
}
i++;
}
i = 1;
while (i <= rocks) {
currentRock = eval ("rock" + i);
e = 1;
while (e <= enemies) {
currentEnemy = eval ("enemy" + e);
if (currentRock.hitTest(currentEnemy)) {
if (currentRock._y < currentEnemy._y) {
if (currentRock.dy > 0) {
if (playsounds) {
}
currentEnemy.health = currentEnemy.health - currentRock.dy;
if (currentEnemy.tower == false) {
currentEnemy._yscale = currentEnemy.health * 10;
} else {
currentEnemy._yscale = currentEnemy.health * 5;
}
currentEnemy.speed = 0;
currentRock.dy = 0;
currentRock.dx = 0;
if (notputdown == i) {
mouse._y = mouse._y - 5;
mouse.dy = mouse.dy - 1;
currentX = currentRock.oX + globalX;
currentY = currentRock.oY + globalY;
dx = mouse._x - currentX;
dy = mouse._y - currentY;
currentRock.oX = currentRock.oX + dx;
currentRock.oY = currentRock.oY + (dy + 27);
notputdown = -1;
}
if (currentEnemy.health <= 1) {
if (i != notputdown) {
if (playsounds) {
explosionS.start(0, 1);
}
explosion.oX = currentEnemy.oX;
explosion.oY = currentEnemy.oY;
if (currentEnemy.tower == true) {
explosion._yscale = 200;
explosion._xscale = 100;
} else {
explosion._yscale = 65;
explosion._xscale = 65;
}
explosion.gotoAndPlay(1);
currentEnemy.oX = -1000;
currentEnemy.oY = -1000;
} else {
if (playsounds) {
explosionS.start(0, 1);
}
if (currentEnemy.tower == true) {
explosion._yscale = 200;
explosion._xscale = 100;
} else {
explosion._yscale = 65;
explosion._xscale = 65;
}
explosion.gotoAndPlay(1);
currentEnemy.oX = -1000;
currentEnemy.oY = -1000;
mouse._y = mouse._y - 5;
mouse.dy = mouse.dy - 1;
currentX = currentRock.oX + globalX;
currentY = currentRock.oY + globalY;
dx = mouse._x - currentX;
dy = mouse._y - currentY;
currentRock.oX = currentRock.oX + dx;
currentRock.oY = currentRock.oY + (dy + 27);
notputdown = -1;
}
currentEnemy.dead = true;
}
}
}
}
e++;
}
i++;
}
i = 1;
while (i <= rocks) {
if (i != notputdown) {
currentRock = eval ("rock" + i);
if (mouse.hitTest(currentRock)) {
if (mouse._y < ((currentRock._y - 25) + (mouse.dy * 1.2))) {
mouse.dy = 0;
mouse._y = (currentRock.oY + globalY) - 26;
onLand = true;
} else {
mouse.dx = mouse.dx * -1;
mouse._x = mouse._x + (mouse.dx * 2);
}
}
}
i++;
}
i = 0;
while (i <= buttons) {
currentResponder = eval ("responder" + i);
if (mouse.hitTest(currentResponder)) {
mouse.dx = mouse.dx * -1;
mouse._x = mouse._x + (mouse.dx * 2);
}
i++;
}
pressed = false;
if (Key.isDown(38)) {
if (onLand) {
mouse.dy = -2;
mouse._y = mouse._y + mouse.dy;
} else if (flightJuice > 0) {
pressed = true;
mouse.gotoAndStop("up");
mouse.dy = mouse.dy - thrust;
flightJuice = flightJuice - 1;
}
}
if (Key.isDown(40)) {
if (onLand) {
} else if (flightJuice > 0) {
pressed = true;
mouse.gotoAndStop("down");
mouse.dy = mouse.dy + thrust;
flightJuice = flightJuice - 1;
}
if (mouse.hitTest(topbarrier)) {
mouse._y = mouse._y + 7;
}
i = 0;
while (i <= lands) {
currentLand = eval ("land" + i);
if (mouse.hitTest(currentLand)) {
if (currentLand._y < (mouse._y - 5)) {
mouse._y = mouse._y + 7;
}
}
i++;
}
}
if (Key.isDown(37)) {
pressed = true;
if (onLand) {
mouse.dx = mouse.dx - thrust;
mouse.gotoAndStop("left");
} else if (flightJuice > 0) {
pressed = true;
mouse.dx = mouse.dx - thrust;
mouse.gotoAndStop("left");
flightJuice = flightJuice - 1;
}
i = 1;
while (i <= lands) {
currentLand = eval ("land" + i);
if (mouse.hitTest(currentLand)) {
if (i != onLandNum) {
if (mouse._y > currentLand._y) {
mouse._x = mouse._x - 7;
}
}
}
i++;
}
i = 1;
while (i <= rocks) {
currentRock = eval ("rock" + i);
if (mouse.hitTest(currentRock)) {
if (mouse._y > (currentRock._y - 26)) {
if (i != notputdown) {
mouse._x = mouse._x - 7;
}
}
}
i++;
}
i = 0;
while (i <= buttons) {
currentResponder = eval ("responder" + i);
if (mouse.hitTest(currentResponder)) {
mouse._x = mouse._x - 7;
}
i++;
}
if (mouse.hitTest(rightbarrier)) {
mouse._x = mouse._x - 7;
}
} else if (Key.isDown(39)) {
pressed = true;
if (onLand) {
mouse.dx = mouse.dx + thrust;
mouse.gotoAndStop("left");
} else if (flightJuice > 0) {
pressed = true;
mouse.dx = mouse.dx + thrust;
mouse.gotoAndStop("left");
flightJuice = flightJuice - 1;
}
mouse.gotoAndStop("right");
i = 1;
while (i <= lands) {
currentLand = eval ("land" + i);
if (mouse.hitTest(currentLand)) {
if (i != onLandNum) {
if (mouse._y > currentLand._y) {
mouse._x = mouse._x + 7;
}
}
}
i++;
}
i = 1;
while (i <= rocks) {
currentRock = eval ("rock" + i);
if (mouse.hitTest(currentRock)) {
if (mouse._y > (currentRock._y - 26)) {
if (i != notputdown) {
mouse._x = mouse._x + 7;
}
}
}
i++;
}
i = 0;
while (i <= buttons) {
currentResponder = eval ("responder" + i);
if (mouse.hitTest(currentResponder)) {
mouse._x = mouse._x + 7;
}
i++;
}
if (mouse.hitTest(leftbarrier)) {
mouse._x = mouse._x + 7;
}
} else if (mouse.dx < 0) {
mouse.dx = mouse.dx + thrust;
} else if (mouse.dx > 0) {
mouse.dx = mouse.dx - thrust;
}
if (mouse.dx < 0.1) {
if (mouse.dx > 0) {
mouse.dx = 0;
}
}
if (mouse.dx > -0.1) {
if (mouse.dx < 0) {
mouse.dx = 0;
}
}
if (pressed == false) {
mouse.gotoAndStop("center");
}
if (pressed == true) {
if (playsounds) {
thrustsoundpauser++;
if (thrustsoundpauser == totalforthruster) {
thruster.start(0, 1);
thrustsoundpauser = 0;
}
}
}
if (Key.isDown(32)) {
if (donePressSpace) {
donePressSpace = false;
if (notputdown == -1) {
i = 1;
while (i <= rocks) {
currentRock = eval ("rock" + i);
if (mouse.hitTest(currentRock)) {
if (playsounds) {
pickup.start(0, 1);
}
notputdown = i;
dx = mouse._x - currentRock._x;
dy = mouse._y - currentRock._y;
currentRock.oX = currentRock.oX + dx;
currentRock.oY = currentRock.oY + (dy + 27);
}
i++;
}
} else {
mouse._y = mouse._y - 5;
mouse.dy = mouse.dy - 1;
if (playsounds) {
pickup.start(0, 1);
}
currentRock = eval ("rock" + notputdown);
currentX = currentRock.oX + globalX;
currentY = currentRock.oY + globalY;
dx = mouse._x - currentX;
dy = mouse._y - currentY;
currentRock.oX = currentRock.oX + dx;
currentRock.oY = currentRock.oY + (dy + 27);
notputdown = -1;
}
}
} else {
donePressSpace = true;
}
i = 1;
while (i <= rocks) {
currentRock = eval ("rock" + i);
if (i != notputdown) {
currentRock.dy = currentRock.dy + gravity;
currentRock.oX = currentRock.oX + currentRock.dx;
currentRock.oY = currentRock.oY + currentRock.dy;
}
l = 1;
while (l <= lands) {
currentLand = eval ("land" + l);
if (currentRock.hitTest(currentLand)) {
if (currentRock._y < ((currentLand._y + currentRock.dy) + 0.5)) {
currentRock.oY = currentLand.oY;
currentRock.dy = 0;
currentRock.dx = 0;
} else if (currentRock._y > (currentLand._y + 25.5)) {
currentRock.dy = currentRock.dy * -1;
currentRock.oY = currentRock.oY + (currentRock.dy * 2);
} else {
currentRock.dx = currentRock.dx * -1;
currentRock.oX = currentRock.oX + (currentRock.dx * 4);
}
}
l++;
}
b = 1;
while (b <= rocks) {
otherRock = eval ("rock" + b);
if (b != i) {
if (currentRock.hitTest(otherRock)) {
if (currentRock.oY < otherRock.oY) {
currentRock.oY = otherRock.oY - 29;
currentRock.dy = 0;
currentRock.dx = 0;
}
}
}
b++;
}
b = 0;
while (b <= buttons) {
currentResponder = eval ("responder" + b);
if (currentRock.hitTest(currentResponder)) {
currentRock.dx = currentRock.dx * -1;
currentRock.oX = currentRock.oX + (currentRock.dx * 6);
}
b++;
}
i++;
}
i = 1;
while (i <= enemies) {
currentEnemy = eval ("enemy" + i);
if (currentEnemy.tower == false) {
if (currentEnemy.gotoLeft == true) {
if (currentEnemy.patrolPoint < currentEnemy.patrolLength) {
currentEnemy.oX = currentEnemy.oX + currentEnemy.speed;
currentEnemy.patrolPoint = currentEnemy.patrolPoint + currentEnemy.speed;
} else {
currentEnemy.gotoLeft = false;
currentEnemy.gotoAndPlay("turn");
}
} else if (currentEnemy.patrolPoint > 0) {
currentEnemy.oX = currentEnemy.oX - currentEnemy.speed;
currentEnemy.patrolPoint = currentEnemy.patrolPoint - currentEnemy.speed;
} else {
currentEnemy.gotoLeft = true;
currentEnemy.gotoAndPlay("turn");
}
}
i++;
}
i = 0;
while (i <= enemies) {
currentEnemy = eval ("enemy" + i);
if (mouse.hitTest(currentEnemy)) {
if (currentEnemy.tower == false) {
health = health - currentEnemy.damage;
}
}
if (currentEnemy.tower == true) {
currentBullet = eval ("bullet" + i);
if (mouse.hitTest(currentBullet)) {
health = health - currentEnemy.damage;
}
}
i++;
}
i = 0;
while (i <= buttons) {
currentButton = eval ("button" + i);
currentResponder = eval ("responder" + i);
hit = false;
r = 0;
while (r <= rocks) {
currentRock = eval ("rock" + r);
if (currentButton.hitTest(currentRock)) {
hit = true;
if (currentButton.pressed == false) {
currentButton.pressed = true;
currentResponder.oX = currentResponder.oX + 10000;
}
}
r++;
}
if (mousehitsbuttons == true) {
if (mouse.hitTest(currentButton)) {
hit = true;
if (currentButton.pressed == false) {
currentButton.pressed = true;
currentResponder.oX = currentResponder.oX + 10000;
}
}
}
if (hit == false) {
if (currentButton.pressed == true) {
currentButton.pressed = false;
currentResponder.oX = currentResponder.oX - 10000;
currentResponder.alpha = 0;
}
}
i++;
}
currentResponder.fadeOut = false;
currentResponder.alpha = 100;
currentResponder.speed = 6;
if (mouse.hitTest(end)) {
if (win == false) {
level++;
winS.start(0, 1);
end.gotoAndPlay("win");
win = true;
}
}
i = 0;
while (i <= enemies) {
currentTower = eval ("enemy" + i);
if (currentTower.tower == true) {
currentTop = eval ("towertop" + i);
currentBullet = eval ("bullet" + i);
currentTop._x = currentTower._x;
currentTop._y = currentTower._y - (95 * (currentTower._yscale / 100));
currentTop._yscale = currentTower._yscale;
dx = currentTop._x - mouse._x;
dy = currentTop._y - mouse._y;
radians = Math.atan(dy / dx);
degrees = (radians * 180) / Math.PI;
if (dx > 0) {
degrees = degrees + 180;
}
radians = (degrees / 180) * Math.PI;
degrees = degrees + 90;
currentTop._rotation = degrees;
distance = Math.sqrt((dx * dx) + (dy * dy));
currentTower.counter++;
if (currentTower.counter >= currentTower.counterLimit) {
currentTower.counter = 0;
currentBullet.oX = currentTower.oX;
currentBullet.oY = currentTower.oY - (95 * (currentTower._yscale / 100));
currentBullet.dx = Math.cos(radians) * currentTower.launchSpeed;
currentBullet.dy = Math.sin(radians) * currentTower.launchSpeed;
}
currentBullet.oX = currentBullet.oX + currentBullet.dx;
currentBullet.oY = currentBullet.oY + currentBullet.dy;
}
i++;
}
};
menu.onRelease = function () {
gotoAndStop ("menu");
};
currentAlpha = 100;
faderbox._alpha = currentAlpha;
fadeOut = function () {
if (loading == true) {
faderbox.gotoAndStop("blue");
}
if (loading == false) {
faderbox.gotoAndStop("red");
}
currentAlpha = currentAlpha + speed;
if (currentAlpha >= 100) {
currentAlpha = 100;
if (loading == true) {
gotoAndStop ("loading");
}
if (loading == false) {
gotoAndStop ("lose");
}
}
faderbox._x = 0;
faderbox._y = 0;
faderbox._alpha = currentAlpha;
};
fadeIn = function () {
faderbox.gotoAndStop("blue");
currentAlpha = currentAlpha - speed;
if (currentAlpha <= 0) {
currentAlpha = 0;
faderbox._x = -10000;
faderbox._y = -10000;
}
faderbox._alpha = currentAlpha;
if (health < topHealth) {
faderbox.gotoAndStop("red");
faderbox._x = 0;
faderbox._y = 0;
faderbox._alpha = (100 - (health * healthMultiplier)) - 20;
if (faderbox._alpha < 0) {
faderbox._alpha = 0;
}
currentAlpha = faderbox._alpha;
}
};
Frame 94
lands = 12;
total = 0;
rocks = 6;
objects = 5;
buttons = 3;
enemies = 8;
notputdown = -1;
health = topHealth;
healthMultiplier = 100 / health;
flightJuice = topFlightJuice;
flightMultiplier = 100 / flightJuice;
mouse.maxWidth = 62.1;
landWidth = 188;
onLandNum = 0;
globalX = 0;
globalY = 0;
win = false;
mousehitsbuttons = false;
topsmoke = 5;
smoke = 0;
thrustsoundpauser = 0;
totalforthruster = 4;
fadein = true;
loading = true;
stop();
mouse = eval (type);
mouse._x = startX._x;
mouse._y = startX._y;
startX._x = -100;
startX._y = -100;
mouse.dy = 0;
mouse.dx = 0;
mouse.oX = mouse._x;
mouse.oY = mouse._y;
explosion.oX = -10000;
explosion.oY = -10000;
leftbarrier.oX = leftbarrier._x;
leftbarrier.oY = leftbarrier._y;
rightbarrier.oX = rightbarrier._x;
rightbarrier.oY = rightbarrier._y;
topbarrier.oX = topbarrier._x;
topbarrier.oY = topbarrier._y;
bottombarrier.oX = bottombarrier._x;
bottombarrier.oY = bottombarrier._y;
end.oX = end._x;
end.oY = end._y;
enemy1.tower = false;
enemy2.tower = false;
enemy3.tower = false;
enemy4.tower = false;
enemy5.tower = true;
enemy6.tower = true;
enemy7.tower = true;
enemy8.tower = true;
i = 0;
while (i <= objects) {
currentObject = eval ("object" + i);
currentObject.oX = currentObject._x;
currentObject.oY = currentObject._y;
i++;
}
enemy1.gotoLeft = true;
i = 1;
while (i <= enemies) {
currentEnemy = eval ("enemy" + i);
currentEnemy.health = 8;
currentEnemy.speed = 2;
firstFlag = eval ("firstPatrolMarker" + i);
secondFlag = eval ("secondPatrolMarker" + i);
currentEnemy.patrolLength = secondFlag._x - firstFlag._x;
currentEnemy.patrolPoint = currentEnemy._x - firstFlag._x;
firstFlag._x = -100;
secondFlag._x = -100;
currentEnemy.damage = 1;
currentEnemy.oX = currentEnemy._x;
currentEnemy.oY = currentEnemy._y;
currentEnemy.dead = false;
currentEnemy.gotoLeft = true;
i++;
}
i = 0;
while (i <= enemies) {
currentEnemy = eval ("enemy" + i);
if (currentEnemy.tower == true) {
currentEnemy.counter = 0;
currentEnemy.counterLimit = 60;
currentEnemy.launchSpeed = 2;
currentEnemy.health = 20;
}
i++;
}
i = 0;
while (i <= buttons) {
currentButton = eval ("button" + i);
currentButton.pressed = false;
currentButton.oX = currentButton._x;
currentButton.oY = currentButton._y;
currentResponder = eval ("responder" + i);
currentResponder.oX = currentResponder._x;
currentResponder.oY = currentResponder._y;
currentResponder.fadeOut = false;
currentResponder.alpha = 100;
currentResponder.speed = 6;
i++;
}
i = 0;
while (i <= rocks) {
currentRock = eval ("rock" + i);
currentRock.oX = currentRock._x;
currentRock.oY = currentRock._y;
currentRock.dx = 0;
currentRock.dy = 0;
currentRock.originX = currentRock._x;
currentRock.originY = currentRock._y;
i++;
}
i = 0;
while (i <= lands) {
currentLand = eval ("land" + i);
currentLand.oX = currentLand._x;
currentLand.oY = currentLand._y;
i++;
}
mouse.onEnterFrame = function () {
if (fadein == true) {
fadeIn();
} else {
fadeOut();
}
mouse.dy = mouse.dy + gravity;
mouse._y = mouse._y + mouse.dy;
mouse._x = mouse._x + mouse.dx;
healthbar._xscale = health * healthMultiplier;
if (flightJuice > 0) {
flightbar._xscale = flightJuice * flightMultiplier;
}
if (health <= 0) {
fadein = false;
loading = false;
}
if (health < topHealth) {
health = health + (regenerateRate / 5);
}
if (flightJuice < topFlightJuice) {
flightJuice = flightJuice + regenerateRate;
}
dx = (Stage.width / 2) - mouse._x;
dy = (Stage.width / 2) - mouse._y;
dx = dx / 4;
dy = dy / 4;
if (mouse.dx > topspeed) {
mouse.dx = topspeed;
}
if (mouse.dx < (-topspeed)) {
mouse.dx = -topspeed;
}
if (mouse.dy > topspeed) {
mouse.dy = topspeed;
}
if (mouse.dy < (-topspeed)) {
mouse.dy = -topspeed;
}
globalX = globalX + dx;
globalY = globalY + dy;
i = 1;
while (i <= lands) {
currentLand = eval ("land" + i);
currentLand._x = currentLand.oX + globalX;
currentLand._y = currentLand.oY + globalY;
i++;
}
i = 1;
while (i <= rocks) {
currentRock = eval ("rock" + i);
currentRock._x = currentRock.oX + globalX;
currentRock._y = currentRock.oY + globalY;
i++;
}
i = 1;
while (i <= enemies) {
currentEnemy = eval ("enemy" + i);
currentEnemy._x = currentEnemy.oX + globalX;
currentEnemy._y = currentEnemy.oY + globalY;
if (currentEnemy.tower) {
currentBullet = eval ("bullet" + i);
currentBullet._x = currentBullet.oX + globalX;
currentBullet._y = currentBullet.oY + globalY;
}
i++;
}
explosion._x = explosion.oX + globalX;
explosion._y = explosion.oY + globalY;
i = 0;
while (i <= buttons) {
currentButton = eval ("button" + i);
currentResponder = eval ("responder" + i);
currentButton._x = currentButton.oX + globalX;
currentButton._y = currentButton.oY + globalY;
currentResponder._x = currentResponder.oX + globalX;
currentResponder._y = currentResponder.oY + globalY;
i++;
}
i = 0;
while (i <= objects) {
currentObject = eval ("object" + i);
currentObject._x = currentObject.oX + globalX;
currentObject._y = currentObject.oY + globalY;
i++;
}
leftbarrier._x = leftbarrier.oX + globalX;
leftbarrier._y = leftbarrier.oY + globalY;
rightbarrier._x = rightbarrier.oX + globalX;
rightbarrier._y = rightbarrier.oY + globalY;
topbarrier._x = topbarrier.oX + globalX;
topbarrier._y = topbarrier.oY + globalY;
bottombarrier._x = bottombarrier.oX + globalX;
bottombarrier._y = bottombarrier.oY + globalY;
end._x = end.oX + globalX;
end._y = end.oY + globalY;
mouse.oX = mouse.oX + dx;
mouse.oY = mouse.oY + dy;
mouse._y = mouse._y + dy;
mouse._x = mouse._x + dx;
bg._x = bg._x + (dx / 3);
bg._y = bg._y + (dy / 3);
if (notputdown != -1) {
currentRock = eval ("rock" + notputdown);
currentRock._x = mouse._x;
currentRock._y = mouse._y + 25;
currentRock.dx = mouse.dx;
currentRock.dy = mouse.dy;
}
onLand = false;
i = 1;
while (i <= lands) {
currentLand = eval ("land" + i);
if (mouse.hitTest(currentLand)) {
if (mouse._y < (currentLand._y + (mouse.dy * 1.2))) {
mouse.dy = 0;
mouse._y = currentLand._y;
onLand = true;
onLandNum = i;
} else if (mouse._y > (((currentLand._y + 35.5) + 25.4) + (mouse.dy * 1.2))) {
mouse.dy = mouse.dy * -1;
mouse._y = mouse._y + (mouse.dy * 1.5);
} else {
mouse.dx = mouse.dx * -1;
mouse._x = mouse._x + (mouse.dx * 2);
}
}
i++;
}
if (notputdown != -1) {
currentRock = eval ("rock" + notputdown);
i = 1;
while (i <= lands) {
currentLand = eval ("land" + i);
if (currentRock.hitTest(currentLand)) {
if (currentRock._y < (currentLand._y + (mouse.dy * 1.2))) {
mouse.dy = 0;
mouse._y = currentLand._y - 25;
onLand = true;
onLandNum = i;
} else if (currentRock._y > (((currentLand._y + 35) + 27) + (mouse.dy * 1.2))) {
mouse.dy = mouse.dy * -1;
mouse._y = mouse._y + (mouse.dy * 1.5);
} else {
mouse.dx = mouse.dx * -1;
mouse._x = mouse._x + (mouse.dx * 2);
}
}
i++;
}
notDropRock = eval ("rock" + notputdown);
i = 1;
while (i <= rocks) {
if (i != notputdown) {
currentRock = eval ("rock" + i);
if (notDropRock.hitTest(currentRock)) {
if (notDropRock._y < ((currentRock._y - 25) + (mouse.dy * 1.2))) {
mouse.dy = 0;
mouse._y = currentRock._y - 54;
onLand = true;
} else {
mouse.dx = mouse.dx * -1;
mouse._x = mouse._x + (mouse.dx * 2);
}
}
}
i++;
}
}
if (mouse.hitTest(leftbarrier)) {
mouse.dx = mouse.dx * -1;
mouse.oX = mouse.oX + (mouse.dx * 6);
}
if (mouse.hitTest(rightbarrier)) {
mouse.dx = mouse.dx * -1;
mouse.oX = mouse.oX + (mouse.dx * 6);
}
if (mouse.hitTest(topbarrier)) {
mouse.dy = mouse.dy * -1;
mouse.oY = mouse.oY + (mouse.dy * 6);
}
if (mouse.hitTest(bottombarrier)) {
mouse.dy = mouse.dy * -1;
mouse.oY = mouse.oY + (mouse.dy * 6);
}
i = 0;
while (i <= rocks) {
currentRock = eval ("rock" + i);
if (currentRock.hitTest(leftbarrier)) {
currentRock.dx = currentRock.dx * -1;
currentRock.oX = currentRock.oX + (currentRock.dx * 6);
}
if (currentRock.hitTest(rightbarrier)) {
currentRock.dx = currentRock.dx * -1;
currentRock.oX = currentRock.oX + (currentRock.dx * 6);
}
if (currentRock.hitTest(topbarrier)) {
currentRock.dy = currentRock.dy * -1;
currentRock.oY = currentRock.oY + (currentRock.dy * 6);
}
if (currentRock.hitTest(bottombarrier)) {
currentRock.dy = currentRock.dy * -1;
currentRock.oX = currentRock.oX + (currentRock.dy * 6);
}
i++;
}
i = 1;
while (i <= rocks) {
currentRock = eval ("rock" + i);
e = 1;
while (e <= enemies) {
currentEnemy = eval ("enemy" + e);
if (currentRock.hitTest(currentEnemy)) {
if (currentRock._y < currentEnemy._y) {
if (currentRock.dy > 0) {
if (playsounds) {
}
currentEnemy.health = currentEnemy.health - currentRock.dy;
if (currentEnemy.tower == false) {
currentEnemy._yscale = currentEnemy.health * 10;
} else {
currentEnemy._yscale = currentEnemy.health * 5;
}
currentEnemy.speed = 0;
currentRock.dy = 0;
currentRock.dx = 0;
if (notputdown == i) {
mouse._y = mouse._y - 5;
mouse.dy = mouse.dy - 1;
currentX = currentRock.oX + globalX;
currentY = currentRock.oY + globalY;
dx = mouse._x - currentX;
dy = mouse._y - currentY;
currentRock.oX = currentRock.oX + dx;
currentRock.oY = currentRock.oY + (dy + 27);
notputdown = -1;
}
if (currentEnemy.health <= 1) {
if (i != notputdown) {
if (playsounds) {
explosionS.start(0, 1);
}
explosion.oX = currentEnemy.oX;
explosion.oY = currentEnemy.oY;
if (currentEnemy.tower == true) {
explosion._yscale = 200;
explosion._xscale = 100;
} else {
explosion._yscale = 65;
explosion._xscale = 65;
}
explosion.gotoAndPlay(1);
currentEnemy.oX = -1000;
currentEnemy.oY = -1000;
} else {
if (playsounds) {
explosionS.start(0, 1);
}
if (currentEnemy.tower == true) {
explosion._yscale = 200;
explosion._xscale = 100;
} else {
explosion._yscale = 65;
explosion._xscale = 65;
}
explosion.gotoAndPlay(1);
currentEnemy.oX = -1000;
currentEnemy.oY = -1000;
mouse._y = mouse._y - 5;
mouse.dy = mouse.dy - 1;
currentX = currentRock.oX + globalX;
currentY = currentRock.oY + globalY;
dx = mouse._x - currentX;
dy = mouse._y - currentY;
currentRock.oX = currentRock.oX + dx;
currentRock.oY = currentRock.oY + (dy + 27);
notputdown = -1;
}
currentEnemy.dead = true;
}
}
}
}
e++;
}
i++;
}
i = 1;
while (i <= rocks) {
if (i != notputdown) {
currentRock = eval ("rock" + i);
if (mouse.hitTest(currentRock)) {
if (mouse._y < ((currentRock._y - 25) + (mouse.dy * 1.2))) {
mouse.dy = 0;
mouse._y = (currentRock.oY + globalY) - 26;
onLand = true;
} else {
mouse.dx = mouse.dx * -1;
mouse._x = mouse._x + (mouse.dx * 2);
}
}
}
i++;
}
i = 0;
while (i <= buttons) {
currentResponder = eval ("responder" + i);
if (mouse.hitTest(currentResponder)) {
mouse.dx = mouse.dx * -1;
mouse._x = mouse._x + (mouse.dx * 2);
}
i++;
}
pressed = false;
if (Key.isDown(38)) {
if (onLand) {
mouse.dy = -2;
mouse._y = mouse._y + mouse.dy;
} else if (flightJuice > 0) {
pressed = true;
mouse.gotoAndStop("up");
mouse.dy = mouse.dy - thrust;
flightJuice = flightJuice - 1;
}
}
if (Key.isDown(40)) {
if (onLand) {
} else if (flightJuice > 0) {
pressed = true;
mouse.gotoAndStop("down");
mouse.dy = mouse.dy + thrust;
flightJuice = flightJuice - 1;
}
if (mouse.hitTest(topbarrier)) {
mouse._y = mouse._y + 7;
}
i = 0;
while (i <= lands) {
currentLand = eval ("land" + i);
if (mouse.hitTest(currentLand)) {
if (currentLand._y < (mouse._y - 5)) {
mouse._y = mouse._y + 7;
}
}
i++;
}
}
if (Key.isDown(37)) {
pressed = true;
if (onLand) {
mouse.dx = mouse.dx - thrust;
mouse.gotoAndStop("left");
} else if (flightJuice > 0) {
pressed = true;
mouse.dx = mouse.dx - thrust;
mouse.gotoAndStop("left");
flightJuice = flightJuice - 1;
}
i = 1;
while (i <= lands) {
currentLand = eval ("land" + i);
if (mouse.hitTest(currentLand)) {
if (i != onLandNum) {
if (mouse._y > currentLand._y) {
mouse._x = mouse._x - 7;
}
}
}
i++;
}
i = 1;
while (i <= rocks) {
currentRock = eval ("rock" + i);
if (mouse.hitTest(currentRock)) {
if (mouse._y > (currentRock._y - 26)) {
if (i != notputdown) {
mouse._x = mouse._x - 7;
}
}
}
i++;
}
i = 0;
while (i <= buttons) {
currentResponder = eval ("responder" + i);
if (mouse.hitTest(currentResponder)) {
mouse._x = mouse._x - 7;
}
i++;
}
if (mouse.hitTest(rightbarrier)) {
mouse._x = mouse._x - 7;
}
} else if (Key.isDown(39)) {
pressed = true;
if (onLand) {
mouse.dx = mouse.dx + thrust;
mouse.gotoAndStop("left");
} else if (flightJuice > 0) {
pressed = true;
mouse.dx = mouse.dx + thrust;
mouse.gotoAndStop("left");
flightJuice = flightJuice - 1;
}
mouse.gotoAndStop("right");
i = 1;
while (i <= lands) {
currentLand = eval ("land" + i);
if (mouse.hitTest(currentLand)) {
if (i != onLandNum) {
if (mouse._y > currentLand._y) {
mouse._x = mouse._x + 7;
}
}
}
i++;
}
i = 1;
while (i <= rocks) {
currentRock = eval ("rock" + i);
if (mouse.hitTest(currentRock)) {
if (mouse._y > (currentRock._y - 26)) {
if (i != notputdown) {
mouse._x = mouse._x + 7;
}
}
}
i++;
}
i = 0;
while (i <= buttons) {
currentResponder = eval ("responder" + i);
if (mouse.hitTest(currentResponder)) {
mouse._x = mouse._x + 7;
}
i++;
}
if (mouse.hitTest(leftbarrier)) {
mouse._x = mouse._x + 7;
}
} else if (mouse.dx < 0) {
mouse.dx = mouse.dx + thrust;
} else if (mouse.dx > 0) {
mouse.dx = mouse.dx - thrust;
}
if (mouse.dx < 0.1) {
if (mouse.dx > 0) {
mouse.dx = 0;
}
}
if (mouse.dx > -0.1) {
if (mouse.dx < 0) {
mouse.dx = 0;
}
}
if (pressed == false) {
mouse.gotoAndStop("center");
}
if (pressed == true) {
if (playsounds) {
thrustsoundpauser++;
if (thrustsoundpauser == totalforthruster) {
thruster.start(0, 1);
thrustsoundpauser = 0;
}
}
}
if (Key.isDown(32)) {
if (donePressSpace) {
donePressSpace = false;
if (notputdown == -1) {
i = 1;
while (i <= rocks) {
currentRock = eval ("rock" + i);
if (mouse.hitTest(currentRock)) {
if (playsounds) {
pickup.start(0, 1);
}
notputdown = i;
dx = mouse._x - currentRock._x;
dy = mouse._y - currentRock._y;
currentRock.oX = currentRock.oX + dx;
currentRock.oY = currentRock.oY + (dy + 27);
}
i++;
}
} else {
mouse._y = mouse._y - 5;
mouse.dy = mouse.dy - 1;
if (playsounds) {
pickup.start(0, 1);
}
currentRock = eval ("rock" + notputdown);
currentX = currentRock.oX + globalX;
currentY = currentRock.oY + globalY;
dx = mouse._x - currentX;
dy = mouse._y - currentY;
currentRock.oX = currentRock.oX + dx;
currentRock.oY = currentRock.oY + (dy + 27);
notputdown = -1;
}
}
} else {
donePressSpace = true;
}
i = 1;
while (i <= rocks) {
currentRock = eval ("rock" + i);
if (i != notputdown) {
currentRock.dy = currentRock.dy + gravity;
currentRock.oX = currentRock.oX + currentRock.dx;
currentRock.oY = currentRock.oY + currentRock.dy;
}
l = 1;
while (l <= lands) {
currentLand = eval ("land" + l);
if (currentRock.hitTest(currentLand)) {
if (currentRock._y < ((currentLand._y + currentRock.dy) + 0.5)) {
currentRock.oY = currentLand.oY;
currentRock.dy = 0;
currentRock.dx = 0;
} else if (currentRock._y > (currentLand._y + 25.5)) {
currentRock.dy = currentRock.dy * -1;
currentRock.oY = currentRock.oY + (currentRock.dy * 2);
} else {
currentRock.dx = currentRock.dx * -1;
currentRock.oX = currentRock.oX + (currentRock.dx * 4);
}
}
l++;
}
b = 1;
while (b <= rocks) {
otherRock = eval ("rock" + b);
if (b != i) {
if (currentRock.hitTest(otherRock)) {
if (currentRock.oY < otherRock.oY) {
currentRock.oY = otherRock.oY - 29;
currentRock.dy = 0;
currentRock.dx = 0;
}
}
}
b++;
}
b = 0;
while (b <= buttons) {
currentResponder = eval ("responder" + b);
if (currentRock.hitTest(currentResponder)) {
currentRock.dx = currentRock.dx * -1;
currentRock.oX = currentRock.oX + (currentRock.dx * 6);
}
b++;
}
i++;
}
i = 1;
while (i <= enemies) {
currentEnemy = eval ("enemy" + i);
if (currentEnemy.tower == false) {
if (currentEnemy.gotoLeft == true) {
if (currentEnemy.patrolPoint < currentEnemy.patrolLength) {
currentEnemy.oX = currentEnemy.oX + currentEnemy.speed;
currentEnemy.patrolPoint = currentEnemy.patrolPoint + currentEnemy.speed;
} else {
currentEnemy.gotoLeft = false;
currentEnemy.gotoAndPlay("turn");
}
} else if (currentEnemy.patrolPoint > 0) {
currentEnemy.oX = currentEnemy.oX - currentEnemy.speed;
currentEnemy.patrolPoint = currentEnemy.patrolPoint - currentEnemy.speed;
} else {
currentEnemy.gotoLeft = true;
currentEnemy.gotoAndPlay("turn");
}
}
i++;
}
i = 0;
while (i <= enemies) {
currentEnemy = eval ("enemy" + i);
if (mouse.hitTest(currentEnemy)) {
if (currentEnemy.tower == false) {
health = health - currentEnemy.damage;
}
}
if (currentEnemy.tower == true) {
currentBullet = eval ("bullet" + i);
if (mouse.hitTest(currentBullet)) {
health = health - currentEnemy.damage;
}
}
i++;
}
i = 0;
while (i <= buttons) {
currentButton = eval ("button" + i);
currentResponder = eval ("responder" + i);
hit = false;
r = 0;
while (r <= rocks) {
currentRock = eval ("rock" + r);
if (currentButton.hitTest(currentRock)) {
hit = true;
if (currentButton.pressed == false) {
currentButton.pressed = true;
currentResponder.oX = currentResponder.oX + 10000;
}
}
r++;
}
if (mousehitsbuttons == true) {
if (mouse.hitTest(currentButton)) {
hit = true;
if (currentButton.pressed == false) {
currentButton.pressed = true;
currentResponder.oX = currentResponder.oX + 10000;
}
}
}
if (hit == false) {
if (currentButton.pressed == true) {
currentButton.pressed = false;
currentResponder.oX = currentResponder.oX - 10000;
currentResponder.alpha = 0;
}
}
i++;
}
currentResponder.fadeOut = false;
currentResponder.alpha = 100;
currentResponder.speed = 6;
if (mouse.hitTest(end)) {
if (win == false) {
level++;
winS.start(0, 1);
end.gotoAndPlay("win");
win = true;
}
}
i = 0;
while (i <= enemies) {
currentTower = eval ("enemy" + i);
if (currentTower.tower == true) {
currentTop = eval ("towertop" + i);
currentBullet = eval ("bullet" + i);
currentTop._x = currentTower._x;
currentTop._y = currentTower._y - (95 * (currentTower._yscale / 100));
currentTop._yscale = currentTower._yscale;
dx = currentTop._x - mouse._x;
dy = currentTop._y - mouse._y;
radians = Math.atan(dy / dx);
degrees = (radians * 180) / Math.PI;
if (dx > 0) {
degrees = degrees + 180;
}
radians = (degrees / 180) * Math.PI;
degrees = degrees + 90;
currentTop._rotation = degrees;
distance = Math.sqrt((dx * dx) + (dy * dy));
currentTower.counter++;
if (currentTower.counter >= currentTower.counterLimit) {
currentTower.counter = 0;
currentBullet.oX = currentTower.oX;
currentBullet.oY = currentTower.oY - (95 * (currentTower._yscale / 100));
currentBullet.dx = Math.cos(radians) * currentTower.launchSpeed;
currentBullet.dy = Math.sin(radians) * currentTower.launchSpeed;
}
currentBullet.oX = currentBullet.oX + currentBullet.dx;
currentBullet.oY = currentBullet.oY + currentBullet.dy;
}
i++;
}
};
menu.onRelease = function () {
gotoAndStop ("menu");
};
currentAlpha = 100;
faderbox._alpha = currentAlpha;
fadeOut = function () {
if (loading == true) {
faderbox.gotoAndStop("blue");
}
if (loading == false) {
faderbox.gotoAndStop("red");
}
currentAlpha = currentAlpha + speed;
if (currentAlpha >= 100) {
currentAlpha = 100;
if (loading == true) {
gotoAndStop ("loading");
}
if (loading == false) {
gotoAndStop ("lose");
}
}
faderbox._x = 0;
faderbox._y = 0;
faderbox._alpha = currentAlpha;
};
fadeIn = function () {
faderbox.gotoAndStop("blue");
currentAlpha = currentAlpha - speed;
if (currentAlpha <= 0) {
currentAlpha = 0;
faderbox._x = -10000;
faderbox._y = -10000;
}
faderbox._alpha = currentAlpha;
if (health < topHealth) {
faderbox.gotoAndStop("red");
faderbox._x = 0;
faderbox._y = 0;
faderbox._alpha = (100 - (health * healthMultiplier)) - 20;
if (faderbox._alpha < 0) {
faderbox._alpha = 0;
}
currentAlpha = faderbox._alpha;
}
};
Frame 95
lands = 12;
total = 0;
rocks = 6;
objects = 5;
buttons = 3;
enemies = 8;
notputdown = -1;
health = topHealth;
healthMultiplier = 100 / health;
flightJuice = topFlightJuice;
flightMultiplier = 100 / flightJuice;
mouse.maxWidth = 62.1;
landWidth = 188;
onLandNum = 0;
globalX = 0;
globalY = 0;
win = false;
mousehitsbuttons = false;
topsmoke = 5;
smoke = 0;
thrustsoundpauser = 0;
totalforthruster = 4;
fadein = true;
loading = true;
stop();
mouse = eval (type);
mouse._x = startX._x;
mouse._y = startX._y;
startX._x = -100;
startX._y = -100;
mouse.dy = 0;
mouse.dx = 0;
mouse.oX = mouse._x;
mouse.oY = mouse._y;
explosion.oX = -10000;
explosion.oY = -10000;
leftbarrier.oX = leftbarrier._x;
leftbarrier.oY = leftbarrier._y;
rightbarrier.oX = rightbarrier._x;
rightbarrier.oY = rightbarrier._y;
topbarrier.oX = topbarrier._x;
topbarrier.oY = topbarrier._y;
bottombarrier.oX = bottombarrier._x;
bottombarrier.oY = bottombarrier._y;
end.oX = end._x;
end.oY = end._y;
enemy1.tower = false;
enemy2.tower = false;
enemy3.tower = false;
enemy4.tower = false;
enemy5.tower = true;
enemy6.tower = true;
enemy7.tower = true;
enemy8.tower = true;
i = 0;
while (i <= objects) {
currentObject = eval ("object" + i);
currentObject.oX = currentObject._x;
currentObject.oY = currentObject._y;
i++;
}
enemy1.gotoLeft = true;
i = 1;
while (i <= enemies) {
currentEnemy = eval ("enemy" + i);
currentEnemy.health = 8;
currentEnemy.speed = 2;
firstFlag = eval ("firstPatrolMarker" + i);
secondFlag = eval ("secondPatrolMarker" + i);
currentEnemy.patrolLength = secondFlag._x - firstFlag._x;
currentEnemy.patrolPoint = currentEnemy._x - firstFlag._x;
firstFlag._x = -100;
secondFlag._x = -100;
currentEnemy.damage = 1;
currentEnemy.oX = currentEnemy._x;
currentEnemy.oY = currentEnemy._y;
currentEnemy.dead = false;
currentEnemy.gotoLeft = true;
i++;
}
i = 0;
while (i <= enemies) {
currentEnemy = eval ("enemy" + i);
if (currentEnemy.tower == true) {
currentEnemy.counter = 0;
currentEnemy.counterLimit = 60;
currentEnemy.launchSpeed = 2;
currentEnemy.health = 20;
}
i++;
}
i = 0;
while (i <= buttons) {
currentButton = eval ("button" + i);
currentButton.pressed = false;
currentButton.oX = currentButton._x;
currentButton.oY = currentButton._y;
currentResponder = eval ("responder" + i);
currentResponder.oX = currentResponder._x;
currentResponder.oY = currentResponder._y;
currentResponder.fadeOut = false;
currentResponder.alpha = 100;
currentResponder.speed = 6;
i++;
}
i = 0;
while (i <= rocks) {
currentRock = eval ("rock" + i);
currentRock.oX = currentRock._x;
currentRock.oY = currentRock._y;
currentRock.dx = 0;
currentRock.dy = 0;
currentRock.originX = currentRock._x;
currentRock.originY = currentRock._y;
i++;
}
i = 0;
while (i <= lands) {
currentLand = eval ("land" + i);
currentLand.oX = currentLand._x;
currentLand.oY = currentLand._y;
i++;
}
mouse.onEnterFrame = function () {
if (fadein == true) {
fadeIn();
} else {
fadeOut();
}
mouse.dy = mouse.dy + gravity;
mouse._y = mouse._y + mouse.dy;
mouse._x = mouse._x + mouse.dx;
healthbar._xscale = health * healthMultiplier;
if (flightJuice > 0) {
flightbar._xscale = flightJuice * flightMultiplier;
}
if (health <= 0) {
fadein = false;
loading = false;
}
if (health < topHealth) {
health = health + (regenerateRate / 5);
}
if (flightJuice < topFlightJuice) {
flightJuice = flightJuice + regenerateRate;
}
dx = (Stage.width / 2) - mouse._x;
dy = (Stage.width / 2) - mouse._y;
dx = dx / 4;
dy = dy / 4;
if (mouse.dx > topspeed) {
mouse.dx = topspeed;
}
if (mouse.dx < (-topspeed)) {
mouse.dx = -topspeed;
}
if (mouse.dy > topspeed) {
mouse.dy = topspeed;
}
if (mouse.dy < (-topspeed)) {
mouse.dy = -topspeed;
}
globalX = globalX + dx;
globalY = globalY + dy;
i = 1;
while (i <= lands) {
currentLand = eval ("land" + i);
currentLand._x = currentLand.oX + globalX;
currentLand._y = currentLand.oY + globalY;
i++;
}
i = 1;
while (i <= rocks) {
currentRock = eval ("rock" + i);
currentRock._x = currentRock.oX + globalX;
currentRock._y = currentRock.oY + globalY;
i++;
}
i = 1;
while (i <= enemies) {
currentEnemy = eval ("enemy" + i);
currentEnemy._x = currentEnemy.oX + globalX;
currentEnemy._y = currentEnemy.oY + globalY;
if (currentEnemy.tower) {
currentBullet = eval ("bullet" + i);
currentBullet._x = currentBullet.oX + globalX;
currentBullet._y = currentBullet.oY + globalY;
}
i++;
}
explosion._x = explosion.oX + globalX;
explosion._y = explosion.oY + globalY;
i = 0;
while (i <= buttons) {
currentButton = eval ("button" + i);
currentResponder = eval ("responder" + i);
currentButton._x = currentButton.oX + globalX;
currentButton._y = currentButton.oY + globalY;
currentResponder._x = currentResponder.oX + globalX;
currentResponder._y = currentResponder.oY + globalY;
i++;
}
i = 0;
while (i <= objects) {
currentObject = eval ("object" + i);
currentObject._x = currentObject.oX + globalX;
currentObject._y = currentObject.oY + globalY;
i++;
}
leftbarrier._x = leftbarrier.oX + globalX;
leftbarrier._y = leftbarrier.oY + globalY;
rightbarrier._x = rightbarrier.oX + globalX;
rightbarrier._y = rightbarrier.oY + globalY;
topbarrier._x = topbarrier.oX + globalX;
topbarrier._y = topbarrier.oY + globalY;
bottombarrier._x = bottombarrier.oX + globalX;
bottombarrier._y = bottombarrier.oY + globalY;
end._x = end.oX + globalX;
end._y = end.oY + globalY;
mouse.oX = mouse.oX + dx;
mouse.oY = mouse.oY + dy;
mouse._y = mouse._y + dy;
mouse._x = mouse._x + dx;
bg._x = bg._x + (dx / 3);
bg._y = bg._y + (dy / 3);
if (notputdown != -1) {
currentRock = eval ("rock" + notputdown);
currentRock._x = mouse._x;
currentRock._y = mouse._y + 25;
currentRock.dx = mouse.dx;
currentRock.dy = mouse.dy;
}
onLand = false;
i = 1;
while (i <= lands) {
currentLand = eval ("land" + i);
if (mouse.hitTest(currentLand)) {
if (mouse._y < (currentLand._y + (mouse.dy * 1.2))) {
mouse.dy = 0;
mouse._y = currentLand._y;
onLand = true;
onLandNum = i;
} else if (mouse._y > (((currentLand._y + 35.5) + 25.4) + (mouse.dy * 1.2))) {
mouse.dy = mouse.dy * -1;
mouse._y = mouse._y + (mouse.dy * 1.5);
} else {
mouse.dx = mouse.dx * -1;
mouse._x = mouse._x + (mouse.dx * 2);
}
}
i++;
}
if (notputdown != -1) {
currentRock = eval ("rock" + notputdown);
i = 1;
while (i <= lands) {
currentLand = eval ("land" + i);
if (currentRock.hitTest(currentLand)) {
if (currentRock._y < (currentLand._y + (mouse.dy * 1.2))) {
mouse.dy = 0;
mouse._y = currentLand._y - 25;
onLand = true;
onLandNum = i;
} else if (currentRock._y > (((currentLand._y + 35) + 27) + (mouse.dy * 1.2))) {
mouse.dy = mouse.dy * -1;
mouse._y = mouse._y + (mouse.dy * 1.5);
} else {
mouse.dx = mouse.dx * -1;
mouse._x = mouse._x + (mouse.dx * 2);
}
}
i++;
}
notDropRock = eval ("rock" + notputdown);
i = 1;
while (i <= rocks) {
if (i != notputdown) {
currentRock = eval ("rock" + i);
if (notDropRock.hitTest(currentRock)) {
if (notDropRock._y < ((currentRock._y - 25) + (mouse.dy * 1.2))) {
mouse.dy = 0;
mouse._y = currentRock._y - 54;
onLand = true;
} else {
mouse.dx = mouse.dx * -1;
mouse._x = mouse._x + (mouse.dx * 2);
}
}
}
i++;
}
}
if (mouse.hitTest(leftbarrier)) {
mouse.dx = mouse.dx * -1;
mouse.oX = mouse.oX + (mouse.dx * 6);
}
if (mouse.hitTest(rightbarrier)) {
mouse.dx = mouse.dx * -1;
mouse.oX = mouse.oX + (mouse.dx * 6);
}
if (mouse.hitTest(topbarrier)) {
mouse.dy = mouse.dy * -1;
mouse.oY = mouse.oY + (mouse.dy * 6);
}
if (mouse.hitTest(bottombarrier)) {
mouse.dy = mouse.dy * -1;
mouse.oY = mouse.oY + (mouse.dy * 6);
}
i = 0;
while (i <= rocks) {
currentRock = eval ("rock" + i);
if (currentRock.hitTest(leftbarrier)) {
currentRock.dx = currentRock.dx * -1;
currentRock.oX = currentRock.oX + (currentRock.dx * 6);
}
if (currentRock.hitTest(rightbarrier)) {
currentRock.dx = currentRock.dx * -1;
currentRock.oX = currentRock.oX + (currentRock.dx * 6);
}
if (currentRock.hitTest(topbarrier)) {
currentRock.dy = currentRock.dy * -1;
currentRock.oY = currentRock.oY + (currentRock.dy * 6);
}
if (currentRock.hitTest(bottombarrier)) {
currentRock.dy = currentRock.dy * -1;
currentRock.oX = currentRock.oX + (currentRock.dy * 6);
}
i++;
}
i = 1;
while (i <= rocks) {
currentRock = eval ("rock" + i);
e = 1;
while (e <= enemies) {
currentEnemy = eval ("enemy" + e);
if (currentRock.hitTest(currentEnemy)) {
if (currentRock._y < currentEnemy._y) {
if (currentRock.dy > 0) {
if (playsounds) {
}
currentEnemy.health = currentEnemy.health - currentRock.dy;
if (currentEnemy.tower == false) {
currentEnemy._yscale = currentEnemy.health * 10;
} else {
currentEnemy._yscale = currentEnemy.health * 5;
}
currentEnemy.speed = 0;
currentRock.dy = 0;
currentRock.dx = 0;
if (notputdown == i) {
mouse._y = mouse._y - 5;
mouse.dy = mouse.dy - 1;
currentX = currentRock.oX + globalX;
currentY = currentRock.oY + globalY;
dx = mouse._x - currentX;
dy = mouse._y - currentY;
currentRock.oX = currentRock.oX + dx;
currentRock.oY = currentRock.oY + (dy + 27);
notputdown = -1;
}
if (currentEnemy.health <= 1) {
if (i != notputdown) {
if (playsounds) {
explosionS.start(0, 1);
}
explosion.oX = currentEnemy.oX;
explosion.oY = currentEnemy.oY;
if (currentEnemy.tower == true) {
explosion._yscale = 200;
explosion._xscale = 100;
} else {
explosion._yscale = 65;
explosion._xscale = 65;
}
explosion.gotoAndPlay(1);
currentEnemy.oX = -1000;
currentEnemy.oY = -1000;
} else {
if (playsounds) {
explosionS.start(0, 1);
}
if (currentEnemy.tower == true) {
explosion._yscale = 200;
explosion._xscale = 100;
} else {
explosion._yscale = 65;
explosion._xscale = 65;
}
explosion.gotoAndPlay(1);
currentEnemy.oX = -1000;
currentEnemy.oY = -1000;
mouse._y = mouse._y - 5;
mouse.dy = mouse.dy - 1;
currentX = currentRock.oX + globalX;
currentY = currentRock.oY + globalY;
dx = mouse._x - currentX;
dy = mouse._y - currentY;
currentRock.oX = currentRock.oX + dx;
currentRock.oY = currentRock.oY + (dy + 27);
notputdown = -1;
}
currentEnemy.dead = true;
}
}
}
}
e++;
}
i++;
}
i = 1;
while (i <= rocks) {
if (i != notputdown) {
currentRock = eval ("rock" + i);
if (mouse.hitTest(currentRock)) {
if (mouse._y < ((currentRock._y - 25) + (mouse.dy * 1.2))) {
mouse.dy = 0;
mouse._y = (currentRock.oY + globalY) - 26;
onLand = true;
} else {
mouse.dx = mouse.dx * -1;
mouse._x = mouse._x + (mouse.dx * 2);
}
}
}
i++;
}
i = 0;
while (i <= buttons) {
currentResponder = eval ("responder" + i);
if (mouse.hitTest(currentResponder)) {
mouse.dx = mouse.dx * -1;
mouse._x = mouse._x + (mouse.dx * 2);
}
i++;
}
pressed = false;
if (Key.isDown(38)) {
if (onLand) {
mouse.dy = -2;
mouse._y = mouse._y + mouse.dy;
} else if (flightJuice > 0) {
pressed = true;
mouse.gotoAndStop("up");
mouse.dy = mouse.dy - thrust;
flightJuice = flightJuice - 1;
}
}
if (Key.isDown(40)) {
if (onLand) {
} else if (flightJuice > 0) {
pressed = true;
mouse.gotoAndStop("down");
mouse.dy = mouse.dy + thrust;
flightJuice = flightJuice - 1;
}
if (mouse.hitTest(topbarrier)) {
mouse._y = mouse._y + 7;
}
i = 0;
while (i <= lands) {
currentLand = eval ("land" + i);
if (mouse.hitTest(currentLand)) {
if (currentLand._y < (mouse._y - 5)) {
mouse._y = mouse._y + 7;
}
}
i++;
}
}
if (Key.isDown(37)) {
pressed = true;
if (onLand) {
mouse.dx = mouse.dx - thrust;
mouse.gotoAndStop("left");
} else if (flightJuice > 0) {
pressed = true;
mouse.dx = mouse.dx - thrust;
mouse.gotoAndStop("left");
flightJuice = flightJuice - 1;
}
i = 1;
while (i <= lands) {
currentLand = eval ("land" + i);
if (mouse.hitTest(currentLand)) {
if (i != onLandNum) {
if (mouse._y > currentLand._y) {
mouse._x = mouse._x - 7;
}
}
}
i++;
}
i = 1;
while (i <= rocks) {
currentRock = eval ("rock" + i);
if (mouse.hitTest(currentRock)) {
if (mouse._y > (currentRock._y - 26)) {
if (i != notputdown) {
mouse._x = mouse._x - 7;
}
}
}
i++;
}
i = 0;
while (i <= buttons) {
currentResponder = eval ("responder" + i);
if (mouse.hitTest(currentResponder)) {
mouse._x = mouse._x - 7;
}
i++;
}
if (mouse.hitTest(rightbarrier)) {
mouse._x = mouse._x - 7;
}
} else if (Key.isDown(39)) {
pressed = true;
if (onLand) {
mouse.dx = mouse.dx + thrust;
mouse.gotoAndStop("left");
} else if (flightJuice > 0) {
pressed = true;
mouse.dx = mouse.dx + thrust;
mouse.gotoAndStop("left");
flightJuice = flightJuice - 1;
}
mouse.gotoAndStop("right");
i = 1;
while (i <= lands) {
currentLand = eval ("land" + i);
if (mouse.hitTest(currentLand)) {
if (i != onLandNum) {
if (mouse._y > currentLand._y) {
mouse._x = mouse._x + 7;
}
}
}
i++;
}
i = 1;
while (i <= rocks) {
currentRock = eval ("rock" + i);
if (mouse.hitTest(currentRock)) {
if (mouse._y > (currentRock._y - 26)) {
if (i != notputdown) {
mouse._x = mouse._x + 7;
}
}
}
i++;
}
i = 0;
while (i <= buttons) {
currentResponder = eval ("responder" + i);
if (mouse.hitTest(currentResponder)) {
mouse._x = mouse._x + 7;
}
i++;
}
if (mouse.hitTest(leftbarrier)) {
mouse._x = mouse._x + 7;
}
} else if (mouse.dx < 0) {
mouse.dx = mouse.dx + thrust;
} else if (mouse.dx > 0) {
mouse.dx = mouse.dx - thrust;
}
if (mouse.dx < 0.1) {
if (mouse.dx > 0) {
mouse.dx = 0;
}
}
if (mouse.dx > -0.1) {
if (mouse.dx < 0) {
mouse.dx = 0;
}
}
if (pressed == false) {
mouse.gotoAndStop("center");
}
if (pressed == true) {
if (playsounds) {
thrustsoundpauser++;
if (thrustsoundpauser == totalforthruster) {
thruster.start(0, 1);
thrustsoundpauser = 0;
}
}
}
if (Key.isDown(32)) {
if (donePressSpace) {
donePressSpace = false;
if (notputdown == -1) {
i = 1;
while (i <= rocks) {
currentRock = eval ("rock" + i);
if (mouse.hitTest(currentRock)) {
if (playsounds) {
pickup.start(0, 1);
}
notputdown = i;
dx = mouse._x - currentRock._x;
dy = mouse._y - currentRock._y;
currentRock.oX = currentRock.oX + dx;
currentRock.oY = currentRock.oY + (dy + 27);
}
i++;
}
} else {
mouse._y = mouse._y - 5;
mouse.dy = mouse.dy - 1;
if (playsounds) {
pickup.start(0, 1);
}
currentRock = eval ("rock" + notputdown);
currentX = currentRock.oX + globalX;
currentY = currentRock.oY + globalY;
dx = mouse._x - currentX;
dy = mouse._y - currentY;
currentRock.oX = currentRock.oX + dx;
currentRock.oY = currentRock.oY + (dy + 27);
notputdown = -1;
}
}
} else {
donePressSpace = true;
}
i = 1;
while (i <= rocks) {
currentRock = eval ("rock" + i);
if (i != notputdown) {
currentRock.dy = currentRock.dy + gravity;
currentRock.oX = currentRock.oX + currentRock.dx;
currentRock.oY = currentRock.oY + currentRock.dy;
}
l = 1;
while (l <= lands) {
currentLand = eval ("land" + l);
if (currentRock.hitTest(currentLand)) {
if (currentRock._y < ((currentLand._y + currentRock.dy) + 0.5)) {
currentRock.oY = currentLand.oY;
currentRock.dy = 0;
currentRock.dx = 0;
} else if (currentRock._y > (currentLand._y + 25.5)) {
currentRock.dy = currentRock.dy * -1;
currentRock.oY = currentRock.oY + (currentRock.dy * 2);
} else {
currentRock.dx = currentRock.dx * -1;
currentRock.oX = currentRock.oX + (currentRock.dx * 4);
}
}
l++;
}
b = 1;
while (b <= rocks) {
otherRock = eval ("rock" + b);
if (b != i) {
if (currentRock.hitTest(otherRock)) {
if (currentRock.oY < otherRock.oY) {
currentRock.oY = otherRock.oY - 29;
currentRock.dy = 0;
currentRock.dx = 0;
}
}
}
b++;
}
b = 0;
while (b <= buttons) {
currentResponder = eval ("responder" + b);
if (currentRock.hitTest(currentResponder)) {
currentRock.dx = currentRock.dx * -1;
currentRock.oX = currentRock.oX + (currentRock.dx * 6);
}
b++;
}
i++;
}
i = 1;
while (i <= enemies) {
currentEnemy = eval ("enemy" + i);
if (currentEnemy.tower == false) {
if (currentEnemy.gotoLeft == true) {
if (currentEnemy.patrolPoint < currentEnemy.patrolLength) {
currentEnemy.oX = currentEnemy.oX + currentEnemy.speed;
currentEnemy.patrolPoint = currentEnemy.patrolPoint + currentEnemy.speed;
} else {
currentEnemy.gotoLeft = false;
currentEnemy.gotoAndPlay("turn");
}
} else if (currentEnemy.patrolPoint > 0) {
currentEnemy.oX = currentEnemy.oX - currentEnemy.speed;
currentEnemy.patrolPoint = currentEnemy.patrolPoint - currentEnemy.speed;
} else {
currentEnemy.gotoLeft = true;
currentEnemy.gotoAndPlay("turn");
}
}
i++;
}
i = 0;
while (i <= enemies) {
currentEnemy = eval ("enemy" + i);
if (mouse.hitTest(currentEnemy)) {
if (currentEnemy.tower == false) {
health = health - currentEnemy.damage;
}
}
if (currentEnemy.tower == true) {
currentBullet = eval ("bullet" + i);
if (mouse.hitTest(currentBullet)) {
health = health - currentEnemy.damage;
}
}
i++;
}
i = 0;
while (i <= buttons) {
currentButton = eval ("button" + i);
currentResponder = eval ("responder" + i);
hit = false;
r = 0;
while (r <= rocks) {
currentRock = eval ("rock" + r);
if (currentButton.hitTest(currentRock)) {
hit = true;
if (currentButton.pressed == false) {
currentButton.pressed = true;
currentResponder.oX = currentResponder.oX + 10000;
}
}
r++;
}
if (mousehitsbuttons == true) {
if (mouse.hitTest(currentButton)) {
hit = true;
if (currentButton.pressed == false) {
currentButton.pressed = true;
currentResponder.oX = currentResponder.oX + 10000;
}
}
}
if (hit == false) {
if (currentButton.pressed == true) {
currentButton.pressed = false;
currentResponder.oX = currentResponder.oX - 10000;
currentResponder.alpha = 0;
}
}
i++;
}
currentResponder.fadeOut = false;
currentResponder.alpha = 100;
currentResponder.speed = 6;
if (mouse.hitTest(end)) {
if (win == false) {
level++;
winS.start(0, 1);
end.gotoAndPlay("win");
win = true;
}
}
i = 0;
while (i <= enemies) {
currentTower = eval ("enemy" + i);
if (currentTower.tower == true) {
currentTop = eval ("towertop" + i);
currentBullet = eval ("bullet" + i);
currentTop._x = currentTower._x;
currentTop._y = currentTower._y - (95 * (currentTower._yscale / 100));
currentTop._yscale = currentTower._yscale;
dx = currentTop._x - mouse._x;
dy = currentTop._y - mouse._y;
radians = Math.atan(dy / dx);
degrees = (radians * 180) / Math.PI;
if (dx > 0) {
degrees = degrees + 180;
}
radians = (degrees / 180) * Math.PI;
degrees = degrees + 90;
currentTop._rotation = degrees;
distance = Math.sqrt((dx * dx) + (dy * dy));
currentTower.counter++;
if (currentTower.counter >= currentTower.counterLimit) {
currentTower.counter = 0;
currentBullet.oX = currentTower.oX;
currentBullet.oY = currentTower.oY - (95 * (currentTower._yscale / 100));
currentBullet.dx = Math.cos(radians) * currentTower.launchSpeed;
currentBullet.dy = Math.sin(radians) * currentTower.launchSpeed;
}
currentBullet.oX = currentBullet.oX + currentBullet.dx;
currentBullet.oY = currentBullet.oY + currentBullet.dy;
}
i++;
}
};
menu.onRelease = function () {
gotoAndStop ("menu");
};
currentAlpha = 100;
faderbox._alpha = currentAlpha;
fadeOut = function () {
if (loading == true) {
faderbox.gotoAndStop("blue");
}
if (loading == false) {
faderbox.gotoAndStop("red");
}
currentAlpha = currentAlpha + speed;
if (currentAlpha >= 100) {
currentAlpha = 100;
if (loading == true) {
gotoAndStop ("loading");
}
if (loading == false) {
gotoAndStop ("lose");
}
}
faderbox._x = 0;
faderbox._y = 0;
faderbox._alpha = currentAlpha;
};
fadeIn = function () {
faderbox.gotoAndStop("blue");
currentAlpha = currentAlpha - speed;
if (currentAlpha <= 0) {
currentAlpha = 0;
faderbox._x = -10000;
faderbox._y = -10000;
}
faderbox._alpha = currentAlpha;
if (health < topHealth) {
faderbox.gotoAndStop("red");
faderbox._x = 0;
faderbox._y = 0;
faderbox._alpha = (100 - (health * healthMultiplier)) - 20;
if (faderbox._alpha < 0) {
faderbox._alpha = 0;
}
currentAlpha = faderbox._alpha;
}
};
Frame 96
lands = 12;
total = 0;
rocks = 6;
objects = 5;
buttons = 3;
enemies = 8;
notputdown = -1;
health = topHealth;
healthMultiplier = 100 / health;
flightJuice = topFlightJuice;
flightMultiplier = 100 / flightJuice;
mouse.maxWidth = 62.1;
landWidth = 188;
onLandNum = 0;
globalX = 0;
globalY = 0;
win = false;
mousehitsbuttons = false;
topsmoke = 5;
smoke = 0;
thrustsoundpauser = 0;
totalforthruster = 4;
fadein = true;
loading = true;
stop();
mouse = eval (type);
mouse._x = startX._x;
mouse._y = startX._y;
startX._x = -100;
startX._y = -100;
mouse.dy = 0;
mouse.dx = 0;
mouse.oX = mouse._x;
mouse.oY = mouse._y;
explosion.oX = -10000;
explosion.oY = -10000;
leftbarrier.oX = leftbarrier._x;
leftbarrier.oY = leftbarrier._y;
rightbarrier.oX = rightbarrier._x;
rightbarrier.oY = rightbarrier._y;
topbarrier.oX = topbarrier._x;
topbarrier.oY = topbarrier._y;
bottombarrier.oX = bottombarrier._x;
bottombarrier.oY = bottombarrier._y;
end.oX = end._x;
end.oY = end._y;
enemy1.tower = false;
enemy2.tower = false;
enemy3.tower = false;
enemy4.tower = false;
enemy5.tower = true;
enemy6.tower = true;
enemy7.tower = true;
enemy8.tower = true;
i = 0;
while (i <= objects) {
currentObject = eval ("object" + i);
currentObject.oX = currentObject._x;
currentObject.oY = currentObject._y;
i++;
}
enemy1.gotoLeft = true;
i = 1;
while (i <= enemies) {
currentEnemy = eval ("enemy" + i);
currentEnemy.health = 8;
currentEnemy.speed = 2;
firstFlag = eval ("firstPatrolMarker" + i);
secondFlag = eval ("secondPatrolMarker" + i);
currentEnemy.patrolLength = secondFlag._x - firstFlag._x;
currentEnemy.patrolPoint = currentEnemy._x - firstFlag._x;
firstFlag._x = -100;
secondFlag._x = -100;
currentEnemy.damage = 1;
currentEnemy.oX = currentEnemy._x;
currentEnemy.oY = currentEnemy._y;
currentEnemy.dead = false;
currentEnemy.gotoLeft = true;
i++;
}
i = 0;
while (i <= enemies) {
currentEnemy = eval ("enemy" + i);
if (currentEnemy.tower == true) {
currentEnemy.counter = 0;
currentEnemy.counterLimit = 60;
currentEnemy.launchSpeed = 2;
currentEnemy.health = 20;
}
i++;
}
i = 0;
while (i <= buttons) {
currentButton = eval ("button" + i);
currentButton.pressed = false;
currentButton.oX = currentButton._x;
currentButton.oY = currentButton._y;
currentResponder = eval ("responder" + i);
currentResponder.oX = currentResponder._x;
currentResponder.oY = currentResponder._y;
currentResponder.fadeOut = false;
currentResponder.alpha = 100;
currentResponder.speed = 6;
i++;
}
i = 0;
while (i <= rocks) {
currentRock = eval ("rock" + i);
currentRock.oX = currentRock._x;
currentRock.oY = currentRock._y;
currentRock.dx = 0;
currentRock.dy = 0;
currentRock.originX = currentRock._x;
currentRock.originY = currentRock._y;
i++;
}
i = 0;
while (i <= lands) {
currentLand = eval ("land" + i);
currentLand.oX = currentLand._x;
currentLand.oY = currentLand._y;
i++;
}
mouse.onEnterFrame = function () {
if (fadein == true) {
fadeIn();
} else {
fadeOut();
}
mouse.dy = mouse.dy + gravity;
mouse._y = mouse._y + mouse.dy;
mouse._x = mouse._x + mouse.dx;
healthbar._xscale = health * healthMultiplier;
if (flightJuice > 0) {
flightbar._xscale = flightJuice * flightMultiplier;
}
if (health <= 0) {
fadein = false;
loading = false;
}
if (health < topHealth) {
health = health + (regenerateRate / 5);
}
if (flightJuice < topFlightJuice) {
flightJuice = flightJuice + regenerateRate;
}
dx = (Stage.width / 2) - mouse._x;
dy = (Stage.width / 2) - mouse._y;
dx = dx / 4;
dy = dy / 4;
if (mouse.dx > topspeed) {
mouse.dx = topspeed;
}
if (mouse.dx < (-topspeed)) {
mouse.dx = -topspeed;
}
if (mouse.dy > topspeed) {
mouse.dy = topspeed;
}
if (mouse.dy < (-topspeed)) {
mouse.dy = -topspeed;
}
globalX = globalX + dx;
globalY = globalY + dy;
i = 1;
while (i <= lands) {
currentLand = eval ("land" + i);
currentLand._x = currentLand.oX + globalX;
currentLand._y = currentLand.oY + globalY;
i++;
}
i = 1;
while (i <= rocks) {
currentRock = eval ("rock" + i);
currentRock._x = currentRock.oX + globalX;
currentRock._y = currentRock.oY + globalY;
i++;
}
i = 1;
while (i <= enemies) {
currentEnemy = eval ("enemy" + i);
currentEnemy._x = currentEnemy.oX + globalX;
currentEnemy._y = currentEnemy.oY + globalY;
if (currentEnemy.tower) {
currentBullet = eval ("bullet" + i);
currentBullet._x = currentBullet.oX + globalX;
currentBullet._y = currentBullet.oY + globalY;
}
i++;
}
explosion._x = explosion.oX + globalX;
explosion._y = explosion.oY + globalY;
i = 0;
while (i <= buttons) {
currentButton = eval ("button" + i);
currentResponder = eval ("responder" + i);
currentButton._x = currentButton.oX + globalX;
currentButton._y = currentButton.oY + globalY;
currentResponder._x = currentResponder.oX + globalX;
currentResponder._y = currentResponder.oY + globalY;
i++;
}
i = 0;
while (i <= objects) {
currentObject = eval ("object" + i);
currentObject._x = currentObject.oX + globalX;
currentObject._y = currentObject.oY + globalY;
i++;
}
leftbarrier._x = leftbarrier.oX + globalX;
leftbarrier._y = leftbarrier.oY + globalY;
rightbarrier._x = rightbarrier.oX + globalX;
rightbarrier._y = rightbarrier.oY + globalY;
topbarrier._x = topbarrier.oX + globalX;
topbarrier._y = topbarrier.oY + globalY;
bottombarrier._x = bottombarrier.oX + globalX;
bottombarrier._y = bottombarrier.oY + globalY;
end._x = end.oX + globalX;
end._y = end.oY + globalY;
mouse.oX = mouse.oX + dx;
mouse.oY = mouse.oY + dy;
mouse._y = mouse._y + dy;
mouse._x = mouse._x + dx;
bg._x = bg._x + (dx / 3);
bg._y = bg._y + (dy / 3);
if (notputdown != -1) {
currentRock = eval ("rock" + notputdown);
currentRock._x = mouse._x;
currentRock._y = mouse._y + 25;
currentRock.dx = mouse.dx;
currentRock.dy = mouse.dy;
}
onLand = false;
i = 1;
while (i <= lands) {
currentLand = eval ("land" + i);
if (mouse.hitTest(currentLand)) {
if (mouse._y < (currentLand._y + (mouse.dy * 1.2))) {
mouse.dy = 0;
mouse._y = currentLand._y;
onLand = true;
onLandNum = i;
} else if (mouse._y > (((currentLand._y + 35.5) + 25.4) + (mouse.dy * 1.2))) {
mouse.dy = mouse.dy * -1;
mouse._y = mouse._y + (mouse.dy * 1.5);
} else {
mouse.dx = mouse.dx * -1;
mouse._x = mouse._x + (mouse.dx * 2);
}
}
i++;
}
if (notputdown != -1) {
currentRock = eval ("rock" + notputdown);
i = 1;
while (i <= lands) {
currentLand = eval ("land" + i);
if (currentRock.hitTest(currentLand)) {
if (currentRock._y < (currentLand._y + (mouse.dy * 1.2))) {
mouse.dy = 0;
mouse._y = currentLand._y - 25;
onLand = true;
onLandNum = i;
} else if (currentRock._y > (((currentLand._y + 35) + 27) + (mouse.dy * 1.2))) {
mouse.dy = mouse.dy * -1;
mouse._y = mouse._y + (mouse.dy * 1.5);
} else {
mouse.dx = mouse.dx * -1;
mouse._x = mouse._x + (mouse.dx * 2);
}
}
i++;
}
notDropRock = eval ("rock" + notputdown);
i = 1;
while (i <= rocks) {
if (i != notputdown) {
currentRock = eval ("rock" + i);
if (notDropRock.hitTest(currentRock)) {
if (notDropRock._y < ((currentRock._y - 25) + (mouse.dy * 1.2))) {
mouse.dy = 0;
mouse._y = currentRock._y - 54;
onLand = true;
} else {
mouse.dx = mouse.dx * -1;
mouse._x = mouse._x + (mouse.dx * 2);
}
}
}
i++;
}
}
if (mouse.hitTest(leftbarrier)) {
mouse.dx = mouse.dx * -1;
mouse.oX = mouse.oX + (mouse.dx * 6);
}
if (mouse.hitTest(rightbarrier)) {
mouse.dx = mouse.dx * -1;
mouse.oX = mouse.oX + (mouse.dx * 6);
}
if (mouse.hitTest(topbarrier)) {
mouse.dy = mouse.dy * -1;
mouse.oY = mouse.oY + (mouse.dy * 6);
}
if (mouse.hitTest(bottombarrier)) {
mouse.dy = mouse.dy * -1;
mouse.oY = mouse.oY + (mouse.dy * 6);
}
i = 0;
while (i <= rocks) {
currentRock = eval ("rock" + i);
if (currentRock.hitTest(leftbarrier)) {
currentRock.dx = currentRock.dx * -1;
currentRock.oX = currentRock.oX + (currentRock.dx * 6);
}
if (currentRock.hitTest(rightbarrier)) {
currentRock.dx = currentRock.dx * -1;
currentRock.oX = currentRock.oX + (currentRock.dx * 6);
}
if (currentRock.hitTest(topbarrier)) {
currentRock.dy = currentRock.dy * -1;
currentRock.oY = currentRock.oY + (currentRock.dy * 6);
}
if (currentRock.hitTest(bottombarrier)) {
currentRock.dy = currentRock.dy * -1;
currentRock.oX = currentRock.oX + (currentRock.dy * 6);
}
i++;
}
i = 1;
while (i <= rocks) {
currentRock = eval ("rock" + i);
e = 1;
while (e <= enemies) {
currentEnemy = eval ("enemy" + e);
if (currentRock.hitTest(currentEnemy)) {
if (currentRock._y < currentEnemy._y) {
if (currentRock.dy > 0) {
if (playsounds) {
}
currentEnemy.health = currentEnemy.health - currentRock.dy;
if (currentEnemy.tower == false) {
currentEnemy._yscale = currentEnemy.health * 10;
} else {
currentEnemy._yscale = currentEnemy.health * 5;
}
currentEnemy.speed = 0;
currentRock.dy = 0;
currentRock.dx = 0;
if (notputdown == i) {
mouse._y = mouse._y - 5;
mouse.dy = mouse.dy - 1;
currentX = currentRock.oX + globalX;
currentY = currentRock.oY + globalY;
dx = mouse._x - currentX;
dy = mouse._y - currentY;
currentRock.oX = currentRock.oX + dx;
currentRock.oY = currentRock.oY + (dy + 27);
notputdown = -1;
}
if (currentEnemy.health <= 1) {
if (i != notputdown) {
if (playsounds) {
explosionS.start(0, 1);
}
explosion.oX = currentEnemy.oX;
explosion.oY = currentEnemy.oY;
if (currentEnemy.tower == true) {
explosion._yscale = 200;
explosion._xscale = 100;
} else {
explosion._yscale = 65;
explosion._xscale = 65;
}
explosion.gotoAndPlay(1);
currentEnemy.oX = -1000;
currentEnemy.oY = -1000;
} else {
if (playsounds) {
explosionS.start(0, 1);
}
if (currentEnemy.tower == true) {
explosion._yscale = 200;
explosion._xscale = 100;
} else {
explosion._yscale = 65;
explosion._xscale = 65;
}
explosion.gotoAndPlay(1);
currentEnemy.oX = -1000;
currentEnemy.oY = -1000;
mouse._y = mouse._y - 5;
mouse.dy = mouse.dy - 1;
currentX = currentRock.oX + globalX;
currentY = currentRock.oY + globalY;
dx = mouse._x - currentX;
dy = mouse._y - currentY;
currentRock.oX = currentRock.oX + dx;
currentRock.oY = currentRock.oY + (dy + 27);
notputdown = -1;
}
currentEnemy.dead = true;
}
}
}
}
e++;
}
i++;
}
i = 1;
while (i <= rocks) {
if (i != notputdown) {
currentRock = eval ("rock" + i);
if (mouse.hitTest(currentRock)) {
if (mouse._y < ((currentRock._y - 25) + (mouse.dy * 1.2))) {
mouse.dy = 0;
mouse._y = (currentRock.oY + globalY) - 26;
onLand = true;
} else {
mouse.dx = mouse.dx * -1;
mouse._x = mouse._x + (mouse.dx * 2);
}
}
}
i++;
}
i = 0;
while (i <= buttons) {
currentResponder = eval ("responder" + i);
if (mouse.hitTest(currentResponder)) {
mouse.dx = mouse.dx * -1;
mouse._x = mouse._x + (mouse.dx * 2);
}
i++;
}
pressed = false;
if (Key.isDown(38)) {
if (onLand) {
mouse.dy = -2;
mouse._y = mouse._y + mouse.dy;
} else if (flightJuice > 0) {
pressed = true;
mouse.gotoAndStop("up");
mouse.dy = mouse.dy - thrust;
flightJuice = flightJuice - 1;
}
}
if (Key.isDown(40)) {
if (onLand) {
} else if (flightJuice > 0) {
pressed = true;
mouse.gotoAndStop("down");
mouse.dy = mouse.dy + thrust;
flightJuice = flightJuice - 1;
}
if (mouse.hitTest(topbarrier)) {
mouse._y = mouse._y + 7;
}
i = 0;
while (i <= lands) {
currentLand = eval ("land" + i);
if (mouse.hitTest(currentLand)) {
if (currentLand._y < (mouse._y - 5)) {
mouse._y = mouse._y + 7;
}
}
i++;
}
}
if (Key.isDown(37)) {
pressed = true;
if (onLand) {
mouse.dx = mouse.dx - thrust;
mouse.gotoAndStop("left");
} else if (flightJuice > 0) {
pressed = true;
mouse.dx = mouse.dx - thrust;
mouse.gotoAndStop("left");
flightJuice = flightJuice - 1;
}
i = 1;
while (i <= lands) {
currentLand = eval ("land" + i);
if (mouse.hitTest(currentLand)) {
if (i != onLandNum) {
if (mouse._y > currentLand._y) {
mouse._x = mouse._x - 7;
}
}
}
i++;
}
i = 1;
while (i <= rocks) {
currentRock = eval ("rock" + i);
if (mouse.hitTest(currentRock)) {
if (mouse._y > (currentRock._y - 26)) {
if (i != notputdown) {
mouse._x = mouse._x - 7;
}
}
}
i++;
}
i = 0;
while (i <= buttons) {
currentResponder = eval ("responder" + i);
if (mouse.hitTest(currentResponder)) {
mouse._x = mouse._x - 7;
}
i++;
}
if (mouse.hitTest(rightbarrier)) {
mouse._x = mouse._x - 7;
}
} else if (Key.isDown(39)) {
pressed = true;
if (onLand) {
mouse.dx = mouse.dx + thrust;
mouse.gotoAndStop("left");
} else if (flightJuice > 0) {
pressed = true;
mouse.dx = mouse.dx + thrust;
mouse.gotoAndStop("left");
flightJuice = flightJuice - 1;
}
mouse.gotoAndStop("right");
i = 1;
while (i <= lands) {
currentLand = eval ("land" + i);
if (mouse.hitTest(currentLand)) {
if (i != onLandNum) {
if (mouse._y > currentLand._y) {
mouse._x = mouse._x + 7;
}
}
}
i++;
}
i = 1;
while (i <= rocks) {
currentRock = eval ("rock" + i);
if (mouse.hitTest(currentRock)) {
if (mouse._y > (currentRock._y - 26)) {
if (i != notputdown) {
mouse._x = mouse._x + 7;
}
}
}
i++;
}
i = 0;
while (i <= buttons) {
currentResponder = eval ("responder" + i);
if (mouse.hitTest(currentResponder)) {
mouse._x = mouse._x + 7;
}
i++;
}
if (mouse.hitTest(leftbarrier)) {
mouse._x = mouse._x + 7;
}
} else if (mouse.dx < 0) {
mouse.dx = mouse.dx + thrust;
} else if (mouse.dx > 0) {
mouse.dx = mouse.dx - thrust;
}
if (mouse.dx < 0.1) {
if (mouse.dx > 0) {
mouse.dx = 0;
}
}
if (mouse.dx > -0.1) {
if (mouse.dx < 0) {
mouse.dx = 0;
}
}
if (pressed == false) {
mouse.gotoAndStop("center");
}
if (pressed == true) {
if (playsounds) {
thrustsoundpauser++;
if (thrustsoundpauser == totalforthruster) {
thruster.start(0, 1);
thrustsoundpauser = 0;
}
}
}
if (Key.isDown(32)) {
if (donePressSpace) {
donePressSpace = false;
if (notputdown == -1) {
i = 1;
while (i <= rocks) {
currentRock = eval ("rock" + i);
if (mouse.hitTest(currentRock)) {
if (playsounds) {
pickup.start(0, 1);
}
notputdown = i;
dx = mouse._x - currentRock._x;
dy = mouse._y - currentRock._y;
currentRock.oX = currentRock.oX + dx;
currentRock.oY = currentRock.oY + (dy + 27);
}
i++;
}
} else {
mouse._y = mouse._y - 5;
mouse.dy = mouse.dy - 1;
if (playsounds) {
pickup.start(0, 1);
}
currentRock = eval ("rock" + notputdown);
currentX = currentRock.oX + globalX;
currentY = currentRock.oY + globalY;
dx = mouse._x - currentX;
dy = mouse._y - currentY;
currentRock.oX = currentRock.oX + dx;
currentRock.oY = currentRock.oY + (dy + 27);
notputdown = -1;
}
}
} else {
donePressSpace = true;
}
i = 1;
while (i <= rocks) {
currentRock = eval ("rock" + i);
if (i != notputdown) {
currentRock.dy = currentRock.dy + gravity;
currentRock.oX = currentRock.oX + currentRock.dx;
currentRock.oY = currentRock.oY + currentRock.dy;
}
l = 1;
while (l <= lands) {
currentLand = eval ("land" + l);
if (currentRock.hitTest(currentLand)) {
if (currentRock._y < ((currentLand._y + currentRock.dy) + 0.5)) {
currentRock.oY = currentLand.oY;
currentRock.dy = 0;
currentRock.dx = 0;
} else if (currentRock._y > (currentLand._y + 25.5)) {
currentRock.dy = currentRock.dy * -1;
currentRock.oY = currentRock.oY + (currentRock.dy * 2);
} else {
currentRock.dx = currentRock.dx * -1;
currentRock.oX = currentRock.oX + (currentRock.dx * 4);
}
}
l++;
}
b = 1;
while (b <= rocks) {
otherRock = eval ("rock" + b);
if (b != i) {
if (currentRock.hitTest(otherRock)) {
if (currentRock.oY < otherRock.oY) {
currentRock.oY = otherRock.oY - 29;
currentRock.dy = 0;
currentRock.dx = 0;
}
}
}
b++;
}
b = 0;
while (b <= buttons) {
currentResponder = eval ("responder" + b);
if (currentRock.hitTest(currentResponder)) {
currentRock.dx = currentRock.dx * -1;
currentRock.oX = currentRock.oX + (currentRock.dx * 6);
}
b++;
}
i++;
}
i = 1;
while (i <= enemies) {
currentEnemy = eval ("enemy" + i);
if (currentEnemy.tower == false) {
if (currentEnemy.gotoLeft == true) {
if (currentEnemy.patrolPoint < currentEnemy.patrolLength) {
currentEnemy.oX = currentEnemy.oX + currentEnemy.speed;
currentEnemy.patrolPoint = currentEnemy.patrolPoint + currentEnemy.speed;
} else {
currentEnemy.gotoLeft = false;
currentEnemy.gotoAndPlay("turn");
}
} else if (currentEnemy.patrolPoint > 0) {
currentEnemy.oX = currentEnemy.oX - currentEnemy.speed;
currentEnemy.patrolPoint = currentEnemy.patrolPoint - currentEnemy.speed;
} else {
currentEnemy.gotoLeft = true;
currentEnemy.gotoAndPlay("turn");
}
}
i++;
}
i = 0;
while (i <= enemies) {
currentEnemy = eval ("enemy" + i);
if (mouse.hitTest(currentEnemy)) {
if (currentEnemy.tower == false) {
health = health - currentEnemy.damage;
}
}
if (currentEnemy.tower == true) {
currentBullet = eval ("bullet" + i);
if (mouse.hitTest(currentBullet)) {
health = health - currentEnemy.damage;
}
}
i++;
}
i = 0;
while (i <= buttons) {
currentButton = eval ("button" + i);
currentResponder = eval ("responder" + i);
hit = false;
r = 0;
while (r <= rocks) {
currentRock = eval ("rock" + r);
if (currentButton.hitTest(currentRock)) {
hit = true;
if (currentButton.pressed == false) {
currentButton.pressed = true;
currentResponder.oX = currentResponder.oX + 10000;
}
}
r++;
}
if (mousehitsbuttons == true) {
if (mouse.hitTest(currentButton)) {
hit = true;
if (currentButton.pressed == false) {
currentButton.pressed = true;
currentResponder.oX = currentResponder.oX + 10000;
}
}
}
if (hit == false) {
if (currentButton.pressed == true) {
currentButton.pressed = false;
currentResponder.oX = currentResponder.oX - 10000;
currentResponder.alpha = 0;
}
}
i++;
}
currentResponder.fadeOut = false;
currentResponder.alpha = 100;
currentResponder.speed = 6;
if (mouse.hitTest(end)) {
if (win == false) {
level++;
winS.start(0, 1);
end.gotoAndPlay("win");
win = true;
}
}
i = 0;
while (i <= enemies) {
currentTower = eval ("enemy" + i);
if (currentTower.tower == true) {
currentTop = eval ("towertop" + i);
currentBullet = eval ("bullet" + i);
currentTop._x = currentTower._x;
currentTop._y = currentTower._y - (95 * (currentTower._yscale / 100));
currentTop._yscale = currentTower._yscale;
dx = currentTop._x - mouse._x;
dy = currentTop._y - mouse._y;
radians = Math.atan(dy / dx);
degrees = (radians * 180) / Math.PI;
if (dx > 0) {
degrees = degrees + 180;
}
radians = (degrees / 180) * Math.PI;
degrees = degrees + 90;
currentTop._rotation = degrees;
distance = Math.sqrt((dx * dx) + (dy * dy));
currentTower.counter++;
if (currentTower.counter >= currentTower.counterLimit) {
currentTower.counter = 0;
currentBullet.oX = currentTower.oX;
currentBullet.oY = currentTower.oY - (95 * (currentTower._yscale / 100));
currentBullet.dx = Math.cos(radians) * currentTower.launchSpeed;
currentBullet.dy = Math.sin(radians) * currentTower.launchSpeed;
}
currentBullet.oX = currentBullet.oX + currentBullet.dx;
currentBullet.oY = currentBullet.oY + currentBullet.dy;
}
i++;
}
};
menu.onRelease = function () {
gotoAndStop ("menu");
};
currentAlpha = 100;
faderbox._alpha = currentAlpha;
fadeOut = function () {
if (loading == true) {
faderbox.gotoAndStop("blue");
}
if (loading == false) {
faderbox.gotoAndStop("red");
}
currentAlpha = currentAlpha + speed;
if (currentAlpha >= 100) {
currentAlpha = 100;
if (loading == true) {
gotoAndStop ("loading");
}
if (loading == false) {
gotoAndStop ("lose");
}
}
faderbox._x = 0;
faderbox._y = 0;
faderbox._alpha = currentAlpha;
};
fadeIn = function () {
faderbox.gotoAndStop("blue");
currentAlpha = currentAlpha - speed;
if (currentAlpha <= 0) {
currentAlpha = 0;
faderbox._x = -10000;
faderbox._y = -10000;
}
faderbox._alpha = currentAlpha;
if (health < topHealth) {
faderbox.gotoAndStop("red");
faderbox._x = 0;
faderbox._y = 0;
faderbox._alpha = (100 - (health * healthMultiplier)) - 20;
if (faderbox._alpha < 0) {
faderbox._alpha = 0;
}
currentAlpha = faderbox._alpha;
}
};
Frame 97
lands = 12;
total = 0;
rocks = 6;
objects = 5;
buttons = 3;
enemies = 8;
notputdown = -1;
health = topHealth;
healthMultiplier = 100 / health;
flightJuice = topFlightJuice;
flightMultiplier = 100 / flightJuice;
mouse.maxWidth = 62.1;
landWidth = 188;
onLandNum = 0;
globalX = 0;
globalY = 0;
win = false;
mousehitsbuttons = false;
topsmoke = 5;
smoke = 0;
thrustsoundpauser = 0;
totalforthruster = 4;
fadein = true;
loading = true;
stop();
mouse = eval (type);
mouse._x = startX._x;
mouse._y = startX._y;
startX._x = -100;
startX._y = -100;
mouse.dy = 0;
mouse.dx = 0;
mouse.oX = mouse._x;
mouse.oY = mouse._y;
explosion.oX = -10000;
explosion.oY = -10000;
leftbarrier.oX = leftbarrier._x;
leftbarrier.oY = leftbarrier._y;
rightbarrier.oX = rightbarrier._x;
rightbarrier.oY = rightbarrier._y;
topbarrier.oX = topbarrier._x;
topbarrier.oY = topbarrier._y;
bottombarrier.oX = bottombarrier._x;
bottombarrier.oY = bottombarrier._y;
end.oX = end._x;
end.oY = end._y;
enemy1.tower = false;
enemy2.tower = false;
enemy3.tower = false;
enemy4.tower = false;
enemy5.tower = true;
enemy6.tower = true;
enemy7.tower = true;
enemy8.tower = true;
i = 0;
while (i <= objects) {
currentObject = eval ("object" + i);
currentObject.oX = currentObject._x;
currentObject.oY = currentObject._y;
i++;
}
enemy1.gotoLeft = true;
i = 1;
while (i <= enemies) {
currentEnemy = eval ("enemy" + i);
currentEnemy.health = 8;
currentEnemy.speed = 2;
firstFlag = eval ("firstPatrolMarker" + i);
secondFlag = eval ("secondPatrolMarker" + i);
currentEnemy.patrolLength = secondFlag._x - firstFlag._x;
currentEnemy.patrolPoint = currentEnemy._x - firstFlag._x;
firstFlag._x = -100;
secondFlag._x = -100;
currentEnemy.damage = 1;
currentEnemy.oX = currentEnemy._x;
currentEnemy.oY = currentEnemy._y;
currentEnemy.dead = false;
currentEnemy.gotoLeft = true;
i++;
}
i = 0;
while (i <= enemies) {
currentEnemy = eval ("enemy" + i);
if (currentEnemy.tower == true) {
currentEnemy.counter = 0;
currentEnemy.counterLimit = 60;
currentEnemy.launchSpeed = 2;
currentEnemy.health = 20;
}
i++;
}
i = 0;
while (i <= buttons) {
currentButton = eval ("button" + i);
currentButton.pressed = false;
currentButton.oX = currentButton._x;
currentButton.oY = currentButton._y;
currentResponder = eval ("responder" + i);
currentResponder.oX = currentResponder._x;
currentResponder.oY = currentResponder._y;
currentResponder.fadeOut = false;
currentResponder.alpha = 100;
currentResponder.speed = 6;
i++;
}
i = 0;
while (i <= rocks) {
currentRock = eval ("rock" + i);
currentRock.oX = currentRock._x;
currentRock.oY = currentRock._y;
currentRock.dx = 0;
currentRock.dy = 0;
currentRock.originX = currentRock._x;
currentRock.originY = currentRock._y;
i++;
}
i = 0;
while (i <= lands) {
currentLand = eval ("land" + i);
currentLand.oX = currentLand._x;
currentLand.oY = currentLand._y;
i++;
}
mouse.onEnterFrame = function () {
if (fadein == true) {
fadeIn();
} else {
fadeOut();
}
mouse.dy = mouse.dy + gravity;
mouse._y = mouse._y + mouse.dy;
mouse._x = mouse._x + mouse.dx;
healthbar._xscale = health * healthMultiplier;
if (flightJuice > 0) {
flightbar._xscale = flightJuice * flightMultiplier;
}
if (health <= 0) {
fadein = false;
loading = false;
}
if (health < topHealth) {
health = health + (regenerateRate / 5);
}
if (flightJuice < topFlightJuice) {
flightJuice = flightJuice + regenerateRate;
}
dx = (Stage.width / 2) - mouse._x;
dy = (Stage.width / 2) - mouse._y;
dx = dx / 4;
dy = dy / 4;
if (mouse.dx > topspeed) {
mouse.dx = topspeed;
}
if (mouse.dx < (-topspeed)) {
mouse.dx = -topspeed;
}
if (mouse.dy > topspeed) {
mouse.dy = topspeed;
}
if (mouse.dy < (-topspeed)) {
mouse.dy = -topspeed;
}
globalX = globalX + dx;
globalY = globalY + dy;
i = 1;
while (i <= lands) {
currentLand = eval ("land" + i);
currentLand._x = currentLand.oX + globalX;
currentLand._y = currentLand.oY + globalY;
i++;
}
i = 1;
while (i <= rocks) {
currentRock = eval ("rock" + i);
currentRock._x = currentRock.oX + globalX;
currentRock._y = currentRock.oY + globalY;
i++;
}
i = 1;
while (i <= enemies) {
currentEnemy = eval ("enemy" + i);
currentEnemy._x = currentEnemy.oX + globalX;
currentEnemy._y = currentEnemy.oY + globalY;
if (currentEnemy.tower) {
currentBullet = eval ("bullet" + i);
currentBullet._x = currentBullet.oX + globalX;
currentBullet._y = currentBullet.oY + globalY;
}
i++;
}
explosion._x = explosion.oX + globalX;
explosion._y = explosion.oY + globalY;
i = 0;
while (i <= buttons) {
currentButton = eval ("button" + i);
currentResponder = eval ("responder" + i);
currentButton._x = currentButton.oX + globalX;
currentButton._y = currentButton.oY + globalY;
currentResponder._x = currentResponder.oX + globalX;
currentResponder._y = currentResponder.oY + globalY;
i++;
}
i = 0;
while (i <= objects) {
currentObject = eval ("object" + i);
currentObject._x = currentObject.oX + globalX;
currentObject._y = currentObject.oY + globalY;
i++;
}
leftbarrier._x = leftbarrier.oX + globalX;
leftbarrier._y = leftbarrier.oY + globalY;
rightbarrier._x = rightbarrier.oX + globalX;
rightbarrier._y = rightbarrier.oY + globalY;
topbarrier._x = topbarrier.oX + globalX;
topbarrier._y = topbarrier.oY + globalY;
bottombarrier._x = bottombarrier.oX + globalX;
bottombarrier._y = bottombarrier.oY + globalY;
end._x = end.oX + globalX;
end._y = end.oY + globalY;
mouse.oX = mouse.oX + dx;
mouse.oY = mouse.oY + dy;
mouse._y = mouse._y + dy;
mouse._x = mouse._x + dx;
bg._x = bg._x + (dx / 3);
bg._y = bg._y + (dy / 3);
if (notputdown != -1) {
currentRock = eval ("rock" + notputdown);
currentRock._x = mouse._x;
currentRock._y = mouse._y + 25;
currentRock.dx = mouse.dx;
currentRock.dy = mouse.dy;
}
onLand = false;
i = 1;
while (i <= lands) {
currentLand = eval ("land" + i);
if (mouse.hitTest(currentLand)) {
if (mouse._y < (currentLand._y + (mouse.dy * 1.2))) {
mouse.dy = 0;
mouse._y = currentLand._y;
onLand = true;
onLandNum = i;
} else if (mouse._y > (((currentLand._y + 35.5) + 25.4) + (mouse.dy * 1.2))) {
mouse.dy = mouse.dy * -1;
mouse._y = mouse._y + (mouse.dy * 1.5);
} else {
mouse.dx = mouse.dx * -1;
mouse._x = mouse._x + (mouse.dx * 2);
}
}
i++;
}
if (notputdown != -1) {
currentRock = eval ("rock" + notputdown);
i = 1;
while (i <= lands) {
currentLand = eval ("land" + i);
if (currentRock.hitTest(currentLand)) {
if (currentRock._y < (currentLand._y + (mouse.dy * 1.2))) {
mouse.dy = 0;
mouse._y = currentLand._y - 25;
onLand = true;
onLandNum = i;
} else if (currentRock._y > (((currentLand._y + 35) + 27) + (mouse.dy * 1.2))) {
mouse.dy = mouse.dy * -1;
mouse._y = mouse._y + (mouse.dy * 1.5);
} else {
mouse.dx = mouse.dx * -1;
mouse._x = mouse._x + (mouse.dx * 2);
}
}
i++;
}
notDropRock = eval ("rock" + notputdown);
i = 1;
while (i <= rocks) {
if (i != notputdown) {
currentRock = eval ("rock" + i);
if (notDropRock.hitTest(currentRock)) {
if (notDropRock._y < ((currentRock._y - 25) + (mouse.dy * 1.2))) {
mouse.dy = 0;
mouse._y = currentRock._y - 54;
onLand = true;
} else {
mouse.dx = mouse.dx * -1;
mouse._x = mouse._x + (mouse.dx * 2);
}
}
}
i++;
}
}
if (mouse.hitTest(leftbarrier)) {
mouse.dx = mouse.dx * -1;
mouse.oX = mouse.oX + (mouse.dx * 6);
}
if (mouse.hitTest(rightbarrier)) {
mouse.dx = mouse.dx * -1;
mouse.oX = mouse.oX + (mouse.dx * 6);
}
if (mouse.hitTest(topbarrier)) {
mouse.dy = mouse.dy * -1;
mouse.oY = mouse.oY + (mouse.dy * 6);
}
if (mouse.hitTest(bottombarrier)) {
mouse.dy = mouse.dy * -1;
mouse.oY = mouse.oY + (mouse.dy * 6);
}
i = 0;
while (i <= rocks) {
currentRock = eval ("rock" + i);
if (currentRock.hitTest(leftbarrier)) {
currentRock.dx = currentRock.dx * -1;
currentRock.oX = currentRock.oX + (currentRock.dx * 6);
}
if (currentRock.hitTest(rightbarrier)) {
currentRock.dx = currentRock.dx * -1;
currentRock.oX = currentRock.oX + (currentRock.dx * 6);
}
if (currentRock.hitTest(topbarrier)) {
currentRock.dy = currentRock.dy * -1;
currentRock.oY = currentRock.oY + (currentRock.dy * 6);
}
if (currentRock.hitTest(bottombarrier)) {
currentRock.dy = currentRock.dy * -1;
currentRock.oX = currentRock.oX + (currentRock.dy * 6);
}
i++;
}
i = 1;
while (i <= rocks) {
currentRock = eval ("rock" + i);
e = 1;
while (e <= enemies) {
currentEnemy = eval ("enemy" + e);
if (currentRock.hitTest(currentEnemy)) {
if (currentRock._y < currentEnemy._y) {
if (currentRock.dy > 0) {
if (playsounds) {
}
currentEnemy.health = currentEnemy.health - currentRock.dy;
if (currentEnemy.tower == false) {
currentEnemy._yscale = currentEnemy.health * 10;
} else {
currentEnemy._yscale = currentEnemy.health * 5;
}
currentEnemy.speed = 0;
currentRock.dy = 0;
currentRock.dx = 0;
if (notputdown == i) {
mouse._y = mouse._y - 5;
mouse.dy = mouse.dy - 1;
currentX = currentRock.oX + globalX;
currentY = currentRock.oY + globalY;
dx = mouse._x - currentX;
dy = mouse._y - currentY;
currentRock.oX = currentRock.oX + dx;
currentRock.oY = currentRock.oY + (dy + 27);
notputdown = -1;
}
if (currentEnemy.health <= 1) {
if (i != notputdown) {
if (playsounds) {
explosionS.start(0, 1);
}
explosion.oX = currentEnemy.oX;
explosion.oY = currentEnemy.oY;
if (currentEnemy.tower == true) {
explosion._yscale = 200;
explosion._xscale = 100;
} else {
explosion._yscale = 65;
explosion._xscale = 65;
}
explosion.gotoAndPlay(1);
currentEnemy.oX = -1000;
currentEnemy.oY = -1000;
} else {
if (playsounds) {
explosionS.start(0, 1);
}
if (currentEnemy.tower == true) {
explosion._yscale = 200;
explosion._xscale = 100;
} else {
explosion._yscale = 65;
explosion._xscale = 65;
}
explosion.gotoAndPlay(1);
currentEnemy.oX = -1000;
currentEnemy.oY = -1000;
mouse._y = mouse._y - 5;
mouse.dy = mouse.dy - 1;
currentX = currentRock.oX + globalX;
currentY = currentRock.oY + globalY;
dx = mouse._x - currentX;
dy = mouse._y - currentY;
currentRock.oX = currentRock.oX + dx;
currentRock.oY = currentRock.oY + (dy + 27);
notputdown = -1;
}
currentEnemy.dead = true;
}
}
}
}
e++;
}
i++;
}
i = 1;
while (i <= rocks) {
if (i != notputdown) {
currentRock = eval ("rock" + i);
if (mouse.hitTest(currentRock)) {
if (mouse._y < ((currentRock._y - 25) + (mouse.dy * 1.2))) {
mouse.dy = 0;
mouse._y = (currentRock.oY + globalY) - 26;
onLand = true;
} else {
mouse.dx = mouse.dx * -1;
mouse._x = mouse._x + (mouse.dx * 2);
}
}
}
i++;
}
i = 0;
while (i <= buttons) {
currentResponder = eval ("responder" + i);
if (mouse.hitTest(currentResponder)) {
mouse.dx = mouse.dx * -1;
mouse._x = mouse._x + (mouse.dx * 2);
}
i++;
}
pressed = false;
if (Key.isDown(38)) {
if (onLand) {
mouse.dy = -2;
mouse._y = mouse._y + mouse.dy;
} else if (flightJuice > 0) {
pressed = true;
mouse.gotoAndStop("up");
mouse.dy = mouse.dy - thrust;
flightJuice = flightJuice - 1;
}
}
if (Key.isDown(40)) {
if (onLand) {
} else if (flightJuice > 0) {
pressed = true;
mouse.gotoAndStop("down");
mouse.dy = mouse.dy + thrust;
flightJuice = flightJuice - 1;
}
if (mouse.hitTest(topbarrier)) {
mouse._y = mouse._y + 7;
}
i = 0;
while (i <= lands) {
currentLand = eval ("land" + i);
if (mouse.hitTest(currentLand)) {
if (currentLand._y < (mouse._y - 5)) {
mouse._y = mouse._y + 7;
}
}
i++;
}
}
if (Key.isDown(37)) {
pressed = true;
if (onLand) {
mouse.dx = mouse.dx - thrust;
mouse.gotoAndStop("left");
} else if (flightJuice > 0) {
pressed = true;
mouse.dx = mouse.dx - thrust;
mouse.gotoAndStop("left");
flightJuice = flightJuice - 1;
}
i = 1;
while (i <= lands) {
currentLand = eval ("land" + i);
if (mouse.hitTest(currentLand)) {
if (i != onLandNum) {
if (mouse._y > currentLand._y) {
mouse._x = mouse._x - 7;
}
}
}
i++;
}
i = 1;
while (i <= rocks) {
currentRock = eval ("rock" + i);
if (mouse.hitTest(currentRock)) {
if (mouse._y > (currentRock._y - 26)) {
if (i != notputdown) {
mouse._x = mouse._x - 7;
}
}
}
i++;
}
i = 0;
while (i <= buttons) {
currentResponder = eval ("responder" + i);
if (mouse.hitTest(currentResponder)) {
mouse._x = mouse._x - 7;
}
i++;
}
if (mouse.hitTest(rightbarrier)) {
mouse._x = mouse._x - 7;
}
} else if (Key.isDown(39)) {
pressed = true;
if (onLand) {
mouse.dx = mouse.dx + thrust;
mouse.gotoAndStop("left");
} else if (flightJuice > 0) {
pressed = true;
mouse.dx = mouse.dx + thrust;
mouse.gotoAndStop("left");
flightJuice = flightJuice - 1;
}
mouse.gotoAndStop("right");
i = 1;
while (i <= lands) {
currentLand = eval ("land" + i);
if (mouse.hitTest(currentLand)) {
if (i != onLandNum) {
if (mouse._y > currentLand._y) {
mouse._x = mouse._x + 7;
}
}
}
i++;
}
i = 1;
while (i <= rocks) {
currentRock = eval ("rock" + i);
if (mouse.hitTest(currentRock)) {
if (mouse._y > (currentRock._y - 26)) {
if (i != notputdown) {
mouse._x = mouse._x + 7;
}
}
}
i++;
}
i = 0;
while (i <= buttons) {
currentResponder = eval ("responder" + i);
if (mouse.hitTest(currentResponder)) {
mouse._x = mouse._x + 7;
}
i++;
}
if (mouse.hitTest(leftbarrier)) {
mouse._x = mouse._x + 7;
}
} else if (mouse.dx < 0) {
mouse.dx = mouse.dx + thrust;
} else if (mouse.dx > 0) {
mouse.dx = mouse.dx - thrust;
}
if (mouse.dx < 0.1) {
if (mouse.dx > 0) {
mouse.dx = 0;
}
}
if (mouse.dx > -0.1) {
if (mouse.dx < 0) {
mouse.dx = 0;
}
}
if (pressed == false) {
mouse.gotoAndStop("center");
}
if (pressed == true) {
if (playsounds) {
thrustsoundpauser++;
if (thrustsoundpauser == totalforthruster) {
thruster.start(0, 1);
thrustsoundpauser = 0;
}
}
}
if (Key.isDown(32)) {
if (donePressSpace) {
donePressSpace = false;
if (notputdown == -1) {
i = 1;
while (i <= rocks) {
currentRock = eval ("rock" + i);
if (mouse.hitTest(currentRock)) {
if (playsounds) {
pickup.start(0, 1);
}
notputdown = i;
dx = mouse._x - currentRock._x;
dy = mouse._y - currentRock._y;
currentRock.oX = currentRock.oX + dx;
currentRock.oY = currentRock.oY + (dy + 27);
}
i++;
}
} else {
mouse._y = mouse._y - 5;
mouse.dy = mouse.dy - 1;
if (playsounds) {
pickup.start(0, 1);
}
currentRock = eval ("rock" + notputdown);
currentX = currentRock.oX + globalX;
currentY = currentRock.oY + globalY;
dx = mouse._x - currentX;
dy = mouse._y - currentY;
currentRock.oX = currentRock.oX + dx;
currentRock.oY = currentRock.oY + (dy + 27);
notputdown = -1;
}
}
} else {
donePressSpace = true;
}
i = 1;
while (i <= rocks) {
currentRock = eval ("rock" + i);
if (i != notputdown) {
currentRock.dy = currentRock.dy + gravity;
currentRock.oX = currentRock.oX + currentRock.dx;
currentRock.oY = currentRock.oY + currentRock.dy;
}
l = 1;
while (l <= lands) {
currentLand = eval ("land" + l);
if (currentRock.hitTest(currentLand)) {
if (currentRock._y < ((currentLand._y + currentRock.dy) + 0.5)) {
currentRock.oY = currentLand.oY;
currentRock.dy = 0;
currentRock.dx = 0;
} else if (currentRock._y > (currentLand._y + 25.5)) {
currentRock.dy = currentRock.dy * -1;
currentRock.oY = currentRock.oY + (currentRock.dy * 2);
} else {
currentRock.dx = currentRock.dx * -1;
currentRock.oX = currentRock.oX + (currentRock.dx * 4);
}
}
l++;
}
b = 1;
while (b <= rocks) {
otherRock = eval ("rock" + b);
if (b != i) {
if (currentRock.hitTest(otherRock)) {
if (currentRock.oY < otherRock.oY) {
currentRock.oY = otherRock.oY - 29;
currentRock.dy = 0;
currentRock.dx = 0;
}
}
}
b++;
}
b = 0;
while (b <= buttons) {
currentResponder = eval ("responder" + b);
if (currentRock.hitTest(currentResponder)) {
currentRock.dx = currentRock.dx * -1;
currentRock.oX = currentRock.oX + (currentRock.dx * 6);
}
b++;
}
i++;
}
i = 1;
while (i <= enemies) {
currentEnemy = eval ("enemy" + i);
if (currentEnemy.tower == false) {
if (currentEnemy.gotoLeft == true) {
if (currentEnemy.patrolPoint < currentEnemy.patrolLength) {
currentEnemy.oX = currentEnemy.oX + currentEnemy.speed;
currentEnemy.patrolPoint = currentEnemy.patrolPoint + currentEnemy.speed;
} else {
currentEnemy.gotoLeft = false;
currentEnemy.gotoAndPlay("turn");
}
} else if (currentEnemy.patrolPoint > 0) {
currentEnemy.oX = currentEnemy.oX - currentEnemy.speed;
currentEnemy.patrolPoint = currentEnemy.patrolPoint - currentEnemy.speed;
} else {
currentEnemy.gotoLeft = true;
currentEnemy.gotoAndPlay("turn");
}
}
i++;
}
i = 0;
while (i <= enemies) {
currentEnemy = eval ("enemy" + i);
if (mouse.hitTest(currentEnemy)) {
if (currentEnemy.tower == false) {
health = health - currentEnemy.damage;
}
}
if (currentEnemy.tower == true) {
currentBullet = eval ("bullet" + i);
if (mouse.hitTest(currentBullet)) {
health = health - currentEnemy.damage;
}
}
i++;
}
i = 0;
while (i <= buttons) {
currentButton = eval ("button" + i);
currentResponder = eval ("responder" + i);
hit = false;
r = 0;
while (r <= rocks) {
currentRock = eval ("rock" + r);
if (currentButton.hitTest(currentRock)) {
hit = true;
if (currentButton.pressed == false) {
currentButton.pressed = true;
currentResponder.oX = currentResponder.oX + 10000;
}
}
r++;
}
if (mousehitsbuttons == true) {
if (mouse.hitTest(currentButton)) {
hit = true;
if (currentButton.pressed == false) {
currentButton.pressed = true;
currentResponder.oX = currentResponder.oX + 10000;
}
}
}
if (hit == false) {
if (currentButton.pressed == true) {
currentButton.pressed = false;
currentResponder.oX = currentResponder.oX - 10000;
currentResponder.alpha = 0;
}
}
i++;
}
currentResponder.fadeOut = false;
currentResponder.alpha = 100;
currentResponder.speed = 6;
if (mouse.hitTest(end)) {
if (win == false) {
level++;
winS.start(0, 1);
end.gotoAndPlay("win");
win = true;
}
}
i = 0;
while (i <= enemies) {
currentTower = eval ("enemy" + i);
if (currentTower.tower == true) {
currentTop = eval ("towertop" + i);
currentBullet = eval ("bullet" + i);
currentTop._x = currentTower._x;
currentTop._y = currentTower._y - (95 * (currentTower._yscale / 100));
currentTop._yscale = currentTower._yscale;
dx = currentTop._x - mouse._x;
dy = currentTop._y - mouse._y;
radians = Math.atan(dy / dx);
degrees = (radians * 180) / Math.PI;
if (dx > 0) {
degrees = degrees + 180;
}
radians = (degrees / 180) * Math.PI;
degrees = degrees + 90;
currentTop._rotation = degrees;
distance = Math.sqrt((dx * dx) + (dy * dy));
currentTower.counter++;
if (currentTower.counter >= currentTower.counterLimit) {
currentTower.counter = 0;
currentBullet.oX = currentTower.oX;
currentBullet.oY = currentTower.oY - (95 * (currentTower._yscale / 100));
currentBullet.dx = Math.cos(radians) * currentTower.launchSpeed;
currentBullet.dy = Math.sin(radians) * currentTower.launchSpeed;
}
currentBullet.oX = currentBullet.oX + currentBullet.dx;
currentBullet.oY = currentBullet.oY + currentBullet.dy;
}
i++;
}
};
menu.onRelease = function () {
gotoAndStop ("menu");
};
currentAlpha = 100;
faderbox._alpha = currentAlpha;
fadeOut = function () {
if (loading == true) {
faderbox.gotoAndStop("blue");
}
if (loading == false) {
faderbox.gotoAndStop("red");
}
currentAlpha = currentAlpha + speed;
if (currentAlpha >= 100) {
currentAlpha = 100;
if (loading == true) {
gotoAndStop ("loading");
}
if (loading == false) {
gotoAndStop ("lose");
}
}
faderbox._x = 0;
faderbox._y = 0;
faderbox._alpha = currentAlpha;
};
fadeIn = function () {
faderbox.gotoAndStop("blue");
currentAlpha = currentAlpha - speed;
if (currentAlpha <= 0) {
currentAlpha = 0;
faderbox._x = -10000;
faderbox._y = -10000;
}
faderbox._alpha = currentAlpha;
if (health < topHealth) {
faderbox.gotoAndStop("red");
faderbox._x = 0;
faderbox._y = 0;
faderbox._alpha = (100 - (health * healthMultiplier)) - 20;
if (faderbox._alpha < 0) {
faderbox._alpha = 0;
}
currentAlpha = faderbox._alpha;
}
};
Frame 98
lands = 12;
total = 0;
rocks = 6;
objects = 5;
buttons = 3;
enemies = 8;
notputdown = -1;
health = topHealth;
healthMultiplier = 100 / health;
flightJuice = topFlightJuice;
flightMultiplier = 100 / flightJuice;
mouse.maxWidth = 62.1;
landWidth = 188;
onLandNum = 0;
globalX = 0;
globalY = 0;
win = false;
mousehitsbuttons = false;
topsmoke = 5;
smoke = 0;
thrustsoundpauser = 0;
totalforthruster = 4;
fadein = true;
loading = true;
stop();
mouse = eval (type);
mouse._x = startX._x;
mouse._y = startX._y;
startX._x = -100;
startX._y = -100;
mouse.dy = 0;
mouse.dx = 0;
mouse.oX = mouse._x;
mouse.oY = mouse._y;
explosion.oX = -10000;
explosion.oY = -10000;
leftbarrier.oX = leftbarrier._x;
leftbarrier.oY = leftbarrier._y;
rightbarrier.oX = rightbarrier._x;
rightbarrier.oY = rightbarrier._y;
topbarrier.oX = topbarrier._x;
topbarrier.oY = topbarrier._y;
bottombarrier.oX = bottombarrier._x;
bottombarrier.oY = bottombarrier._y;
end.oX = end._x;
end.oY = end._y;
enemy1.tower = false;
enemy2.tower = false;
enemy3.tower = false;
enemy4.tower = false;
enemy5.tower = true;
enemy6.tower = true;
enemy7.tower = true;
enemy8.tower = true;
i = 0;
while (i <= objects) {
currentObject = eval ("object" + i);
currentObject.oX = currentObject._x;
currentObject.oY = currentObject._y;
i++;
}
enemy1.gotoLeft = true;
i = 1;
while (i <= enemies) {
currentEnemy = eval ("enemy" + i);
currentEnemy.health = 8;
currentEnemy.speed = 2;
firstFlag = eval ("firstPatrolMarker" + i);
secondFlag = eval ("secondPatrolMarker" + i);
currentEnemy.patrolLength = secondFlag._x - firstFlag._x;
currentEnemy.patrolPoint = currentEnemy._x - firstFlag._x;
firstFlag._x = -100;
secondFlag._x = -100;
currentEnemy.damage = 1;
currentEnemy.oX = currentEnemy._x;
currentEnemy.oY = currentEnemy._y;
currentEnemy.dead = false;
currentEnemy.gotoLeft = true;
i++;
}
i = 0;
while (i <= enemies) {
currentEnemy = eval ("enemy" + i);
if (currentEnemy.tower == true) {
currentEnemy.counter = 0;
currentEnemy.counterLimit = 60;
currentEnemy.launchSpeed = 2;
currentEnemy.health = 20;
}
i++;
}
i = 0;
while (i <= buttons) {
currentButton = eval ("button" + i);
currentButton.pressed = false;
currentButton.oX = currentButton._x;
currentButton.oY = currentButton._y;
currentResponder = eval ("responder" + i);
currentResponder.oX = currentResponder._x;
currentResponder.oY = currentResponder._y;
currentResponder.fadeOut = false;
currentResponder.alpha = 100;
currentResponder.speed = 6;
i++;
}
i = 0;
while (i <= rocks) {
currentRock = eval ("rock" + i);
currentRock.oX = currentRock._x;
currentRock.oY = currentRock._y;
currentRock.dx = 0;
currentRock.dy = 0;
currentRock.originX = currentRock._x;
currentRock.originY = currentRock._y;
i++;
}
i = 0;
while (i <= lands) {
currentLand = eval ("land" + i);
currentLand.oX = currentLand._x;
currentLand.oY = currentLand._y;
i++;
}
mouse.onEnterFrame = function () {
if (fadein == true) {
fadeIn();
} else {
fadeOut();
}
mouse.dy = mouse.dy + gravity;
mouse._y = mouse._y + mouse.dy;
mouse._x = mouse._x + mouse.dx;
healthbar._xscale = health * healthMultiplier;
if (flightJuice > 0) {
flightbar._xscale = flightJuice * flightMultiplier;
}
if (health <= 0) {
fadein = false;
loading = false;
}
if (health < topHealth) {
health = health + (regenerateRate / 5);
}
if (flightJuice < topFlightJuice) {
flightJuice = flightJuice + regenerateRate;
}
dx = (Stage.width / 2) - mouse._x;
dy = (Stage.width / 2) - mouse._y;
dx = dx / 4;
dy = dy / 4;
if (mouse.dx > topspeed) {
mouse.dx = topspeed;
}
if (mouse.dx < (-topspeed)) {
mouse.dx = -topspeed;
}
if (mouse.dy > topspeed) {
mouse.dy = topspeed;
}
if (mouse.dy < (-topspeed)) {
mouse.dy = -topspeed;
}
globalX = globalX + dx;
globalY = globalY + dy;
i = 1;
while (i <= lands) {
currentLand = eval ("land" + i);
currentLand._x = currentLand.oX + globalX;
currentLand._y = currentLand.oY + globalY;
i++;
}
i = 1;
while (i <= rocks) {
currentRock = eval ("rock" + i);
currentRock._x = currentRock.oX + globalX;
currentRock._y = currentRock.oY + globalY;
i++;
}
i = 1;
while (i <= enemies) {
currentEnemy = eval ("enemy" + i);
currentEnemy._x = currentEnemy.oX + globalX;
currentEnemy._y = currentEnemy.oY + globalY;
if (currentEnemy.tower) {
currentBullet = eval ("bullet" + i);
currentBullet._x = currentBullet.oX + globalX;
currentBullet._y = currentBullet.oY + globalY;
}
i++;
}
explosion._x = explosion.oX + globalX;
explosion._y = explosion.oY + globalY;
i = 0;
while (i <= buttons) {
currentButton = eval ("button" + i);
currentResponder = eval ("responder" + i);
currentButton._x = currentButton.oX + globalX;
currentButton._y = currentButton.oY + globalY;
currentResponder._x = currentResponder.oX + globalX;
currentResponder._y = currentResponder.oY + globalY;
i++;
}
i = 0;
while (i <= objects) {
currentObject = eval ("object" + i);
currentObject._x = currentObject.oX + globalX;
currentObject._y = currentObject.oY + globalY;
i++;
}
leftbarrier._x = leftbarrier.oX + globalX;
leftbarrier._y = leftbarrier.oY + globalY;
rightbarrier._x = rightbarrier.oX + globalX;
rightbarrier._y = rightbarrier.oY + globalY;
topbarrier._x = topbarrier.oX + globalX;
topbarrier._y = topbarrier.oY + globalY;
bottombarrier._x = bottombarrier.oX + globalX;
bottombarrier._y = bottombarrier.oY + globalY;
end._x = end.oX + globalX;
end._y = end.oY + globalY;
mouse.oX = mouse.oX + dx;
mouse.oY = mouse.oY + dy;
mouse._y = mouse._y + dy;
mouse._x = mouse._x + dx;
bg._x = bg._x + (dx / 3);
bg._y = bg._y + (dy / 3);
if (notputdown != -1) {
currentRock = eval ("rock" + notputdown);
currentRock._x = mouse._x;
currentRock._y = mouse._y + 25;
currentRock.dx = mouse.dx;
currentRock.dy = mouse.dy;
}
onLand = false;
i = 1;
while (i <= lands) {
currentLand = eval ("land" + i);
if (mouse.hitTest(currentLand)) {
if (mouse._y < (currentLand._y + (mouse.dy * 1.2))) {
mouse.dy = 0;
mouse._y = currentLand._y;
onLand = true;
onLandNum = i;
} else if (mouse._y > (((currentLand._y + 35.5) + 25.4) + (mouse.dy * 1.2))) {
mouse.dy = mouse.dy * -1;
mouse._y = mouse._y + (mouse.dy * 1.5);
} else {
mouse.dx = mouse.dx * -1;
mouse._x = mouse._x + (mouse.dx * 2);
}
}
i++;
}
if (notputdown != -1) {
currentRock = eval ("rock" + notputdown);
i = 1;
while (i <= lands) {
currentLand = eval ("land" + i);
if (currentRock.hitTest(currentLand)) {
if (currentRock._y < (currentLand._y + (mouse.dy * 1.2))) {
mouse.dy = 0;
mouse._y = currentLand._y - 25;
onLand = true;
onLandNum = i;
} else if (currentRock._y > (((currentLand._y + 35) + 27) + (mouse.dy * 1.2))) {
mouse.dy = mouse.dy * -1;
mouse._y = mouse._y + (mouse.dy * 1.5);
} else {
mouse.dx = mouse.dx * -1;
mouse._x = mouse._x + (mouse.dx * 2);
}
}
i++;
}
notDropRock = eval ("rock" + notputdown);
i = 1;
while (i <= rocks) {
if (i != notputdown) {
currentRock = eval ("rock" + i);
if (notDropRock.hitTest(currentRock)) {
if (notDropRock._y < ((currentRock._y - 25) + (mouse.dy * 1.2))) {
mouse.dy = 0;
mouse._y = currentRock._y - 54;
onLand = true;
} else {
mouse.dx = mouse.dx * -1;
mouse._x = mouse._x + (mouse.dx * 2);
}
}
}
i++;
}
}
if (mouse.hitTest(leftbarrier)) {
mouse.dx = mouse.dx * -1;
mouse.oX = mouse.oX + (mouse.dx * 6);
}
if (mouse.hitTest(rightbarrier)) {
mouse.dx = mouse.dx * -1;
mouse.oX = mouse.oX + (mouse.dx * 6);
}
if (mouse.hitTest(topbarrier)) {
mouse.dy = mouse.dy * -1;
mouse.oY = mouse.oY + (mouse.dy * 6);
}
if (mouse.hitTest(bottombarrier)) {
mouse.dy = mouse.dy * -1;
mouse.oY = mouse.oY + (mouse.dy * 6);
}
i = 0;
while (i <= rocks) {
currentRock = eval ("rock" + i);
if (currentRock.hitTest(leftbarrier)) {
currentRock.dx = currentRock.dx * -1;
currentRock.oX = currentRock.oX + (currentRock.dx * 6);
}
if (currentRock.hitTest(rightbarrier)) {
currentRock.dx = currentRock.dx * -1;
currentRock.oX = currentRock.oX + (currentRock.dx * 6);
}
if (currentRock.hitTest(topbarrier)) {
currentRock.dy = currentRock.dy * -1;
currentRock.oY = currentRock.oY + (currentRock.dy * 6);
}
if (currentRock.hitTest(bottombarrier)) {
currentRock.dy = currentRock.dy * -1;
currentRock.oX = currentRock.oX + (currentRock.dy * 6);
}
i++;
}
i = 1;
while (i <= rocks) {
currentRock = eval ("rock" + i);
e = 1;
while (e <= enemies) {
currentEnemy = eval ("enemy" + e);
if (currentRock.hitTest(currentEnemy)) {
if (currentRock._y < currentEnemy._y) {
if (currentRock.dy > 0) {
if (playsounds) {
}
currentEnemy.health = currentEnemy.health - currentRock.dy;
if (currentEnemy.tower == false) {
currentEnemy._yscale = currentEnemy.health * 10;
} else {
currentEnemy._yscale = currentEnemy.health * 5;
}
currentEnemy.speed = 0;
currentRock.dy = 0;
currentRock.dx = 0;
if (notputdown == i) {
mouse._y = mouse._y - 5;
mouse.dy = mouse.dy - 1;
currentX = currentRock.oX + globalX;
currentY = currentRock.oY + globalY;
dx = mouse._x - currentX;
dy = mouse._y - currentY;
currentRock.oX = currentRock.oX + dx;
currentRock.oY = currentRock.oY + (dy + 27);
notputdown = -1;
}
if (currentEnemy.health <= 1) {
if (i != notputdown) {
if (playsounds) {
explosionS.start(0, 1);
}
explosion.oX = currentEnemy.oX;
explosion.oY = currentEnemy.oY;
if (currentEnemy.tower == true) {
explosion._yscale = 200;
explosion._xscale = 100;
} else {
explosion._yscale = 65;
explosion._xscale = 65;
}
explosion.gotoAndPlay(1);
currentEnemy.oX = -1000;
currentEnemy.oY = -1000;
} else {
if (playsounds) {
explosionS.start(0, 1);
}
if (currentEnemy.tower == true) {
explosion._yscale = 200;
explosion._xscale = 100;
} else {
explosion._yscale = 65;
explosion._xscale = 65;
}
explosion.gotoAndPlay(1);
currentEnemy.oX = -1000;
currentEnemy.oY = -1000;
mouse._y = mouse._y - 5;
mouse.dy = mouse.dy - 1;
currentX = currentRock.oX + globalX;
currentY = currentRock.oY + globalY;
dx = mouse._x - currentX;
dy = mouse._y - currentY;
currentRock.oX = currentRock.oX + dx;
currentRock.oY = currentRock.oY + (dy + 27);
notputdown = -1;
}
currentEnemy.dead = true;
}
}
}
}
e++;
}
i++;
}
i = 1;
while (i <= rocks) {
if (i != notputdown) {
currentRock = eval ("rock" + i);
if (mouse.hitTest(currentRock)) {
if (mouse._y < ((currentRock._y - 25) + (mouse.dy * 1.2))) {
mouse.dy = 0;
mouse._y = (currentRock.oY + globalY) - 26;
onLand = true;
} else {
mouse.dx = mouse.dx * -1;
mouse._x = mouse._x + (mouse.dx * 2);
}
}
}
i++;
}
i = 0;
while (i <= buttons) {
currentResponder = eval ("responder" + i);
if (mouse.hitTest(currentResponder)) {
mouse.dx = mouse.dx * -1;
mouse._x = mouse._x + (mouse.dx * 2);
}
i++;
}
pressed = false;
if (Key.isDown(38)) {
if (onLand) {
mouse.dy = -2;
mouse._y = mouse._y + mouse.dy;
} else if (flightJuice > 0) {
pressed = true;
mouse.gotoAndStop("up");
mouse.dy = mouse.dy - thrust;
flightJuice = flightJuice - 1;
}
}
if (Key.isDown(40)) {
if (onLand) {
} else if (flightJuice > 0) {
pressed = true;
mouse.gotoAndStop("down");
mouse.dy = mouse.dy + thrust;
flightJuice = flightJuice - 1;
}
if (mouse.hitTest(topbarrier)) {
mouse._y = mouse._y + 7;
}
i = 0;
while (i <= lands) {
currentLand = eval ("land" + i);
if (mouse.hitTest(currentLand)) {
if (currentLand._y < (mouse._y - 5)) {
mouse._y = mouse._y + 7;
}
}
i++;
}
}
if (Key.isDown(37)) {
pressed = true;
if (onLand) {
mouse.dx = mouse.dx - thrust;
mouse.gotoAndStop("left");
} else if (flightJuice > 0) {
pressed = true;
mouse.dx = mouse.dx - thrust;
mouse.gotoAndStop("left");
flightJuice = flightJuice - 1;
}
i = 1;
while (i <= lands) {
currentLand = eval ("land" + i);
if (mouse.hitTest(currentLand)) {
if (i != onLandNum) {
if (mouse._y > currentLand._y) {
mouse._x = mouse._x - 7;
}
}
}
i++;
}
i = 1;
while (i <= rocks) {
currentRock = eval ("rock" + i);
if (mouse.hitTest(currentRock)) {
if (mouse._y > (currentRock._y - 26)) {
if (i != notputdown) {
mouse._x = mouse._x - 7;
}
}
}
i++;
}
i = 0;
while (i <= buttons) {
currentResponder = eval ("responder" + i);
if (mouse.hitTest(currentResponder)) {
mouse._x = mouse._x - 7;
}
i++;
}
if (mouse.hitTest(rightbarrier)) {
mouse._x = mouse._x - 7;
}
} else if (Key.isDown(39)) {
pressed = true;
if (onLand) {
mouse.dx = mouse.dx + thrust;
mouse.gotoAndStop("left");
} else if (flightJuice > 0) {
pressed = true;
mouse.dx = mouse.dx + thrust;
mouse.gotoAndStop("left");
flightJuice = flightJuice - 1;
}
mouse.gotoAndStop("right");
i = 1;
while (i <= lands) {
currentLand = eval ("land" + i);
if (mouse.hitTest(currentLand)) {
if (i != onLandNum) {
if (mouse._y > currentLand._y) {
mouse._x = mouse._x + 7;
}
}
}
i++;
}
i = 1;
while (i <= rocks) {
currentRock = eval ("rock" + i);
if (mouse.hitTest(currentRock)) {
if (mouse._y > (currentRock._y - 26)) {
if (i != notputdown) {
mouse._x = mouse._x + 7;
}
}
}
i++;
}
i = 0;
while (i <= buttons) {
currentResponder = eval ("responder" + i);
if (mouse.hitTest(currentResponder)) {
mouse._x = mouse._x + 7;
}
i++;
}
if (mouse.hitTest(leftbarrier)) {
mouse._x = mouse._x + 7;
}
} else if (mouse.dx < 0) {
mouse.dx = mouse.dx + thrust;
} else if (mouse.dx > 0) {
mouse.dx = mouse.dx - thrust;
}
if (mouse.dx < 0.1) {
if (mouse.dx > 0) {
mouse.dx = 0;
}
}
if (mouse.dx > -0.1) {
if (mouse.dx < 0) {
mouse.dx = 0;
}
}
if (pressed == false) {
mouse.gotoAndStop("center");
}
if (pressed == true) {
if (playsounds) {
thrustsoundpauser++;
if (thrustsoundpauser == totalforthruster) {
thruster.start(0, 1);
thrustsoundpauser = 0;
}
}
}
if (Key.isDown(32)) {
if (donePressSpace) {
donePressSpace = false;
if (notputdown == -1) {
i = 1;
while (i <= rocks) {
currentRock = eval ("rock" + i);
if (mouse.hitTest(currentRock)) {
if (playsounds) {
pickup.start(0, 1);
}
notputdown = i;
dx = mouse._x - currentRock._x;
dy = mouse._y - currentRock._y;
currentRock.oX = currentRock.oX + dx;
currentRock.oY = currentRock.oY + (dy + 27);
}
i++;
}
} else {
mouse._y = mouse._y - 5;
mouse.dy = mouse.dy - 1;
if (playsounds) {
pickup.start(0, 1);
}
currentRock = eval ("rock" + notputdown);
currentX = currentRock.oX + globalX;
currentY = currentRock.oY + globalY;
dx = mouse._x - currentX;
dy = mouse._y - currentY;
currentRock.oX = currentRock.oX + dx;
currentRock.oY = currentRock.oY + (dy + 27);
notputdown = -1;
}
}
} else {
donePressSpace = true;
}
i = 1;
while (i <= rocks) {
currentRock = eval ("rock" + i);
if (i != notputdown) {
currentRock.dy = currentRock.dy + gravity;
currentRock.oX = currentRock.oX + currentRock.dx;
currentRock.oY = currentRock.oY + currentRock.dy;
}
l = 1;
while (l <= lands) {
currentLand = eval ("land" + l);
if (currentRock.hitTest(currentLand)) {
if (currentRock._y < ((currentLand._y + currentRock.dy) + 0.5)) {
currentRock.oY = currentLand.oY;
currentRock.dy = 0;
currentRock.dx = 0;
} else if (currentRock._y > (currentLand._y + 25.5)) {
currentRock.dy = currentRock.dy * -1;
currentRock.oY = currentRock.oY + (currentRock.dy * 2);
} else {
currentRock.dx = currentRock.dx * -1;
currentRock.oX = currentRock.oX + (currentRock.dx * 4);
}
}
l++;
}
b = 1;
while (b <= rocks) {
otherRock = eval ("rock" + b);
if (b != i) {
if (currentRock.hitTest(otherRock)) {
if (currentRock.oY < otherRock.oY) {
currentRock.oY = otherRock.oY - 29;
currentRock.dy = 0;
currentRock.dx = 0;
}
}
}
b++;
}
b = 0;
while (b <= buttons) {
currentResponder = eval ("responder" + b);
if (currentRock.hitTest(currentResponder)) {
currentRock.dx = currentRock.dx * -1;
currentRock.oX = currentRock.oX + (currentRock.dx * 6);
}
b++;
}
i++;
}
i = 1;
while (i <= enemies) {
currentEnemy = eval ("enemy" + i);
if (currentEnemy.tower == false) {
if (currentEnemy.gotoLeft == true) {
if (currentEnemy.patrolPoint < currentEnemy.patrolLength) {
currentEnemy.oX = currentEnemy.oX + currentEnemy.speed;
currentEnemy.patrolPoint = currentEnemy.patrolPoint + currentEnemy.speed;
} else {
currentEnemy.gotoLeft = false;
currentEnemy.gotoAndPlay("turn");
}
} else if (currentEnemy.patrolPoint > 0) {
currentEnemy.oX = currentEnemy.oX - currentEnemy.speed;
currentEnemy.patrolPoint = currentEnemy.patrolPoint - currentEnemy.speed;
} else {
currentEnemy.gotoLeft = true;
currentEnemy.gotoAndPlay("turn");
}
}
i++;
}
i = 0;
while (i <= enemies) {
currentEnemy = eval ("enemy" + i);
if (mouse.hitTest(currentEnemy)) {
if (currentEnemy.tower == false) {
health = health - currentEnemy.damage;
}
}
if (currentEnemy.tower == true) {
currentBullet = eval ("bullet" + i);
if (mouse.hitTest(currentBullet)) {
health = health - currentEnemy.damage;
}
}
i++;
}
i = 0;
while (i <= buttons) {
currentButton = eval ("button" + i);
currentResponder = eval ("responder" + i);
hit = false;
r = 0;
while (r <= rocks) {
currentRock = eval ("rock" + r);
if (currentButton.hitTest(currentRock)) {
hit = true;
if (currentButton.pressed == false) {
currentButton.pressed = true;
currentResponder.oX = currentResponder.oX + 10000;
}
}
r++;
}
if (mousehitsbuttons == true) {
if (mouse.hitTest(currentButton)) {
hit = true;
if (currentButton.pressed == false) {
currentButton.pressed = true;
currentResponder.oX = currentResponder.oX + 10000;
}
}
}
if (hit == false) {
if (currentButton.pressed == true) {
currentButton.pressed = false;
currentResponder.oX = currentResponder.oX - 10000;
currentResponder.alpha = 0;
}
}
i++;
}
currentResponder.fadeOut = false;
currentResponder.alpha = 100;
currentResponder.speed = 6;
if (mouse.hitTest(end)) {
if (win == false) {
level++;
winS.start(0, 1);
end.gotoAndPlay("win");
win = true;
}
}
i = 0;
while (i <= enemies) {
currentTower = eval ("enemy" + i);
if (currentTower.tower == true) {
currentTop = eval ("towertop" + i);
currentBullet = eval ("bullet" + i);
currentTop._x = currentTower._x;
currentTop._y = currentTower._y - (95 * (currentTower._yscale / 100));
currentTop._yscale = currentTower._yscale;
dx = currentTop._x - mouse._x;
dy = currentTop._y - mouse._y;
radians = Math.atan(dy / dx);
degrees = (radians * 180) / Math.PI;
if (dx > 0) {
degrees = degrees + 180;
}
radians = (degrees / 180) * Math.PI;
degrees = degrees + 90;
currentTop._rotation = degrees;
distance = Math.sqrt((dx * dx) + (dy * dy));
currentTower.counter++;
if (currentTower.counter >= currentTower.counterLimit) {
currentTower.counter = 0;
currentBullet.oX = currentTower.oX;
currentBullet.oY = currentTower.oY - (95 * (currentTower._yscale / 100));
currentBullet.dx = Math.cos(radians) * currentTower.launchSpeed;
currentBullet.dy = Math.sin(radians) * currentTower.launchSpeed;
}
currentBullet.oX = currentBullet.oX + currentBullet.dx;
currentBullet.oY = currentBullet.oY + currentBullet.dy;
}
i++;
}
};
menu.onRelease = function () {
gotoAndStop ("menu");
};
currentAlpha = 100;
faderbox._alpha = currentAlpha;
fadeOut = function () {
if (loading == true) {
faderbox.gotoAndStop("blue");
}
if (loading == false) {
faderbox.gotoAndStop("red");
}
currentAlpha = currentAlpha + speed;
if (currentAlpha >= 100) {
currentAlpha = 100;
if (loading == true) {
gotoAndStop ("loading");
}
if (loading == false) {
gotoAndStop ("lose");
}
}
faderbox._x = 0;
faderbox._y = 0;
faderbox._alpha = currentAlpha;
};
fadeIn = function () {
faderbox.gotoAndStop("blue");
currentAlpha = currentAlpha - speed;
if (currentAlpha <= 0) {
currentAlpha = 0;
faderbox._x = -10000;
faderbox._y = -10000;
}
faderbox._alpha = currentAlpha;
if (health < topHealth) {
faderbox.gotoAndStop("red");
faderbox._x = 0;
faderbox._y = 0;
faderbox._alpha = (100 - (health * healthMultiplier)) - 20;
if (faderbox._alpha < 0) {
faderbox._alpha = 0;
}
currentAlpha = faderbox._alpha;
}
};
Frame 99
lands = 12;
total = 0;
rocks = 6;
objects = 5;
buttons = 3;
enemies = 8;
notputdown = -1;
health = topHealth;
healthMultiplier = 100 / health;
flightJuice = topFlightJuice;
flightMultiplier = 100 / flightJuice;
mouse.maxWidth = 62.1;
landWidth = 188;
onLandNum = 0;
globalX = 0;
globalY = 0;
win = false;
mousehitsbuttons = false;
topsmoke = 5;
smoke = 0;
thrustsoundpauser = 0;
totalforthruster = 4;
fadein = true;
loading = true;
stop();
mouse = eval (type);
mouse._x = startX._x;
mouse._y = startX._y;
startX._x = -100;
startX._y = -100;
mouse.dy = 0;
mouse.dx = 0;
mouse.oX = mouse._x;
mouse.oY = mouse._y;
explosion.oX = -10000;
explosion.oY = -10000;
leftbarrier.oX = leftbarrier._x;
leftbarrier.oY = leftbarrier._y;
rightbarrier.oX = rightbarrier._x;
rightbarrier.oY = rightbarrier._y;
topbarrier.oX = topbarrier._x;
topbarrier.oY = topbarrier._y;
bottombarrier.oX = bottombarrier._x;
bottombarrier.oY = bottombarrier._y;
end.oX = end._x;
end.oY = end._y;
enemy1.tower = false;
enemy2.tower = false;
enemy3.tower = false;
enemy4.tower = false;
enemy5.tower = true;
enemy6.tower = true;
enemy7.tower = true;
enemy8.tower = true;
i = 0;
while (i <= objects) {
currentObject = eval ("object" + i);
currentObject.oX = currentObject._x;
currentObject.oY = currentObject._y;
i++;
}
enemy1.gotoLeft = true;
i = 1;
while (i <= enemies) {
currentEnemy = eval ("enemy" + i);
currentEnemy.health = 8;
currentEnemy.speed = 2;
firstFlag = eval ("firstPatrolMarker" + i);
secondFlag = eval ("secondPatrolMarker" + i);
currentEnemy.patrolLength = secondFlag._x - firstFlag._x;
currentEnemy.patrolPoint = currentEnemy._x - firstFlag._x;
firstFlag._x = -100;
secondFlag._x = -100;
currentEnemy.damage = 1;
currentEnemy.oX = currentEnemy._x;
currentEnemy.oY = currentEnemy._y;
currentEnemy.dead = false;
currentEnemy.gotoLeft = true;
i++;
}
i = 0;
while (i <= enemies) {
currentEnemy = eval ("enemy" + i);
if (currentEnemy.tower == true) {
currentEnemy.counter = 0;
currentEnemy.counterLimit = 60;
currentEnemy.launchSpeed = 2;
currentEnemy.health = 20;
}
i++;
}
i = 0;
while (i <= buttons) {
currentButton = eval ("button" + i);
currentButton.pressed = false;
currentButton.oX = currentButton._x;
currentButton.oY = currentButton._y;
currentResponder = eval ("responder" + i);
currentResponder.oX = currentResponder._x;
currentResponder.oY = currentResponder._y;
currentResponder.fadeOut = false;
currentResponder.alpha = 100;
currentResponder.speed = 6;
i++;
}
i = 0;
while (i <= rocks) {
currentRock = eval ("rock" + i);
currentRock.oX = currentRock._x;
currentRock.oY = currentRock._y;
currentRock.dx = 0;
currentRock.dy = 0;
currentRock.originX = currentRock._x;
currentRock.originY = currentRock._y;
i++;
}
i = 0;
while (i <= lands) {
currentLand = eval ("land" + i);
currentLand.oX = currentLand._x;
currentLand.oY = currentLand._y;
i++;
}
mouse.onEnterFrame = function () {
if (fadein == true) {
fadeIn();
} else {
fadeOut();
}
mouse.dy = mouse.dy + gravity;
mouse._y = mouse._y + mouse.dy;
mouse._x = mouse._x + mouse.dx;
healthbar._xscale = health * healthMultiplier;
if (flightJuice > 0) {
flightbar._xscale = flightJuice * flightMultiplier;
}
if (health <= 0) {
fadein = false;
loading = false;
}
if (health < topHealth) {
health = health + (regenerateRate / 5);
}
if (flightJuice < topFlightJuice) {
flightJuice = flightJuice + regenerateRate;
}
dx = (Stage.width / 2) - mouse._x;
dy = (Stage.width / 2) - mouse._y;
dx = dx / 4;
dy = dy / 4;
if (mouse.dx > topspeed) {
mouse.dx = topspeed;
}
if (mouse.dx < (-topspeed)) {
mouse.dx = -topspeed;
}
if (mouse.dy > topspeed) {
mouse.dy = topspeed;
}
if (mouse.dy < (-topspeed)) {
mouse.dy = -topspeed;
}
globalX = globalX + dx;
globalY = globalY + dy;
i = 1;
while (i <= lands) {
currentLand = eval ("land" + i);
currentLand._x = currentLand.oX + globalX;
currentLand._y = currentLand.oY + globalY;
i++;
}
i = 1;
while (i <= rocks) {
currentRock = eval ("rock" + i);
currentRock._x = currentRock.oX + globalX;
currentRock._y = currentRock.oY + globalY;
i++;
}
i = 1;
while (i <= enemies) {
currentEnemy = eval ("enemy" + i);
currentEnemy._x = currentEnemy.oX + globalX;
currentEnemy._y = currentEnemy.oY + globalY;
if (currentEnemy.tower) {
currentBullet = eval ("bullet" + i);
currentBullet._x = currentBullet.oX + globalX;
currentBullet._y = currentBullet.oY + globalY;
}
i++;
}
explosion._x = explosion.oX + globalX;
explosion._y = explosion.oY + globalY;
i = 0;
while (i <= buttons) {
currentButton = eval ("button" + i);
currentResponder = eval ("responder" + i);
currentButton._x = currentButton.oX + globalX;
currentButton._y = currentButton.oY + globalY;
currentResponder._x = currentResponder.oX + globalX;
currentResponder._y = currentResponder.oY + globalY;
i++;
}
i = 0;
while (i <= objects) {
currentObject = eval ("object" + i);
currentObject._x = currentObject.oX + globalX;
currentObject._y = currentObject.oY + globalY;
i++;
}
leftbarrier._x = leftbarrier.oX + globalX;
leftbarrier._y = leftbarrier.oY + globalY;
rightbarrier._x = rightbarrier.oX + globalX;
rightbarrier._y = rightbarrier.oY + globalY;
topbarrier._x = topbarrier.oX + globalX;
topbarrier._y = topbarrier.oY + globalY;
bottombarrier._x = bottombarrier.oX + globalX;
bottombarrier._y = bottombarrier.oY + globalY;
end._x = end.oX + globalX;
end._y = end.oY + globalY;
mouse.oX = mouse.oX + dx;
mouse.oY = mouse.oY + dy;
mouse._y = mouse._y + dy;
mouse._x = mouse._x + dx;
bg._x = bg._x + (dx / 3);
bg._y = bg._y + (dy / 3);
if (notputdown != -1) {
currentRock = eval ("rock" + notputdown);
currentRock._x = mouse._x;
currentRock._y = mouse._y + 25;
currentRock.dx = mouse.dx;
currentRock.dy = mouse.dy;
}
onLand = false;
i = 1;
while (i <= lands) {
currentLand = eval ("land" + i);
if (mouse.hitTest(currentLand)) {
if (mouse._y < (currentLand._y + (mouse.dy * 1.2))) {
mouse.dy = 0;
mouse._y = currentLand._y;
onLand = true;
onLandNum = i;
} else if (mouse._y > (((currentLand._y + 35.5) + 25.4) + (mouse.dy * 1.2))) {
mouse.dy = mouse.dy * -1;
mouse._y = mouse._y + (mouse.dy * 1.5);
} else {
mouse.dx = mouse.dx * -1;
mouse._x = mouse._x + (mouse.dx * 2);
}
}
i++;
}
if (notputdown != -1) {
currentRock = eval ("rock" + notputdown);
i = 1;
while (i <= lands) {
currentLand = eval ("land" + i);
if (currentRock.hitTest(currentLand)) {
if (currentRock._y < (currentLand._y + (mouse.dy * 1.2))) {
mouse.dy = 0;
mouse._y = currentLand._y - 25;
onLand = true;
onLandNum = i;
} else if (currentRock._y > (((currentLand._y + 35) + 27) + (mouse.dy * 1.2))) {
mouse.dy = mouse.dy * -1;
mouse._y = mouse._y + (mouse.dy * 1.5);
} else {
mouse.dx = mouse.dx * -1;
mouse._x = mouse._x + (mouse.dx * 2);
}
}
i++;
}
notDropRock = eval ("rock" + notputdown);
i = 1;
while (i <= rocks) {
if (i != notputdown) {
currentRock = eval ("rock" + i);
if (notDropRock.hitTest(currentRock)) {
if (notDropRock._y < ((currentRock._y - 25) + (mouse.dy * 1.2))) {
mouse.dy = 0;
mouse._y = currentRock._y - 54;
onLand = true;
} else {
mouse.dx = mouse.dx * -1;
mouse._x = mouse._x + (mouse.dx * 2);
}
}
}
i++;
}
}
if (mouse.hitTest(leftbarrier)) {
mouse.dx = mouse.dx * -1;
mouse.oX = mouse.oX + (mouse.dx * 6);
}
if (mouse.hitTest(rightbarrier)) {
mouse.dx = mouse.dx * -1;
mouse.oX = mouse.oX + (mouse.dx * 6);
}
if (mouse.hitTest(topbarrier)) {
mouse.dy = mouse.dy * -1;
mouse.oY = mouse.oY + (mouse.dy * 6);
}
if (mouse.hitTest(bottombarrier)) {
mouse.dy = mouse.dy * -1;
mouse.oY = mouse.oY + (mouse.dy * 6);
}
i = 0;
while (i <= rocks) {
currentRock = eval ("rock" + i);
if (currentRock.hitTest(leftbarrier)) {
currentRock.dx = currentRock.dx * -1;
currentRock.oX = currentRock.oX + (currentRock.dx * 6);
}
if (currentRock.hitTest(rightbarrier)) {
currentRock.dx = currentRock.dx * -1;
currentRock.oX = currentRock.oX + (currentRock.dx * 6);
}
if (currentRock.hitTest(topbarrier)) {
currentRock.dy = currentRock.dy * -1;
currentRock.oY = currentRock.oY + (currentRock.dy * 6);
}
if (currentRock.hitTest(bottombarrier)) {
currentRock.dy = currentRock.dy * -1;
currentRock.oX = currentRock.oX + (currentRock.dy * 6);
}
i++;
}
i = 1;
while (i <= rocks) {
currentRock = eval ("rock" + i);
e = 1;
while (e <= enemies) {
currentEnemy = eval ("enemy" + e);
if (currentRock.hitTest(currentEnemy)) {
if (currentRock._y < currentEnemy._y) {
if (currentRock.dy > 0) {
if (playsounds) {
}
currentEnemy.health = currentEnemy.health - currentRock.dy;
if (currentEnemy.tower == false) {
currentEnemy._yscale = currentEnemy.health * 10;
} else {
currentEnemy._yscale = currentEnemy.health * 5;
}
currentEnemy.speed = 0;
currentRock.dy = 0;
currentRock.dx = 0;
if (notputdown == i) {
mouse._y = mouse._y - 5;
mouse.dy = mouse.dy - 1;
currentX = currentRock.oX + globalX;
currentY = currentRock.oY + globalY;
dx = mouse._x - currentX;
dy = mouse._y - currentY;
currentRock.oX = currentRock.oX + dx;
currentRock.oY = currentRock.oY + (dy + 27);
notputdown = -1;
}
if (currentEnemy.health <= 1) {
if (i != notputdown) {
if (playsounds) {
explosionS.start(0, 1);
}
explosion.oX = currentEnemy.oX;
explosion.oY = currentEnemy.oY;
if (currentEnemy.tower == true) {
explosion._yscale = 200;
explosion._xscale = 100;
} else {
explosion._yscale = 65;
explosion._xscale = 65;
}
explosion.gotoAndPlay(1);
currentEnemy.oX = -1000;
currentEnemy.oY = -1000;
} else {
if (playsounds) {
explosionS.start(0, 1);
}
if (currentEnemy.tower == true) {
explosion._yscale = 200;
explosion._xscale = 100;
} else {
explosion._yscale = 65;
explosion._xscale = 65;
}
explosion.gotoAndPlay(1);
currentEnemy.oX = -1000;
currentEnemy.oY = -1000;
mouse._y = mouse._y - 5;
mouse.dy = mouse.dy - 1;
currentX = currentRock.oX + globalX;
currentY = currentRock.oY + globalY;
dx = mouse._x - currentX;
dy = mouse._y - currentY;
currentRock.oX = currentRock.oX + dx;
currentRock.oY = currentRock.oY + (dy + 27);
notputdown = -1;
}
currentEnemy.dead = true;
}
}
}
}
e++;
}
i++;
}
i = 1;
while (i <= rocks) {
if (i != notputdown) {
currentRock = eval ("rock" + i);
if (mouse.hitTest(currentRock)) {
if (mouse._y < ((currentRock._y - 25) + (mouse.dy * 1.2))) {
mouse.dy = 0;
mouse._y = (currentRock.oY + globalY) - 26;
onLand = true;
} else {
mouse.dx = mouse.dx * -1;
mouse._x = mouse._x + (mouse.dx * 2);
}
}
}
i++;
}
i = 0;
while (i <= buttons) {
currentResponder = eval ("responder" + i);
if (mouse.hitTest(currentResponder)) {
mouse.dx = mouse.dx * -1;
mouse._x = mouse._x + (mouse.dx * 2);
}
i++;
}
pressed = false;
if (Key.isDown(38)) {
if (onLand) {
mouse.dy = -2;
mouse._y = mouse._y + mouse.dy;
} else if (flightJuice > 0) {
pressed = true;
mouse.gotoAndStop("up");
mouse.dy = mouse.dy - thrust;
flightJuice = flightJuice - 1;
}
}
if (Key.isDown(40)) {
if (onLand) {
} else if (flightJuice > 0) {
pressed = true;
mouse.gotoAndStop("down");
mouse.dy = mouse.dy + thrust;
flightJuice = flightJuice - 1;
}
if (mouse.hitTest(topbarrier)) {
mouse._y = mouse._y + 7;
}
i = 0;
while (i <= lands) {
currentLand = eval ("land" + i);
if (mouse.hitTest(currentLand)) {
if (currentLand._y < (mouse._y - 5)) {
mouse._y = mouse._y + 7;
}
}
i++;
}
}
if (Key.isDown(37)) {
pressed = true;
if (onLand) {
mouse.dx = mouse.dx - thrust;
mouse.gotoAndStop("left");
} else if (flightJuice > 0) {
pressed = true;
mouse.dx = mouse.dx - thrust;
mouse.gotoAndStop("left");
flightJuice = flightJuice - 1;
}
i = 1;
while (i <= lands) {
currentLand = eval ("land" + i);
if (mouse.hitTest(currentLand)) {
if (i != onLandNum) {
if (mouse._y > currentLand._y) {
mouse._x = mouse._x - 7;
}
}
}
i++;
}
i = 1;
while (i <= rocks) {
currentRock = eval ("rock" + i);
if (mouse.hitTest(currentRock)) {
if (mouse._y > (currentRock._y - 26)) {
if (i != notputdown) {
mouse._x = mouse._x - 7;
}
}
}
i++;
}
i = 0;
while (i <= buttons) {
currentResponder = eval ("responder" + i);
if (mouse.hitTest(currentResponder)) {
mouse._x = mouse._x - 7;
}
i++;
}
if (mouse.hitTest(rightbarrier)) {
mouse._x = mouse._x - 7;
}
} else if (Key.isDown(39)) {
pressed = true;
if (onLand) {
mouse.dx = mouse.dx + thrust;
mouse.gotoAndStop("left");
} else if (flightJuice > 0) {
pressed = true;
mouse.dx = mouse.dx + thrust;
mouse.gotoAndStop("left");
flightJuice = flightJuice - 1;
}
mouse.gotoAndStop("right");
i = 1;
while (i <= lands) {
currentLand = eval ("land" + i);
if (mouse.hitTest(currentLand)) {
if (i != onLandNum) {
if (mouse._y > currentLand._y) {
mouse._x = mouse._x + 7;
}
}
}
i++;
}
i = 1;
while (i <= rocks) {
currentRock = eval ("rock" + i);
if (mouse.hitTest(currentRock)) {
if (mouse._y > (currentRock._y - 26)) {
if (i != notputdown) {
mouse._x = mouse._x + 7;
}
}
}
i++;
}
i = 0;
while (i <= buttons) {
currentResponder = eval ("responder" + i);
if (mouse.hitTest(currentResponder)) {
mouse._x = mouse._x + 7;
}
i++;
}
if (mouse.hitTest(leftbarrier)) {
mouse._x = mouse._x + 7;
}
} else if (mouse.dx < 0) {
mouse.dx = mouse.dx + thrust;
} else if (mouse.dx > 0) {
mouse.dx = mouse.dx - thrust;
}
if (mouse.dx < 0.1) {
if (mouse.dx > 0) {
mouse.dx = 0;
}
}
if (mouse.dx > -0.1) {
if (mouse.dx < 0) {
mouse.dx = 0;
}
}
if (pressed == false) {
mouse.gotoAndStop("center");
}
if (pressed == true) {
if (playsounds) {
thrustsoundpauser++;
if (thrustsoundpauser == totalforthruster) {
thruster.start(0, 1);
thrustsoundpauser = 0;
}
}
}
if (Key.isDown(32)) {
if (donePressSpace) {
donePressSpace = false;
if (notputdown == -1) {
i = 1;
while (i <= rocks) {
currentRock = eval ("rock" + i);
if (mouse.hitTest(currentRock)) {
if (playsounds) {
pickup.start(0, 1);
}
notputdown = i;
dx = mouse._x - currentRock._x;
dy = mouse._y - currentRock._y;
currentRock.oX = currentRock.oX + dx;
currentRock.oY = currentRock.oY + (dy + 27);
}
i++;
}
} else {
mouse._y = mouse._y - 5;
mouse.dy = mouse.dy - 1;
if (playsounds) {
pickup.start(0, 1);
}
currentRock = eval ("rock" + notputdown);
currentX = currentRock.oX + globalX;
currentY = currentRock.oY + globalY;
dx = mouse._x - currentX;
dy = mouse._y - currentY;
currentRock.oX = currentRock.oX + dx;
currentRock.oY = currentRock.oY + (dy + 27);
notputdown = -1;
}
}
} else {
donePressSpace = true;
}
i = 1;
while (i <= rocks) {
currentRock = eval ("rock" + i);
if (i != notputdown) {
currentRock.dy = currentRock.dy + gravity;
currentRock.oX = currentRock.oX + currentRock.dx;
currentRock.oY = currentRock.oY + currentRock.dy;
}
l = 1;
while (l <= lands) {
currentLand = eval ("land" + l);
if (currentRock.hitTest(currentLand)) {
if (currentRock._y < ((currentLand._y + currentRock.dy) + 0.5)) {
currentRock.oY = currentLand.oY;
currentRock.dy = 0;
currentRock.dx = 0;
} else if (currentRock._y > (currentLand._y + 25.5)) {
currentRock.dy = currentRock.dy * -1;
currentRock.oY = currentRock.oY + (currentRock.dy * 2);
} else {
currentRock.dx = currentRock.dx * -1;
currentRock.oX = currentRock.oX + (currentRock.dx * 4);
}
}
l++;
}
b = 1;
while (b <= rocks) {
otherRock = eval ("rock" + b);
if (b != i) {
if (currentRock.hitTest(otherRock)) {
if (currentRock.oY < otherRock.oY) {
currentRock.oY = otherRock.oY - 29;
currentRock.dy = 0;
currentRock.dx = 0;
}
}
}
b++;
}
b = 0;
while (b <= buttons) {
currentResponder = eval ("responder" + b);
if (currentRock.hitTest(currentResponder)) {
currentRock.dx = currentRock.dx * -1;
currentRock.oX = currentRock.oX + (currentRock.dx * 6);
}
b++;
}
i++;
}
i = 1;
while (i <= enemies) {
currentEnemy = eval ("enemy" + i);
if (currentEnemy.tower == false) {
if (currentEnemy.gotoLeft == true) {
if (currentEnemy.patrolPoint < currentEnemy.patrolLength) {
currentEnemy.oX = currentEnemy.oX + currentEnemy.speed;
currentEnemy.patrolPoint = currentEnemy.patrolPoint + currentEnemy.speed;
} else {
currentEnemy.gotoLeft = false;
currentEnemy.gotoAndPlay("turn");
}
} else if (currentEnemy.patrolPoint > 0) {
currentEnemy.oX = currentEnemy.oX - currentEnemy.speed;
currentEnemy.patrolPoint = currentEnemy.patrolPoint - currentEnemy.speed;
} else {
currentEnemy.gotoLeft = true;
currentEnemy.gotoAndPlay("turn");
}
}
i++;
}
i = 0;
while (i <= enemies) {
currentEnemy = eval ("enemy" + i);
if (mouse.hitTest(currentEnemy)) {
if (currentEnemy.tower == false) {
health = health - currentEnemy.damage;
}
}
if (currentEnemy.tower == true) {
currentBullet = eval ("bullet" + i);
if (mouse.hitTest(currentBullet)) {
health = health - currentEnemy.damage;
}
}
i++;
}
i = 0;
while (i <= buttons) {
currentButton = eval ("button" + i);
currentResponder = eval ("responder" + i);
hit = false;
r = 0;
while (r <= rocks) {
currentRock = eval ("rock" + r);
if (currentButton.hitTest(currentRock)) {
hit = true;
if (currentButton.pressed == false) {
currentButton.pressed = true;
currentResponder.oX = currentResponder.oX + 10000;
}
}
r++;
}
if (mousehitsbuttons == true) {
if (mouse.hitTest(currentButton)) {
hit = true;
if (currentButton.pressed == false) {
currentButton.pressed = true;
currentResponder.oX = currentResponder.oX + 10000;
}
}
}
if (hit == false) {
if (currentButton.pressed == true) {
currentButton.pressed = false;
currentResponder.oX = currentResponder.oX - 10000;
currentResponder.alpha = 0;
}
}
i++;
}
currentResponder.fadeOut = false;
currentResponder.alpha = 100;
currentResponder.speed = 6;
if (mouse.hitTest(end)) {
if (win == false) {
level++;
winS.start(0, 1);
end.gotoAndPlay("win");
win = true;
}
}
i = 0;
while (i <= enemies) {
currentTower = eval ("enemy" + i);
if (currentTower.tower == true) {
currentTop = eval ("towertop" + i);
currentBullet = eval ("bullet" + i);
currentTop._x = currentTower._x;
currentTop._y = currentTower._y - (95 * (currentTower._yscale / 100));
currentTop._yscale = currentTower._yscale;
dx = currentTop._x - mouse._x;
dy = currentTop._y - mouse._y;
radians = Math.atan(dy / dx);
degrees = (radians * 180) / Math.PI;
if (dx > 0) {
degrees = degrees + 180;
}
radians = (degrees / 180) * Math.PI;
degrees = degrees + 90;
currentTop._rotation = degrees;
distance = Math.sqrt((dx * dx) + (dy * dy));
currentTower.counter++;
if (currentTower.counter >= currentTower.counterLimit) {
currentTower.counter = 0;
currentBullet.oX = currentTower.oX;
currentBullet.oY = currentTower.oY - (95 * (currentTower._yscale / 100));
currentBullet.dx = Math.cos(radians) * currentTower.launchSpeed;
currentBullet.dy = Math.sin(radians) * currentTower.launchSpeed;
}
currentBullet.oX = currentBullet.oX + currentBullet.dx;
currentBullet.oY = currentBullet.oY + currentBullet.dy;
}
i++;
}
};
menu.onRelease = function () {
gotoAndStop ("menu");
};
currentAlpha = 100;
faderbox._alpha = currentAlpha;
fadeOut = function () {
if (loading == true) {
faderbox.gotoAndStop("blue");
}
if (loading == false) {
faderbox.gotoAndStop("red");
}
currentAlpha = currentAlpha + speed;
if (currentAlpha >= 100) {
currentAlpha = 100;
if (loading == true) {
gotoAndStop ("loading");
}
if (loading == false) {
gotoAndStop ("lose");
}
}
faderbox._x = 0;
faderbox._y = 0;
faderbox._alpha = currentAlpha;
};
fadeIn = function () {
faderbox.gotoAndStop("blue");
currentAlpha = currentAlpha - speed;
if (currentAlpha <= 0) {
currentAlpha = 0;
faderbox._x = -10000;
faderbox._y = -10000;
}
faderbox._alpha = currentAlpha;
if (health < topHealth) {
faderbox.gotoAndStop("red");
faderbox._x = 0;
faderbox._y = 0;
faderbox._alpha = (100 - (health * healthMultiplier)) - 20;
if (faderbox._alpha < 0) {
faderbox._alpha = 0;
}
currentAlpha = faderbox._alpha;
}
};
Frame 100
lands = 12;
total = 0;
rocks = 6;
objects = 5;
buttons = 3;
enemies = 8;
notputdown = -1;
health = topHealth;
healthMultiplier = 100 / health;
flightJuice = topFlightJuice;
flightMultiplier = 100 / flightJuice;
mouse.maxWidth = 62.1;
landWidth = 188;
onLandNum = 0;
globalX = 0;
globalY = 0;
win = false;
mousehitsbuttons = false;
topsmoke = 5;
smoke = 0;
thrustsoundpauser = 0;
totalforthruster = 4;
fadein = true;
loading = true;
stop();
mouse = eval (type);
mouse._x = startX._x;
mouse._y = startX._y;
startX._x = -100;
startX._y = -100;
mouse.dy = 0;
mouse.dx = 0;
mouse.oX = mouse._x;
mouse.oY = mouse._y;
explosion.oX = -10000;
explosion.oY = -10000;
leftbarrier.oX = leftbarrier._x;
leftbarrier.oY = leftbarrier._y;
rightbarrier.oX = rightbarrier._x;
rightbarrier.oY = rightbarrier._y;
topbarrier.oX = topbarrier._x;
topbarrier.oY = topbarrier._y;
bottombarrier.oX = bottombarrier._x;
bottombarrier.oY = bottombarrier._y;
end.oX = end._x;
end.oY = end._y;
enemy1.tower = false;
enemy2.tower = false;
enemy3.tower = false;
enemy4.tower = false;
enemy5.tower = true;
enemy6.tower = true;
enemy7.tower = true;
enemy8.tower = true;
i = 0;
while (i <= objects) {
currentObject = eval ("object" + i);
currentObject.oX = currentObject._x;
currentObject.oY = currentObject._y;
i++;
}
enemy1.gotoLeft = true;
i = 1;
while (i <= enemies) {
currentEnemy = eval ("enemy" + i);
currentEnemy.health = 8;
currentEnemy.speed = 2;
firstFlag = eval ("firstPatrolMarker" + i);
secondFlag = eval ("secondPatrolMarker" + i);
currentEnemy.patrolLength = secondFlag._x - firstFlag._x;
currentEnemy.patrolPoint = currentEnemy._x - firstFlag._x;
firstFlag._x = -100;
secondFlag._x = -100;
currentEnemy.damage = 1;
currentEnemy.oX = currentEnemy._x;
currentEnemy.oY = currentEnemy._y;
currentEnemy.dead = false;
currentEnemy.gotoLeft = true;
i++;
}
i = 0;
while (i <= enemies) {
currentEnemy = eval ("enemy" + i);
if (currentEnemy.tower == true) {
currentEnemy.counter = 0;
currentEnemy.counterLimit = 60;
currentEnemy.launchSpeed = 2;
currentEnemy.health = 20;
}
i++;
}
i = 0;
while (i <= buttons) {
currentButton = eval ("button" + i);
currentButton.pressed = false;
currentButton.oX = currentButton._x;
currentButton.oY = currentButton._y;
currentResponder = eval ("responder" + i);
currentResponder.oX = currentResponder._x;
currentResponder.oY = currentResponder._y;
currentResponder.fadeOut = false;
currentResponder.alpha = 100;
currentResponder.speed = 6;
i++;
}
i = 0;
while (i <= rocks) {
currentRock = eval ("rock" + i);
currentRock.oX = currentRock._x;
currentRock.oY = currentRock._y;
currentRock.dx = 0;
currentRock.dy = 0;
currentRock.originX = currentRock._x;
currentRock.originY = currentRock._y;
i++;
}
i = 0;
while (i <= lands) {
currentLand = eval ("land" + i);
currentLand.oX = currentLand._x;
currentLand.oY = currentLand._y;
i++;
}
mouse.onEnterFrame = function () {
if (fadein == true) {
fadeIn();
} else {
fadeOut();
}
mouse.dy = mouse.dy + gravity;
mouse._y = mouse._y + mouse.dy;
mouse._x = mouse._x + mouse.dx;
healthbar._xscale = health * healthMultiplier;
if (flightJuice > 0) {
flightbar._xscale = flightJuice * flightMultiplier;
}
if (health <= 0) {
fadein = false;
loading = false;
}
if (health < topHealth) {
health = health + (regenerateRate / 5);
}
if (flightJuice < topFlightJuice) {
flightJuice = flightJuice + regenerateRate;
}
dx = (Stage.width / 2) - mouse._x;
dy = (Stage.width / 2) - mouse._y;
dx = dx / 4;
dy = dy / 4;
if (mouse.dx > topspeed) {
mouse.dx = topspeed;
}
if (mouse.dx < (-topspeed)) {
mouse.dx = -topspeed;
}
if (mouse.dy > topspeed) {
mouse.dy = topspeed;
}
if (mouse.dy < (-topspeed)) {
mouse.dy = -topspeed;
}
globalX = globalX + dx;
globalY = globalY + dy;
i = 1;
while (i <= lands) {
currentLand = eval ("land" + i);
currentLand._x = currentLand.oX + globalX;
currentLand._y = currentLand.oY + globalY;
i++;
}
i = 1;
while (i <= rocks) {
currentRock = eval ("rock" + i);
currentRock._x = currentRock.oX + globalX;
currentRock._y = currentRock.oY + globalY;
i++;
}
i = 1;
while (i <= enemies) {
currentEnemy = eval ("enemy" + i);
currentEnemy._x = currentEnemy.oX + globalX;
currentEnemy._y = currentEnemy.oY + globalY;
if (currentEnemy.tower) {
currentBullet = eval ("bullet" + i);
currentBullet._x = currentBullet.oX + globalX;
currentBullet._y = currentBullet.oY + globalY;
}
i++;
}
explosion._x = explosion.oX + globalX;
explosion._y = explosion.oY + globalY;
i = 0;
while (i <= buttons) {
currentButton = eval ("button" + i);
currentResponder = eval ("responder" + i);
currentButton._x = currentButton.oX + globalX;
currentButton._y = currentButton.oY + globalY;
currentResponder._x = currentResponder.oX + globalX;
currentResponder._y = currentResponder.oY + globalY;
i++;
}
i = 0;
while (i <= objects) {
currentObject = eval ("object" + i);
currentObject._x = currentObject.oX + globalX;
currentObject._y = currentObject.oY + globalY;
i++;
}
leftbarrier._x = leftbarrier.oX + globalX;
leftbarrier._y = leftbarrier.oY + globalY;
rightbarrier._x = rightbarrier.oX + globalX;
rightbarrier._y = rightbarrier.oY + globalY;
topbarrier._x = topbarrier.oX + globalX;
topbarrier._y = topbarrier.oY + globalY;
bottombarrier._x = bottombarrier.oX + globalX;
bottombarrier._y = bottombarrier.oY + globalY;
end._x = end.oX + globalX;
end._y = end.oY + globalY;
mouse.oX = mouse.oX + dx;
mouse.oY = mouse.oY + dy;
mouse._y = mouse._y + dy;
mouse._x = mouse._x + dx;
bg._x = bg._x + (dx / 3);
bg._y = bg._y + (dy / 3);
if (notputdown != -1) {
currentRock = eval ("rock" + notputdown);
currentRock._x = mouse._x;
currentRock._y = mouse._y + 25;
currentRock.dx = mouse.dx;
currentRock.dy = mouse.dy;
}
onLand = false;
i = 1;
while (i <= lands) {
currentLand = eval ("land" + i);
if (mouse.hitTest(currentLand)) {
if (mouse._y < (currentLand._y + (mouse.dy * 1.2))) {
mouse.dy = 0;
mouse._y = currentLand._y;
onLand = true;
onLandNum = i;
} else if (mouse._y > (((currentLand._y + 35.5) + 25.4) + (mouse.dy * 1.2))) {
mouse.dy = mouse.dy * -1;
mouse._y = mouse._y + (mouse.dy * 1.5);
} else {
mouse.dx = mouse.dx * -1;
mouse._x = mouse._x + (mouse.dx * 2);
}
}
i++;
}
if (notputdown != -1) {
currentRock = eval ("rock" + notputdown);
i = 1;
while (i <= lands) {
currentLand = eval ("land" + i);
if (currentRock.hitTest(currentLand)) {
if (currentRock._y < (currentLand._y + (mouse.dy * 1.2))) {
mouse.dy = 0;
mouse._y = currentLand._y - 25;
onLand = true;
onLandNum = i;
} else if (currentRock._y > (((currentLand._y + 35) + 27) + (mouse.dy * 1.2))) {
mouse.dy = mouse.dy * -1;
mouse._y = mouse._y + (mouse.dy * 1.5);
} else {
mouse.dx = mouse.dx * -1;
mouse._x = mouse._x + (mouse.dx * 2);
}
}
i++;
}
notDropRock = eval ("rock" + notputdown);
i = 1;
while (i <= rocks) {
if (i != notputdown) {
currentRock = eval ("rock" + i);
if (notDropRock.hitTest(currentRock)) {
if (notDropRock._y < ((currentRock._y - 25) + (mouse.dy * 1.2))) {
mouse.dy = 0;
mouse._y = currentRock._y - 54;
onLand = true;
} else {
mouse.dx = mouse.dx * -1;
mouse._x = mouse._x + (mouse.dx * 2);
}
}
}
i++;
}
}
if (mouse.hitTest(leftbarrier)) {
mouse.dx = mouse.dx * -1;
mouse.oX = mouse.oX + (mouse.dx * 6);
}
if (mouse.hitTest(rightbarrier)) {
mouse.dx = mouse.dx * -1;
mouse.oX = mouse.oX + (mouse.dx * 6);
}
if (mouse.hitTest(topbarrier)) {
mouse.dy = mouse.dy * -1;
mouse.oY = mouse.oY + (mouse.dy * 6);
}
if (mouse.hitTest(bottombarrier)) {
mouse.dy = mouse.dy * -1;
mouse.oY = mouse.oY + (mouse.dy * 6);
}
i = 0;
while (i <= rocks) {
currentRock = eval ("rock" + i);
if (currentRock.hitTest(leftbarrier)) {
currentRock.dx = currentRock.dx * -1;
currentRock.oX = currentRock.oX + (currentRock.dx * 6);
}
if (currentRock.hitTest(rightbarrier)) {
currentRock.dx = currentRock.dx * -1;
currentRock.oX = currentRock.oX + (currentRock.dx * 6);
}
if (currentRock.hitTest(topbarrier)) {
currentRock.dy = currentRock.dy * -1;
currentRock.oY = currentRock.oY + (currentRock.dy * 6);
}
if (currentRock.hitTest(bottombarrier)) {
currentRock.dy = currentRock.dy * -1;
currentRock.oX = currentRock.oX + (currentRock.dy * 6);
}
i++;
}
i = 1;
while (i <= rocks) {
currentRock = eval ("rock" + i);
e = 1;
while (e <= enemies) {
currentEnemy = eval ("enemy" + e);
if (currentRock.hitTest(currentEnemy)) {
if (currentRock._y < currentEnemy._y) {
if (currentRock.dy > 0) {
if (playsounds) {
}
currentEnemy.health = currentEnemy.health - currentRock.dy;
if (currentEnemy.tower == false) {
currentEnemy._yscale = currentEnemy.health * 10;
} else {
currentEnemy._yscale = currentEnemy.health * 5;
}
currentEnemy.speed = 0;
currentRock.dy = 0;
currentRock.dx = 0;
if (notputdown == i) {
mouse._y = mouse._y - 5;
mouse.dy = mouse.dy - 1;
currentX = currentRock.oX + globalX;
currentY = currentRock.oY + globalY;
dx = mouse._x - currentX;
dy = mouse._y - currentY;
currentRock.oX = currentRock.oX + dx;
currentRock.oY = currentRock.oY + (dy + 27);
notputdown = -1;
}
if (currentEnemy.health <= 1) {
if (i != notputdown) {
if (playsounds) {
explosionS.start(0, 1);
}
explosion.oX = currentEnemy.oX;
explosion.oY = currentEnemy.oY;
if (currentEnemy.tower == true) {
explosion._yscale = 200;
explosion._xscale = 100;
} else {
explosion._yscale = 65;
explosion._xscale = 65;
}
explosion.gotoAndPlay(1);
currentEnemy.oX = -1000;
currentEnemy.oY = -1000;
} else {
if (playsounds) {
explosionS.start(0, 1);
}
if (currentEnemy.tower == true) {
explosion._yscale = 200;
explosion._xscale = 100;
} else {
explosion._yscale = 65;
explosion._xscale = 65;
}
explosion.gotoAndPlay(1);
currentEnemy.oX = -1000;
currentEnemy.oY = -1000;
mouse._y = mouse._y - 5;
mouse.dy = mouse.dy - 1;
currentX = currentRock.oX + globalX;
currentY = currentRock.oY + globalY;
dx = mouse._x - currentX;
dy = mouse._y - currentY;
currentRock.oX = currentRock.oX + dx;
currentRock.oY = currentRock.oY + (dy + 27);
notputdown = -1;
}
currentEnemy.dead = true;
}
}
}
}
e++;
}
i++;
}
i = 1;
while (i <= rocks) {
if (i != notputdown) {
currentRock = eval ("rock" + i);
if (mouse.hitTest(currentRock)) {
if (mouse._y < ((currentRock._y - 25) + (mouse.dy * 1.2))) {
mouse.dy = 0;
mouse._y = (currentRock.oY + globalY) - 26;
onLand = true;
} else {
mouse.dx = mouse.dx * -1;
mouse._x = mouse._x + (mouse.dx * 2);
}
}
}
i++;
}
i = 0;
while (i <= buttons) {
currentResponder = eval ("responder" + i);
if (mouse.hitTest(currentResponder)) {
mouse.dx = mouse.dx * -1;
mouse._x = mouse._x + (mouse.dx * 2);
}
i++;
}
pressed = false;
if (Key.isDown(38)) {
if (onLand) {
mouse.dy = -2;
mouse._y = mouse._y + mouse.dy;
} else if (flightJuice > 0) {
pressed = true;
mouse.gotoAndStop("up");
mouse.dy = mouse.dy - thrust;
flightJuice = flightJuice - 1;
}
}
if (Key.isDown(40)) {
if (onLand) {
} else if (flightJuice > 0) {
pressed = true;
mouse.gotoAndStop("down");
mouse.dy = mouse.dy + thrust;
flightJuice = flightJuice - 1;
}
if (mouse.hitTest(topbarrier)) {
mouse._y = mouse._y + 7;
}
i = 0;
while (i <= lands) {
currentLand = eval ("land" + i);
if (mouse.hitTest(currentLand)) {
if (currentLand._y < (mouse._y - 5)) {
mouse._y = mouse._y + 7;
}
}
i++;
}
}
if (Key.isDown(37)) {
pressed = true;
if (onLand) {
mouse.dx = mouse.dx - thrust;
mouse.gotoAndStop("left");
} else if (flightJuice > 0) {
pressed = true;
mouse.dx = mouse.dx - thrust;
mouse.gotoAndStop("left");
flightJuice = flightJuice - 1;
}
i = 1;
while (i <= lands) {
currentLand = eval ("land" + i);
if (mouse.hitTest(currentLand)) {
if (i != onLandNum) {
if (mouse._y > currentLand._y) {
mouse._x = mouse._x - 7;
}
}
}
i++;
}
i = 1;
while (i <= rocks) {
currentRock = eval ("rock" + i);
if (mouse.hitTest(currentRock)) {
if (mouse._y > (currentRock._y - 26)) {
if (i != notputdown) {
mouse._x = mouse._x - 7;
}
}
}
i++;
}
i = 0;
while (i <= buttons) {
currentResponder = eval ("responder" + i);
if (mouse.hitTest(currentResponder)) {
mouse._x = mouse._x - 7;
}
i++;
}
if (mouse.hitTest(rightbarrier)) {
mouse._x = mouse._x - 7;
}
} else if (Key.isDown(39)) {
pressed = true;
if (onLand) {
mouse.dx = mouse.dx + thrust;
mouse.gotoAndStop("left");
} else if (flightJuice > 0) {
pressed = true;
mouse.dx = mouse.dx + thrust;
mouse.gotoAndStop("left");
flightJuice = flightJuice - 1;
}
mouse.gotoAndStop("right");
i = 1;
while (i <= lands) {
currentLand = eval ("land" + i);
if (mouse.hitTest(currentLand)) {
if (i != onLandNum) {
if (mouse._y > currentLand._y) {
mouse._x = mouse._x + 7;
}
}
}
i++;
}
i = 1;
while (i <= rocks) {
currentRock = eval ("rock" + i);
if (mouse.hitTest(currentRock)) {
if (mouse._y > (currentRock._y - 26)) {
if (i != notputdown) {
mouse._x = mouse._x + 7;
}
}
}
i++;
}
i = 0;
while (i <= buttons) {
currentResponder = eval ("responder" + i);
if (mouse.hitTest(currentResponder)) {
mouse._x = mouse._x + 7;
}
i++;
}
if (mouse.hitTest(leftbarrier)) {
mouse._x = mouse._x + 7;
}
} else if (mouse.dx < 0) {
mouse.dx = mouse.dx + thrust;
} else if (mouse.dx > 0) {
mouse.dx = mouse.dx - thrust;
}
if (mouse.dx < 0.1) {
if (mouse.dx > 0) {
mouse.dx = 0;
}
}
if (mouse.dx > -0.1) {
if (mouse.dx < 0) {
mouse.dx = 0;
}
}
if (pressed == false) {
mouse.gotoAndStop("center");
}
if (pressed == true) {
if (playsounds) {
thrustsoundpauser++;
if (thrustsoundpauser == totalforthruster) {
thruster.start(0, 1);
thrustsoundpauser = 0;
}
}
}
if (Key.isDown(32)) {
if (donePressSpace) {
donePressSpace = false;
if (notputdown == -1) {
i = 1;
while (i <= rocks) {
currentRock = eval ("rock" + i);
if (mouse.hitTest(currentRock)) {
if (playsounds) {
pickup.start(0, 1);
}
notputdown = i;
dx = mouse._x - currentRock._x;
dy = mouse._y - currentRock._y;
currentRock.oX = currentRock.oX + dx;
currentRock.oY = currentRock.oY + (dy + 27);
}
i++;
}
} else {
mouse._y = mouse._y - 5;
mouse.dy = mouse.dy - 1;
if (playsounds) {
pickup.start(0, 1);
}
currentRock = eval ("rock" + notputdown);
currentX = currentRock.oX + globalX;
currentY = currentRock.oY + globalY;
dx = mouse._x - currentX;
dy = mouse._y - currentY;
currentRock.oX = currentRock.oX + dx;
currentRock.oY = currentRock.oY + (dy + 27);
notputdown = -1;
}
}
} else {
donePressSpace = true;
}
i = 1;
while (i <= rocks) {
currentRock = eval ("rock" + i);
if (i != notputdown) {
currentRock.dy = currentRock.dy + gravity;
currentRock.oX = currentRock.oX + currentRock.dx;
currentRock.oY = currentRock.oY + currentRock.dy;
}
l = 1;
while (l <= lands) {
currentLand = eval ("land" + l);
if (currentRock.hitTest(currentLand)) {
if (currentRock._y < ((currentLand._y + currentRock.dy) + 0.5)) {
currentRock.oY = currentLand.oY;
currentRock.dy = 0;
currentRock.dx = 0;
} else if (currentRock._y > (currentLand._y + 25.5)) {
currentRock.dy = currentRock.dy * -1;
currentRock.oY = currentRock.oY + (currentRock.dy * 2);
} else {
currentRock.dx = currentRock.dx * -1;
currentRock.oX = currentRock.oX + (currentRock.dx * 4);
}
}
l++;
}
b = 1;
while (b <= rocks) {
otherRock = eval ("rock" + b);
if (b != i) {
if (currentRock.hitTest(otherRock)) {
if (currentRock.oY < otherRock.oY) {
currentRock.oY = otherRock.oY - 29;
currentRock.dy = 0;
currentRock.dx = 0;
}
}
}
b++;
}
b = 0;
while (b <= buttons) {
currentResponder = eval ("responder" + b);
if (currentRock.hitTest(currentResponder)) {
currentRock.dx = currentRock.dx * -1;
currentRock.oX = currentRock.oX + (currentRock.dx * 6);
}
b++;
}
i++;
}
i = 1;
while (i <= enemies) {
currentEnemy = eval ("enemy" + i);
if (currentEnemy.tower == false) {
if (currentEnemy.gotoLeft == true) {
if (currentEnemy.patrolPoint < currentEnemy.patrolLength) {
currentEnemy.oX = currentEnemy.oX + currentEnemy.speed;
currentEnemy.patrolPoint = currentEnemy.patrolPoint + currentEnemy.speed;
} else {
currentEnemy.gotoLeft = false;
currentEnemy.gotoAndPlay("turn");
}
} else if (currentEnemy.patrolPoint > 0) {
currentEnemy.oX = currentEnemy.oX - currentEnemy.speed;
currentEnemy.patrolPoint = currentEnemy.patrolPoint - currentEnemy.speed;
} else {
currentEnemy.gotoLeft = true;
currentEnemy.gotoAndPlay("turn");
}
}
i++;
}
i = 0;
while (i <= enemies) {
currentEnemy = eval ("enemy" + i);
if (mouse.hitTest(currentEnemy)) {
if (currentEnemy.tower == false) {
health = health - currentEnemy.damage;
}
}
if (currentEnemy.tower == true) {
currentBullet = eval ("bullet" + i);
if (mouse.hitTest(currentBullet)) {
health = health - currentEnemy.damage;
}
}
i++;
}
i = 0;
while (i <= buttons) {
currentButton = eval ("button" + i);
currentResponder = eval ("responder" + i);
hit = false;
r = 0;
while (r <= rocks) {
currentRock = eval ("rock" + r);
if (currentButton.hitTest(currentRock)) {
hit = true;
if (currentButton.pressed == false) {
currentButton.pressed = true;
currentResponder.oX = currentResponder.oX + 10000;
}
}
r++;
}
if (mousehitsbuttons == true) {
if (mouse.hitTest(currentButton)) {
hit = true;
if (currentButton.pressed == false) {
currentButton.pressed = true;
currentResponder.oX = currentResponder.oX + 10000;
}
}
}
if (hit == false) {
if (currentButton.pressed == true) {
currentButton.pressed = false;
currentResponder.oX = currentResponder.oX - 10000;
currentResponder.alpha = 0;
}
}
i++;
}
currentResponder.fadeOut = false;
currentResponder.alpha = 100;
currentResponder.speed = 6;
if (mouse.hitTest(end)) {
if (win == false) {
level++;
winS.start(0, 1);
end.gotoAndPlay("win");
win = true;
}
}
i = 0;
while (i <= enemies) {
currentTower = eval ("enemy" + i);
if (currentTower.tower == true) {
currentTop = eval ("towertop" + i);
currentBullet = eval ("bullet" + i);
currentTop._x = currentTower._x;
currentTop._y = currentTower._y - (95 * (currentTower._yscale / 100));
currentTop._yscale = currentTower._yscale;
dx = currentTop._x - mouse._x;
dy = currentTop._y - mouse._y;
radians = Math.atan(dy / dx);
degrees = (radians * 180) / Math.PI;
if (dx > 0) {
degrees = degrees + 180;
}
radians = (degrees / 180) * Math.PI;
degrees = degrees + 90;
currentTop._rotation = degrees;
distance = Math.sqrt((dx * dx) + (dy * dy));
currentTower.counter++;
if (currentTower.counter >= currentTower.counterLimit) {
currentTower.counter = 0;
currentBullet.oX = currentTower.oX;
currentBullet.oY = currentTower.oY - (95 * (currentTower._yscale / 100));
currentBullet.dx = Math.cos(radians) * currentTower.launchSpeed;
currentBullet.dy = Math.sin(radians) * currentTower.launchSpeed;
}
currentBullet.oX = currentBullet.oX + currentBullet.dx;
currentBullet.oY = currentBullet.oY + currentBullet.dy;
}
i++;
}
};
menu.onRelease = function () {
gotoAndStop ("menu");
};
currentAlpha = 100;
faderbox._alpha = currentAlpha;
fadeOut = function () {
if (loading == true) {
faderbox.gotoAndStop("blue");
}
if (loading == false) {
faderbox.gotoAndStop("red");
}
currentAlpha = currentAlpha + speed;
if (currentAlpha >= 100) {
currentAlpha = 100;
if (loading == true) {
gotoAndStop ("loading");
}
if (loading == false) {
gotoAndStop ("lose");
}
}
faderbox._x = 0;
faderbox._y = 0;
faderbox._alpha = currentAlpha;
};
fadeIn = function () {
faderbox.gotoAndStop("blue");
currentAlpha = currentAlpha - speed;
if (currentAlpha <= 0) {
currentAlpha = 0;
faderbox._x = -10000;
faderbox._y = -10000;
}
faderbox._alpha = currentAlpha;
if (health < topHealth) {
faderbox.gotoAndStop("red");
faderbox._x = 0;
faderbox._y = 0;
faderbox._alpha = (100 - (health * healthMultiplier)) - 20;
if (faderbox._alpha < 0) {
faderbox._alpha = 0;
}
currentAlpha = faderbox._alpha;
}
};
Frame 101
lands = 12;
total = 0;
rocks = 6;
objects = 5;
buttons = 3;
enemies = 8;
notputdown = -1;
health = topHealth;
healthMultiplier = 100 / health;
flightJuice = topFlightJuice;
flightMultiplier = 100 / flightJuice;
mouse.maxWidth = 62.1;
landWidth = 188;
onLandNum = 0;
globalX = 0;
globalY = 0;
win = false;
mousehitsbuttons = false;
topsmoke = 5;
smoke = 0;
thrustsoundpauser = 0;
totalforthruster = 4;
fadein = true;
loading = true;
stop();
mouse = eval (type);
mouse._x = startX._x;
mouse._y = startX._y;
startX._x = -100;
startX._y = -100;
mouse.dy = 0;
mouse.dx = 0;
mouse.oX = mouse._x;
mouse.oY = mouse._y;
explosion.oX = -10000;
explosion.oY = -10000;
leftbarrier.oX = leftbarrier._x;
leftbarrier.oY = leftbarrier._y;
rightbarrier.oX = rightbarrier._x;
rightbarrier.oY = rightbarrier._y;
topbarrier.oX = topbarrier._x;
topbarrier.oY = topbarrier._y;
bottombarrier.oX = bottombarrier._x;
bottombarrier.oY = bottombarrier._y;
end.oX = end._x;
end.oY = end._y;
enemy1.tower = false;
enemy2.tower = false;
enemy3.tower = false;
enemy4.tower = false;
enemy5.tower = true;
enemy6.tower = true;
enemy7.tower = true;
enemy8.tower = true;
i = 0;
while (i <= objects) {
currentObject = eval ("object" + i);
currentObject.oX = currentObject._x;
currentObject.oY = currentObject._y;
i++;
}
enemy1.gotoLeft = true;
i = 1;
while (i <= enemies) {
currentEnemy = eval ("enemy" + i);
currentEnemy.health = 8;
currentEnemy.speed = 2;
firstFlag = eval ("firstPatrolMarker" + i);
secondFlag = eval ("secondPatrolMarker" + i);
currentEnemy.patrolLength = secondFlag._x - firstFlag._x;
currentEnemy.patrolPoint = currentEnemy._x - firstFlag._x;
firstFlag._x = -100;
secondFlag._x = -100;
currentEnemy.damage = 1;
currentEnemy.oX = currentEnemy._x;
currentEnemy.oY = currentEnemy._y;
currentEnemy.dead = false;
currentEnemy.gotoLeft = true;
i++;
}
i = 0;
while (i <= enemies) {
currentEnemy = eval ("enemy" + i);
if (currentEnemy.tower == true) {
currentEnemy.counter = 0;
currentEnemy.counterLimit = 60;
currentEnemy.launchSpeed = 2;
currentEnemy.health = 20;
}
i++;
}
i = 0;
while (i <= buttons) {
currentButton = eval ("button" + i);
currentButton.pressed = false;
currentButton.oX = currentButton._x;
currentButton.oY = currentButton._y;
currentResponder = eval ("responder" + i);
currentResponder.oX = currentResponder._x;
currentResponder.oY = currentResponder._y;
currentResponder.fadeOut = false;
currentResponder.alpha = 100;
currentResponder.speed = 6;
i++;
}
i = 0;
while (i <= rocks) {
currentRock = eval ("rock" + i);
currentRock.oX = currentRock._x;
currentRock.oY = currentRock._y;
currentRock.dx = 0;
currentRock.dy = 0;
currentRock.originX = currentRock._x;
currentRock.originY = currentRock._y;
i++;
}
i = 0;
while (i <= lands) {
currentLand = eval ("land" + i);
currentLand.oX = currentLand._x;
currentLand.oY = currentLand._y;
i++;
}
mouse.onEnterFrame = function () {
if (fadein == true) {
fadeIn();
} else {
fadeOut();
}
mouse.dy = mouse.dy + gravity;
mouse._y = mouse._y + mouse.dy;
mouse._x = mouse._x + mouse.dx;
healthbar._xscale = health * healthMultiplier;
if (flightJuice > 0) {
flightbar._xscale = flightJuice * flightMultiplier;
}
if (health <= 0) {
fadein = false;
loading = false;
}
if (health < topHealth) {
health = health + (regenerateRate / 5);
}
if (flightJuice < topFlightJuice) {
flightJuice = flightJuice + regenerateRate;
}
dx = (Stage.width / 2) - mouse._x;
dy = (Stage.width / 2) - mouse._y;
dx = dx / 4;
dy = dy / 4;
if (mouse.dx > topspeed) {
mouse.dx = topspeed;
}
if (mouse.dx < (-topspeed)) {
mouse.dx = -topspeed;
}
if (mouse.dy > topspeed) {
mouse.dy = topspeed;
}
if (mouse.dy < (-topspeed)) {
mouse.dy = -topspeed;
}
globalX = globalX + dx;
globalY = globalY + dy;
i = 1;
while (i <= lands) {
currentLand = eval ("land" + i);
currentLand._x = currentLand.oX + globalX;
currentLand._y = currentLand.oY + globalY;
i++;
}
i = 1;
while (i <= rocks) {
currentRock = eval ("rock" + i);
currentRock._x = currentRock.oX + globalX;
currentRock._y = currentRock.oY + globalY;
i++;
}
i = 1;
while (i <= enemies) {
currentEnemy = eval ("enemy" + i);
currentEnemy._x = currentEnemy.oX + globalX;
currentEnemy._y = currentEnemy.oY + globalY;
if (currentEnemy.tower) {
currentBullet = eval ("bullet" + i);
currentBullet._x = currentBullet.oX + globalX;
currentBullet._y = currentBullet.oY + globalY;
}
i++;
}
explosion._x = explosion.oX + globalX;
explosion._y = explosion.oY + globalY;
i = 0;
while (i <= buttons) {
currentButton = eval ("button" + i);
currentResponder = eval ("responder" + i);
currentButton._x = currentButton.oX + globalX;
currentButton._y = currentButton.oY + globalY;
currentResponder._x = currentResponder.oX + globalX;
currentResponder._y = currentResponder.oY + globalY;
i++;
}
i = 0;
while (i <= objects) {
currentObject = eval ("object" + i);
currentObject._x = currentObject.oX + globalX;
currentObject._y = currentObject.oY + globalY;
i++;
}
leftbarrier._x = leftbarrier.oX + globalX;
leftbarrier._y = leftbarrier.oY + globalY;
rightbarrier._x = rightbarrier.oX + globalX;
rightbarrier._y = rightbarrier.oY + globalY;
topbarrier._x = topbarrier.oX + globalX;
topbarrier._y = topbarrier.oY + globalY;
bottombarrier._x = bottombarrier.oX + globalX;
bottombarrier._y = bottombarrier.oY + globalY;
end._x = end.oX + globalX;
end._y = end.oY + globalY;
mouse.oX = mouse.oX + dx;
mouse.oY = mouse.oY + dy;
mouse._y = mouse._y + dy;
mouse._x = mouse._x + dx;
bg._x = bg._x + (dx / 3);
bg._y = bg._y + (dy / 3);
if (notputdown != -1) {
currentRock = eval ("rock" + notputdown);
currentRock._x = mouse._x;
currentRock._y = mouse._y + 25;
currentRock.dx = mouse.dx;
currentRock.dy = mouse.dy;
}
onLand = false;
i = 1;
while (i <= lands) {
currentLand = eval ("land" + i);
if (mouse.hitTest(currentLand)) {
if (mouse._y < (currentLand._y + (mouse.dy * 1.2))) {
mouse.dy = 0;
mouse._y = currentLand._y;
onLand = true;
onLandNum = i;
} else if (mouse._y > (((currentLand._y + 35.5) + 25.4) + (mouse.dy * 1.2))) {
mouse.dy = mouse.dy * -1;
mouse._y = mouse._y + (mouse.dy * 1.5);
} else {
mouse.dx = mouse.dx * -1;
mouse._x = mouse._x + (mouse.dx * 2);
}
}
i++;
}
if (notputdown != -1) {
currentRock = eval ("rock" + notputdown);
i = 1;
while (i <= lands) {
currentLand = eval ("land" + i);
if (currentRock.hitTest(currentLand)) {
if (currentRock._y < (currentLand._y + (mouse.dy * 1.2))) {
mouse.dy = 0;
mouse._y = currentLand._y - 25;
onLand = true;
onLandNum = i;
} else if (currentRock._y > (((currentLand._y + 35) + 27) + (mouse.dy * 1.2))) {
mouse.dy = mouse.dy * -1;
mouse._y = mouse._y + (mouse.dy * 1.5);
} else {
mouse.dx = mouse.dx * -1;
mouse._x = mouse._x + (mouse.dx * 2);
}
}
i++;
}
notDropRock = eval ("rock" + notputdown);
i = 1;
while (i <= rocks) {
if (i != notputdown) {
currentRock = eval ("rock" + i);
if (notDropRock.hitTest(currentRock)) {
if (notDropRock._y < ((currentRock._y - 25) + (mouse.dy * 1.2))) {
mouse.dy = 0;
mouse._y = currentRock._y - 54;
onLand = true;
} else {
mouse.dx = mouse.dx * -1;
mouse._x = mouse._x + (mouse.dx * 2);
}
}
}
i++;
}
}
if (mouse.hitTest(leftbarrier)) {
mouse.dx = mouse.dx * -1;
mouse.oX = mouse.oX + (mouse.dx * 6);
}
if (mouse.hitTest(rightbarrier)) {
mouse.dx = mouse.dx * -1;
mouse.oX = mouse.oX + (mouse.dx * 6);
}
if (mouse.hitTest(topbarrier)) {
mouse.dy = mouse.dy * -1;
mouse.oY = mouse.oY + (mouse.dy * 6);
}
if (mouse.hitTest(bottombarrier)) {
mouse.dy = mouse.dy * -1;
mouse.oY = mouse.oY + (mouse.dy * 6);
}
i = 0;
while (i <= rocks) {
currentRock = eval ("rock" + i);
if (currentRock.hitTest(leftbarrier)) {
currentRock.dx = currentRock.dx * -1;
currentRock.oX = currentRock.oX + (currentRock.dx * 6);
}
if (currentRock.hitTest(rightbarrier)) {
currentRock.dx = currentRock.dx * -1;
currentRock.oX = currentRock.oX + (currentRock.dx * 6);
}
if (currentRock.hitTest(topbarrier)) {
currentRock.dy = currentRock.dy * -1;
currentRock.oY = currentRock.oY + (currentRock.dy * 6);
}
if (currentRock.hitTest(bottombarrier)) {
currentRock.dy = currentRock.dy * -1;
currentRock.oX = currentRock.oX + (currentRock.dy * 6);
}
i++;
}
i = 1;
while (i <= rocks) {
currentRock = eval ("rock" + i);
e = 1;
while (e <= enemies) {
currentEnemy = eval ("enemy" + e);
if (currentRock.hitTest(currentEnemy)) {
if (currentRock._y < currentEnemy._y) {
if (currentRock.dy > 0) {
if (playsounds) {
}
currentEnemy.health = currentEnemy.health - currentRock.dy;
if (currentEnemy.tower == false) {
currentEnemy._yscale = currentEnemy.health * 10;
} else {
currentEnemy._yscale = currentEnemy.health * 5;
}
currentEnemy.speed = 0;
currentRock.dy = 0;
currentRock.dx = 0;
if (notputdown == i) {
mouse._y = mouse._y - 5;
mouse.dy = mouse.dy - 1;
currentX = currentRock.oX + globalX;
currentY = currentRock.oY + globalY;
dx = mouse._x - currentX;
dy = mouse._y - currentY;
currentRock.oX = currentRock.oX + dx;
currentRock.oY = currentRock.oY + (dy + 27);
notputdown = -1;
}
if (currentEnemy.health <= 1) {
if (i != notputdown) {
if (playsounds) {
explosionS.start(0, 1);
}
explosion.oX = currentEnemy.oX;
explosion.oY = currentEnemy.oY;
if (currentEnemy.tower == true) {
explosion._yscale = 200;
explosion._xscale = 100;
} else {
explosion._yscale = 65;
explosion._xscale = 65;
}
explosion.gotoAndPlay(1);
currentEnemy.oX = -1000;
currentEnemy.oY = -1000;
} else {
if (playsounds) {
explosionS.start(0, 1);
}
if (currentEnemy.tower == true) {
explosion._yscale = 200;
explosion._xscale = 100;
} else {
explosion._yscale = 65;
explosion._xscale = 65;
}
explosion.gotoAndPlay(1);
currentEnemy.oX = -1000;
currentEnemy.oY = -1000;
mouse._y = mouse._y - 5;
mouse.dy = mouse.dy - 1;
currentX = currentRock.oX + globalX;
currentY = currentRock.oY + globalY;
dx = mouse._x - currentX;
dy = mouse._y - currentY;
currentRock.oX = currentRock.oX + dx;
currentRock.oY = currentRock.oY + (dy + 27);
notputdown = -1;
}
currentEnemy.dead = true;
}
}
}
}
e++;
}
i++;
}
i = 1;
while (i <= rocks) {
if (i != notputdown) {
currentRock = eval ("rock" + i);
if (mouse.hitTest(currentRock)) {
if (mouse._y < ((currentRock._y - 25) + (mouse.dy * 1.2))) {
mouse.dy = 0;
mouse._y = (currentRock.oY + globalY) - 26;
onLand = true;
} else {
mouse.dx = mouse.dx * -1;
mouse._x = mouse._x + (mouse.dx * 2);
}
}
}
i++;
}
i = 0;
while (i <= buttons) {
currentResponder = eval ("responder" + i);
if (mouse.hitTest(currentResponder)) {
mouse.dx = mouse.dx * -1;
mouse._x = mouse._x + (mouse.dx * 2);
}
i++;
}
pressed = false;
if (Key.isDown(38)) {
if (onLand) {
mouse.dy = -2;
mouse._y = mouse._y + mouse.dy;
} else if (flightJuice > 0) {
pressed = true;
mouse.gotoAndStop("up");
mouse.dy = mouse.dy - thrust;
flightJuice = flightJuice - 1;
}
}
if (Key.isDown(40)) {
if (onLand) {
} else if (flightJuice > 0) {
pressed = true;
mouse.gotoAndStop("down");
mouse.dy = mouse.dy + thrust;
flightJuice = flightJuice - 1;
}
if (mouse.hitTest(topbarrier)) {
mouse._y = mouse._y + 7;
}
i = 0;
while (i <= lands) {
currentLand = eval ("land" + i);
if (mouse.hitTest(currentLand)) {
if (currentLand._y < (mouse._y - 5)) {
mouse._y = mouse._y + 7;
}
}
i++;
}
}
if (Key.isDown(37)) {
pressed = true;
if (onLand) {
mouse.dx = mouse.dx - thrust;
mouse.gotoAndStop("left");
} else if (flightJuice > 0) {
pressed = true;
mouse.dx = mouse.dx - thrust;
mouse.gotoAndStop("left");
flightJuice = flightJuice - 1;
}
i = 1;
while (i <= lands) {
currentLand = eval ("land" + i);
if (mouse.hitTest(currentLand)) {
if (i != onLandNum) {
if (mouse._y > currentLand._y) {
mouse._x = mouse._x - 7;
}
}
}
i++;
}
i = 1;
while (i <= rocks) {
currentRock = eval ("rock" + i);
if (mouse.hitTest(currentRock)) {
if (mouse._y > (currentRock._y - 26)) {
if (i != notputdown) {
mouse._x = mouse._x - 7;
}
}
}
i++;
}
i = 0;
while (i <= buttons) {
currentResponder = eval ("responder" + i);
if (mouse.hitTest(currentResponder)) {
mouse._x = mouse._x - 7;
}
i++;
}
if (mouse.hitTest(rightbarrier)) {
mouse._x = mouse._x - 7;
}
} else if (Key.isDown(39)) {
pressed = true;
if (onLand) {
mouse.dx = mouse.dx + thrust;
mouse.gotoAndStop("left");
} else if (flightJuice > 0) {
pressed = true;
mouse.dx = mouse.dx + thrust;
mouse.gotoAndStop("left");
flightJuice = flightJuice - 1;
}
mouse.gotoAndStop("right");
i = 1;
while (i <= lands) {
currentLand = eval ("land" + i);
if (mouse.hitTest(currentLand)) {
if (i != onLandNum) {
if (mouse._y > currentLand._y) {
mouse._x = mouse._x + 7;
}
}
}
i++;
}
i = 1;
while (i <= rocks) {
currentRock = eval ("rock" + i);
if (mouse.hitTest(currentRock)) {
if (mouse._y > (currentRock._y - 26)) {
if (i != notputdown) {
mouse._x = mouse._x + 7;
}
}
}
i++;
}
i = 0;
while (i <= buttons) {
currentResponder = eval ("responder" + i);
if (mouse.hitTest(currentResponder)) {
mouse._x = mouse._x + 7;
}
i++;
}
if (mouse.hitTest(leftbarrier)) {
mouse._x = mouse._x + 7;
}
} else if (mouse.dx < 0) {
mouse.dx = mouse.dx + thrust;
} else if (mouse.dx > 0) {
mouse.dx = mouse.dx - thrust;
}
if (mouse.dx < 0.1) {
if (mouse.dx > 0) {
mouse.dx = 0;
}
}
if (mouse.dx > -0.1) {
if (mouse.dx < 0) {
mouse.dx = 0;
}
}
if (pressed == false) {
mouse.gotoAndStop("center");
}
if (pressed == true) {
if (playsounds) {
thrustsoundpauser++;
if (thrustsoundpauser == totalforthruster) {
thruster.start(0, 1);
thrustsoundpauser = 0;
}
}
}
if (Key.isDown(32)) {
if (donePressSpace) {
donePressSpace = false;
if (notputdown == -1) {
i = 1;
while (i <= rocks) {
currentRock = eval ("rock" + i);
if (mouse.hitTest(currentRock)) {
if (playsounds) {
pickup.start(0, 1);
}
notputdown = i;
dx = mouse._x - currentRock._x;
dy = mouse._y - currentRock._y;
currentRock.oX = currentRock.oX + dx;
currentRock.oY = currentRock.oY + (dy + 27);
}
i++;
}
} else {
mouse._y = mouse._y - 5;
mouse.dy = mouse.dy - 1;
if (playsounds) {
pickup.start(0, 1);
}
currentRock = eval ("rock" + notputdown);
currentX = currentRock.oX + globalX;
currentY = currentRock.oY + globalY;
dx = mouse._x - currentX;
dy = mouse._y - currentY;
currentRock.oX = currentRock.oX + dx;
currentRock.oY = currentRock.oY + (dy + 27);
notputdown = -1;
}
}
} else {
donePressSpace = true;
}
i = 1;
while (i <= rocks) {
currentRock = eval ("rock" + i);
if (i != notputdown) {
currentRock.dy = currentRock.dy + gravity;
currentRock.oX = currentRock.oX + currentRock.dx;
currentRock.oY = currentRock.oY + currentRock.dy;
}
l = 1;
while (l <= lands) {
currentLand = eval ("land" + l);
if (currentRock.hitTest(currentLand)) {
if (currentRock._y < ((currentLand._y + currentRock.dy) + 0.5)) {
currentRock.oY = currentLand.oY;
currentRock.dy = 0;
currentRock.dx = 0;
} else if (currentRock._y > (currentLand._y + 25.5)) {
currentRock.dy = currentRock.dy * -1;
currentRock.oY = currentRock.oY + (currentRock.dy * 2);
} else {
currentRock.dx = currentRock.dx * -1;
currentRock.oX = currentRock.oX + (currentRock.dx * 4);
}
}
l++;
}
b = 1;
while (b <= rocks) {
otherRock = eval ("rock" + b);
if (b != i) {
if (currentRock.hitTest(otherRock)) {
if (currentRock.oY < otherRock.oY) {
currentRock.oY = otherRock.oY - 29;
currentRock.dy = 0;
currentRock.dx = 0;
}
}
}
b++;
}
b = 0;
while (b <= buttons) {
currentResponder = eval ("responder" + b);
if (currentRock.hitTest(currentResponder)) {
currentRock.dx = currentRock.dx * -1;
currentRock.oX = currentRock.oX + (currentRock.dx * 6);
}
b++;
}
i++;
}
i = 1;
while (i <= enemies) {
currentEnemy = eval ("enemy" + i);
if (currentEnemy.tower == false) {
if (currentEnemy.gotoLeft == true) {
if (currentEnemy.patrolPoint < currentEnemy.patrolLength) {
currentEnemy.oX = currentEnemy.oX + currentEnemy.speed;
currentEnemy.patrolPoint = currentEnemy.patrolPoint + currentEnemy.speed;
} else {
currentEnemy.gotoLeft = false;
currentEnemy.gotoAndPlay("turn");
}
} else if (currentEnemy.patrolPoint > 0) {
currentEnemy.oX = currentEnemy.oX - currentEnemy.speed;
currentEnemy.patrolPoint = currentEnemy.patrolPoint - currentEnemy.speed;
} else {
currentEnemy.gotoLeft = true;
currentEnemy.gotoAndPlay("turn");
}
}
i++;
}
i = 0;
while (i <= enemies) {
currentEnemy = eval ("enemy" + i);
if (mouse.hitTest(currentEnemy)) {
if (currentEnemy.tower == false) {
health = health - currentEnemy.damage;
}
}
if (currentEnemy.tower == true) {
currentBullet = eval ("bullet" + i);
if (mouse.hitTest(currentBullet)) {
health = health - currentEnemy.damage;
}
}
i++;
}
i = 0;
while (i <= buttons) {
currentButton = eval ("button" + i);
currentResponder = eval ("responder" + i);
hit = false;
r = 0;
while (r <= rocks) {
currentRock = eval ("rock" + r);
if (currentButton.hitTest(currentRock)) {
hit = true;
if (currentButton.pressed == false) {
currentButton.pressed = true;
currentResponder.oX = currentResponder.oX + 10000;
}
}
r++;
}
if (mousehitsbuttons == true) {
if (mouse.hitTest(currentButton)) {
hit = true;
if (currentButton.pressed == false) {
currentButton.pressed = true;
currentResponder.oX = currentResponder.oX + 10000;
}
}
}
if (hit == false) {
if (currentButton.pressed == true) {
currentButton.pressed = false;
currentResponder.oX = currentResponder.oX - 10000;
currentResponder.alpha = 0;
}
}
i++;
}
currentResponder.fadeOut = false;
currentResponder.alpha = 100;
currentResponder.speed = 6;
if (mouse.hitTest(end)) {
if (win == false) {
level++;
winS.start(0, 1);
end.gotoAndPlay("win");
win = true;
}
}
i = 0;
while (i <= enemies) {
currentTower = eval ("enemy" + i);
if (currentTower.tower == true) {
currentTop = eval ("towertop" + i);
currentBullet = eval ("bullet" + i);
currentTop._x = currentTower._x;
currentTop._y = currentTower._y - (95 * (currentTower._yscale / 100));
currentTop._yscale = currentTower._yscale;
dx = currentTop._x - mouse._x;
dy = currentTop._y - mouse._y;
radians = Math.atan(dy / dx);
degrees = (radians * 180) / Math.PI;
if (dx > 0) {
degrees = degrees + 180;
}
radians = (degrees / 180) * Math.PI;
degrees = degrees + 90;
currentTop._rotation = degrees;
distance = Math.sqrt((dx * dx) + (dy * dy));
currentTower.counter++;
if (currentTower.counter >= currentTower.counterLimit) {
currentTower.counter = 0;
currentBullet.oX = currentTower.oX;
currentBullet.oY = currentTower.oY - (95 * (currentTower._yscale / 100));
currentBullet.dx = Math.cos(radians) * currentTower.launchSpeed;
currentBullet.dy = Math.sin(radians) * currentTower.launchSpeed;
}
currentBullet.oX = currentBullet.oX + currentBullet.dx;
currentBullet.oY = currentBullet.oY + currentBullet.dy;
}
i++;
}
};
menu.onRelease = function () {
gotoAndStop ("menu");
};
currentAlpha = 100;
faderbox._alpha = currentAlpha;
fadeOut = function () {
if (loading == true) {
faderbox.gotoAndStop("blue");
}
if (loading == false) {
faderbox.gotoAndStop("red");
}
currentAlpha = currentAlpha + speed;
if (currentAlpha >= 100) {
currentAlpha = 100;
if (loading == true) {
gotoAndStop ("loading");
}
if (loading == false) {
gotoAndStop ("lose");
}
}
faderbox._x = 0;
faderbox._y = 0;
faderbox._alpha = currentAlpha;
};
fadeIn = function () {
faderbox.gotoAndStop("blue");
currentAlpha = currentAlpha - speed;
if (currentAlpha <= 0) {
currentAlpha = 0;
faderbox._x = -10000;
faderbox._y = -10000;
}
faderbox._alpha = currentAlpha;
if (health < topHealth) {
faderbox.gotoAndStop("red");
faderbox._x = 0;
faderbox._y = 0;
faderbox._alpha = (100 - (health * healthMultiplier)) - 20;
if (faderbox._alpha < 0) {
faderbox._alpha = 0;
}
currentAlpha = faderbox._alpha;
}
};
Frame 102
lands = 12;
total = 0;
rocks = 6;
objects = 5;
buttons = 3;
enemies = 8;
notputdown = -1;
health = topHealth;
healthMultiplier = 100 / health;
flightJuice = topFlightJuice;
flightMultiplier = 100 / flightJuice;
mouse.maxWidth = 62.1;
landWidth = 188;
onLandNum = 0;
globalX = 0;
globalY = 0;
win = false;
mousehitsbuttons = false;
topsmoke = 5;
smoke = 0;
thrustsoundpauser = 0;
totalforthruster = 4;
fadein = true;
loading = true;
stop();
mouse = eval (type);
mouse._x = startX._x;
mouse._y = startX._y;
startX._x = -100;
startX._y = -100;
mouse.dy = 0;
mouse.dx = 0;
mouse.oX = mouse._x;
mouse.oY = mouse._y;
explosion.oX = -10000;
explosion.oY = -10000;
leftbarrier.oX = leftbarrier._x;
leftbarrier.oY = leftbarrier._y;
rightbarrier.oX = rightbarrier._x;
rightbarrier.oY = rightbarrier._y;
topbarrier.oX = topbarrier._x;
topbarrier.oY = topbarrier._y;
bottombarrier.oX = bottombarrier._x;
bottombarrier.oY = bottombarrier._y;
end.oX = end._x;
end.oY = end._y;
enemy1.tower = false;
enemy2.tower = false;
enemy3.tower = false;
enemy4.tower = false;
enemy5.tower = true;
enemy6.tower = true;
enemy7.tower = true;
enemy8.tower = true;
enemy2._xscale = enemy2._xscale * -1;
i = 0;
while (i <= objects) {
currentObject = eval ("object" + i);
currentObject.oX = currentObject._x;
currentObject.oY = currentObject._y;
i++;
}
enemy1.gotoLeft = true;
i = 1;
while (i <= enemies) {
currentEnemy = eval ("enemy" + i);
currentEnemy.health = 8;
currentEnemy.speed = 2;
firstFlag = eval ("firstPatrolMarker" + i);
secondFlag = eval ("secondPatrolMarker" + i);
currentEnemy.patrolLength = secondFlag._x - firstFlag._x;
currentEnemy.patrolPoint = currentEnemy._x - firstFlag._x;
firstFlag._x = -100;
secondFlag._x = -100;
currentEnemy.damage = 1;
currentEnemy.oX = currentEnemy._x;
currentEnemy.oY = currentEnemy._y;
currentEnemy.dead = false;
currentEnemy.gotoLeft = true;
i++;
}
enemy2.gotoLeft = false;
enemy1.speed = 4.5;
enemy2.speed = 4.5;
i = 0;
while (i <= enemies) {
currentEnemy = eval ("enemy" + i);
if (currentEnemy.tower == true) {
currentEnemy.counter = 0;
currentEnemy.counterLimit = 60;
currentEnemy.launchSpeed = 2;
currentEnemy.health = 20;
}
i++;
}
i = 0;
while (i <= buttons) {
currentButton = eval ("button" + i);
currentButton.pressed = false;
currentButton.oX = currentButton._x;
currentButton.oY = currentButton._y;
currentResponder = eval ("responder" + i);
currentResponder.oX = currentResponder._x;
currentResponder.oY = currentResponder._y;
currentResponder.fadeOut = false;
currentResponder.alpha = 100;
currentResponder.speed = 6;
i++;
}
i = 0;
while (i <= rocks) {
currentRock = eval ("rock" + i);
currentRock.oX = currentRock._x;
currentRock.oY = currentRock._y;
currentRock.dx = 0;
currentRock.dy = 0;
currentRock.originX = currentRock._x;
currentRock.originY = currentRock._y;
i++;
}
i = 0;
while (i <= lands) {
currentLand = eval ("land" + i);
currentLand.oX = currentLand._x;
currentLand.oY = currentLand._y;
i++;
}
mouse.onEnterFrame = function () {
if (fadein == true) {
fadeIn();
} else {
fadeOut();
}
mouse.dy = mouse.dy + gravity;
mouse._y = mouse._y + mouse.dy;
mouse._x = mouse._x + mouse.dx;
healthbar._xscale = health * healthMultiplier;
if (flightJuice > 0) {
flightbar._xscale = flightJuice * flightMultiplier;
}
if (health <= 0) {
fadein = false;
loading = false;
}
if (health < topHealth) {
health = health + (regenerateRate / 5);
}
if (flightJuice < topFlightJuice) {
flightJuice = flightJuice + regenerateRate;
}
dx = (Stage.width / 2) - mouse._x;
dy = (Stage.width / 2) - mouse._y;
dx = dx / 4;
dy = dy / 4;
if (mouse.dx > topspeed) {
mouse.dx = topspeed;
}
if (mouse.dx < (-topspeed)) {
mouse.dx = -topspeed;
}
if (mouse.dy > topspeed) {
mouse.dy = topspeed;
}
if (mouse.dy < (-topspeed)) {
mouse.dy = -topspeed;
}
globalX = globalX + dx;
globalY = globalY + dy;
i = 1;
while (i <= lands) {
currentLand = eval ("land" + i);
currentLand._x = currentLand.oX + globalX;
currentLand._y = currentLand.oY + globalY;
i++;
}
i = 1;
while (i <= rocks) {
currentRock = eval ("rock" + i);
currentRock._x = currentRock.oX + globalX;
currentRock._y = currentRock.oY + globalY;
i++;
}
i = 1;
while (i <= enemies) {
currentEnemy = eval ("enemy" + i);
currentEnemy._x = currentEnemy.oX + globalX;
currentEnemy._y = currentEnemy.oY + globalY;
if (currentEnemy.tower) {
currentBullet = eval ("bullet" + i);
currentBullet._x = currentBullet.oX + globalX;
currentBullet._y = currentBullet.oY + globalY;
}
i++;
}
explosion._x = explosion.oX + globalX;
explosion._y = explosion.oY + globalY;
i = 0;
while (i <= buttons) {
currentButton = eval ("button" + i);
currentResponder = eval ("responder" + i);
currentButton._x = currentButton.oX + globalX;
currentButton._y = currentButton.oY + globalY;
currentResponder._x = currentResponder.oX + globalX;
currentResponder._y = currentResponder.oY + globalY;
i++;
}
i = 0;
while (i <= objects) {
currentObject = eval ("object" + i);
currentObject._x = currentObject.oX + globalX;
currentObject._y = currentObject.oY + globalY;
i++;
}
leftbarrier._x = leftbarrier.oX + globalX;
leftbarrier._y = leftbarrier.oY + globalY;
rightbarrier._x = rightbarrier.oX + globalX;
rightbarrier._y = rightbarrier.oY + globalY;
topbarrier._x = topbarrier.oX + globalX;
topbarrier._y = topbarrier.oY + globalY;
bottombarrier._x = bottombarrier.oX + globalX;
bottombarrier._y = bottombarrier.oY + globalY;
end._x = end.oX + globalX;
end._y = end.oY + globalY;
mouse.oX = mouse.oX + dx;
mouse.oY = mouse.oY + dy;
mouse._y = mouse._y + dy;
mouse._x = mouse._x + dx;
bg._x = bg._x + (dx / 3);
bg._y = bg._y + (dy / 3);
if (notputdown != -1) {
currentRock = eval ("rock" + notputdown);
currentRock._x = mouse._x;
currentRock._y = mouse._y + 25;
currentRock.dx = mouse.dx;
currentRock.dy = mouse.dy;
}
onLand = false;
i = 1;
while (i <= lands) {
currentLand = eval ("land" + i);
if (mouse.hitTest(currentLand)) {
if (mouse._y < (currentLand._y + (mouse.dy * 1.2))) {
mouse.dy = 0;
mouse._y = currentLand._y;
onLand = true;
onLandNum = i;
} else if (mouse._y > (((currentLand._y + 35.5) + 25.4) + (mouse.dy * 1.2))) {
mouse.dy = mouse.dy * -1;
mouse._y = mouse._y + (mouse.dy * 1.5);
} else {
mouse.dx = mouse.dx * -1;
mouse._x = mouse._x + (mouse.dx * 2);
}
}
i++;
}
if (notputdown != -1) {
currentRock = eval ("rock" + notputdown);
i = 1;
while (i <= lands) {
currentLand = eval ("land" + i);
if (currentRock.hitTest(currentLand)) {
if (currentRock._y < (currentLand._y + (mouse.dy * 1.2))) {
mouse.dy = 0;
mouse._y = currentLand._y - 25;
onLand = true;
onLandNum = i;
} else if (currentRock._y > (((currentLand._y + 35) + 27) + (mouse.dy * 1.2))) {
mouse.dy = mouse.dy * -1;
mouse._y = mouse._y + (mouse.dy * 1.5);
} else {
mouse.dx = mouse.dx * -1;
mouse._x = mouse._x + (mouse.dx * 2);
}
}
i++;
}
notDropRock = eval ("rock" + notputdown);
i = 1;
while (i <= rocks) {
if (i != notputdown) {
currentRock = eval ("rock" + i);
if (notDropRock.hitTest(currentRock)) {
if (notDropRock._y < ((currentRock._y - 25) + (mouse.dy * 1.2))) {
mouse.dy = 0;
mouse._y = currentRock._y - 54;
onLand = true;
} else {
mouse.dx = mouse.dx * -1;
mouse._x = mouse._x + (mouse.dx * 2);
}
}
}
i++;
}
}
if (mouse.hitTest(leftbarrier)) {
mouse.dx = mouse.dx * -1;
mouse.oX = mouse.oX + (mouse.dx * 6);
}
if (mouse.hitTest(rightbarrier)) {
mouse.dx = mouse.dx * -1;
mouse.oX = mouse.oX + (mouse.dx * 6);
}
if (mouse.hitTest(topbarrier)) {
mouse.dy = mouse.dy * -1;
mouse.oY = mouse.oY + (mouse.dy * 6);
}
if (mouse.hitTest(bottombarrier)) {
mouse.dy = mouse.dy * -1;
mouse.oY = mouse.oY + (mouse.dy * 6);
}
i = 0;
while (i <= rocks) {
currentRock = eval ("rock" + i);
if (currentRock.hitTest(leftbarrier)) {
currentRock.dx = currentRock.dx * -1;
currentRock.oX = currentRock.oX + (currentRock.dx * 6);
}
if (currentRock.hitTest(rightbarrier)) {
currentRock.dx = currentRock.dx * -1;
currentRock.oX = currentRock.oX + (currentRock.dx * 6);
}
if (currentRock.hitTest(topbarrier)) {
currentRock.dy = currentRock.dy * -1;
currentRock.oY = currentRock.oY + (currentRock.dy * 6);
}
if (currentRock.hitTest(bottombarrier)) {
currentRock.dy = currentRock.dy * -1;
currentRock.oX = currentRock.oX + (currentRock.dy * 6);
}
i++;
}
i = 1;
while (i <= rocks) {
currentRock = eval ("rock" + i);
e = 1;
while (e <= enemies) {
currentEnemy = eval ("enemy" + e);
if (currentRock.hitTest(currentEnemy)) {
if (currentRock._y < currentEnemy._y) {
if (currentRock.dy > 0) {
if (playsounds) {
}
currentEnemy.health = currentEnemy.health - currentRock.dy;
if (currentEnemy.tower == false) {
currentEnemy._yscale = currentEnemy.health * 10;
} else {
currentEnemy._yscale = currentEnemy.health * 5;
}
currentEnemy.speed = 0;
currentRock.dy = 0;
currentRock.dx = 0;
if (notputdown == i) {
mouse._y = mouse._y - 5;
mouse.dy = mouse.dy - 1;
currentX = currentRock.oX + globalX;
currentY = currentRock.oY + globalY;
dx = mouse._x - currentX;
dy = mouse._y - currentY;
currentRock.oX = currentRock.oX + dx;
currentRock.oY = currentRock.oY + (dy + 27);
notputdown = -1;
}
if (currentEnemy.health <= 1) {
if (i != notputdown) {
if (playsounds) {
explosionS.start(0, 1);
}
explosion.oX = currentEnemy.oX;
explosion.oY = currentEnemy.oY;
if (currentEnemy.tower == true) {
explosion._yscale = 200;
explosion._xscale = 100;
} else {
explosion._yscale = 65;
explosion._xscale = 65;
}
explosion.gotoAndPlay(1);
currentEnemy.oX = -1000;
currentEnemy.oY = -1000;
} else {
if (playsounds) {
explosionS.start(0, 1);
}
if (currentEnemy.tower == true) {
explosion._yscale = 200;
explosion._xscale = 100;
} else {
explosion._yscale = 65;
explosion._xscale = 65;
}
explosion.gotoAndPlay(1);
currentEnemy.oX = -1000;
currentEnemy.oY = -1000;
mouse._y = mouse._y - 5;
mouse.dy = mouse.dy - 1;
currentX = currentRock.oX + globalX;
currentY = currentRock.oY + globalY;
dx = mouse._x - currentX;
dy = mouse._y - currentY;
currentRock.oX = currentRock.oX + dx;
currentRock.oY = currentRock.oY + (dy + 27);
notputdown = -1;
}
currentEnemy.dead = true;
}
}
}
}
e++;
}
i++;
}
i = 1;
while (i <= rocks) {
if (i != notputdown) {
currentRock = eval ("rock" + i);
if (mouse.hitTest(currentRock)) {
if (mouse._y < ((currentRock._y - 25) + (mouse.dy * 1.2))) {
mouse.dy = 0;
mouse._y = (currentRock.oY + globalY) - 26;
onLand = true;
} else {
mouse.dx = mouse.dx * -1;
mouse._x = mouse._x + (mouse.dx * 2);
}
}
}
i++;
}
i = 0;
while (i <= buttons) {
currentResponder = eval ("responder" + i);
if (mouse.hitTest(currentResponder)) {
mouse.dx = mouse.dx * -1;
mouse._x = mouse._x + (mouse.dx * 2);
}
i++;
}
pressed = false;
if (Key.isDown(38)) {
if (onLand) {
mouse.dy = -2;
mouse._y = mouse._y + mouse.dy;
} else if (flightJuice > 0) {
pressed = true;
mouse.gotoAndStop("up");
mouse.dy = mouse.dy - thrust;
flightJuice = flightJuice - 1;
}
}
if (Key.isDown(40)) {
if (onLand) {
} else if (flightJuice > 0) {
pressed = true;
mouse.gotoAndStop("down");
mouse.dy = mouse.dy + thrust;
flightJuice = flightJuice - 1;
}
if (mouse.hitTest(topbarrier)) {
mouse._y = mouse._y + 7;
}
i = 0;
while (i <= lands) {
currentLand = eval ("land" + i);
if (mouse.hitTest(currentLand)) {
if (currentLand._y < (mouse._y - 5)) {
mouse._y = mouse._y + 7;
}
}
i++;
}
}
if (Key.isDown(37)) {
pressed = true;
if (onLand) {
mouse.dx = mouse.dx - thrust;
mouse.gotoAndStop("left");
} else if (flightJuice > 0) {
pressed = true;
mouse.dx = mouse.dx - thrust;
mouse.gotoAndStop("left");
flightJuice = flightJuice - 1;
}
i = 1;
while (i <= lands) {
currentLand = eval ("land" + i);
if (mouse.hitTest(currentLand)) {
if (i != onLandNum) {
if (mouse._y > currentLand._y) {
mouse._x = mouse._x - 7;
}
}
}
i++;
}
i = 1;
while (i <= rocks) {
currentRock = eval ("rock" + i);
if (mouse.hitTest(currentRock)) {
if (mouse._y > (currentRock._y - 26)) {
if (i != notputdown) {
mouse._x = mouse._x - 7;
}
}
}
i++;
}
i = 0;
while (i <= buttons) {
currentResponder = eval ("responder" + i);
if (mouse.hitTest(currentResponder)) {
mouse._x = mouse._x - 7;
}
i++;
}
if (mouse.hitTest(rightbarrier)) {
mouse._x = mouse._x - 7;
}
} else if (Key.isDown(39)) {
pressed = true;
if (onLand) {
mouse.dx = mouse.dx + thrust;
mouse.gotoAndStop("left");
} else if (flightJuice > 0) {
pressed = true;
mouse.dx = mouse.dx + thrust;
mouse.gotoAndStop("left");
flightJuice = flightJuice - 1;
}
mouse.gotoAndStop("right");
i = 1;
while (i <= lands) {
currentLand = eval ("land" + i);
if (mouse.hitTest(currentLand)) {
if (i != onLandNum) {
if (mouse._y > currentLand._y) {
mouse._x = mouse._x + 7;
}
}
}
i++;
}
i = 1;
while (i <= rocks) {
currentRock = eval ("rock" + i);
if (mouse.hitTest(currentRock)) {
if (mouse._y > (currentRock._y - 26)) {
if (i != notputdown) {
mouse._x = mouse._x + 7;
}
}
}
i++;
}
i = 0;
while (i <= buttons) {
currentResponder = eval ("responder" + i);
if (mouse.hitTest(currentResponder)) {
mouse._x = mouse._x + 7;
}
i++;
}
if (mouse.hitTest(leftbarrier)) {
mouse._x = mouse._x + 7;
}
} else if (mouse.dx < 0) {
mouse.dx = mouse.dx + thrust;
} else if (mouse.dx > 0) {
mouse.dx = mouse.dx - thrust;
}
if (mouse.dx < 0.1) {
if (mouse.dx > 0) {
mouse.dx = 0;
}
}
if (mouse.dx > -0.1) {
if (mouse.dx < 0) {
mouse.dx = 0;
}
}
if (pressed == false) {
mouse.gotoAndStop("center");
}
if (pressed == true) {
if (playsounds) {
thrustsoundpauser++;
if (thrustsoundpauser == totalforthruster) {
thruster.start(0, 1);
thrustsoundpauser = 0;
}
}
}
if (Key.isDown(32)) {
if (donePressSpace) {
donePressSpace = false;
if (notputdown == -1) {
i = 1;
while (i <= rocks) {
currentRock = eval ("rock" + i);
if (mouse.hitTest(currentRock)) {
if (playsounds) {
pickup.start(0, 1);
}
notputdown = i;
dx = mouse._x - currentRock._x;
dy = mouse._y - currentRock._y;
currentRock.oX = currentRock.oX + dx;
currentRock.oY = currentRock.oY + (dy + 27);
}
i++;
}
} else {
mouse._y = mouse._y - 5;
mouse.dy = mouse.dy - 1;
if (playsounds) {
pickup.start(0, 1);
}
currentRock = eval ("rock" + notputdown);
currentX = currentRock.oX + globalX;
currentY = currentRock.oY + globalY;
dx = mouse._x - currentX;
dy = mouse._y - currentY;
currentRock.oX = currentRock.oX + dx;
currentRock.oY = currentRock.oY + (dy + 27);
notputdown = -1;
}
}
} else {
donePressSpace = true;
}
i = 1;
while (i <= rocks) {
currentRock = eval ("rock" + i);
if (i != notputdown) {
currentRock.dy = currentRock.dy + gravity;
currentRock.oX = currentRock.oX + currentRock.dx;
currentRock.oY = currentRock.oY + currentRock.dy;
}
l = 1;
while (l <= lands) {
currentLand = eval ("land" + l);
if (currentRock.hitTest(currentLand)) {
if (currentRock._y < ((currentLand._y + currentRock.dy) + 0.5)) {
currentRock.oY = currentLand.oY;
currentRock.dy = 0;
currentRock.dx = 0;
} else if (currentRock._y > (currentLand._y + 25.5)) {
currentRock.dy = currentRock.dy * -1;
currentRock.oY = currentRock.oY + (currentRock.dy * 2);
} else {
currentRock.dx = currentRock.dx * -1;
currentRock.oX = currentRock.oX + (currentRock.dx * 4);
}
}
l++;
}
b = 1;
while (b <= rocks) {
otherRock = eval ("rock" + b);
if (b != i) {
if (currentRock.hitTest(otherRock)) {
if (currentRock.oY < otherRock.oY) {
currentRock.oY = otherRock.oY - 29;
currentRock.dy = 0;
currentRock.dx = 0;
}
}
}
b++;
}
b = 0;
while (b <= buttons) {
currentResponder = eval ("responder" + b);
if (currentRock.hitTest(currentResponder)) {
currentRock.dx = currentRock.dx * -1;
currentRock.oX = currentRock.oX + (currentRock.dx * 6);
}
b++;
}
i++;
}
i = 1;
while (i <= enemies) {
currentEnemy = eval ("enemy" + i);
if (currentEnemy.tower == false) {
if (currentEnemy.gotoLeft == true) {
if (currentEnemy.patrolPoint < currentEnemy.patrolLength) {
currentEnemy.oX = currentEnemy.oX + currentEnemy.speed;
currentEnemy.patrolPoint = currentEnemy.patrolPoint + currentEnemy.speed;
} else {
currentEnemy.speed = 0;
currentEnemy.gotoAndPlay("turn");
}
} else if (currentEnemy.patrolPoint > 0) {
currentEnemy.oX = currentEnemy.oX - currentEnemy.speed;
currentEnemy.patrolPoint = currentEnemy.patrolPoint - currentEnemy.speed;
} else {
currentEnemy.speed = 0;
currentEnemy.gotoAndPlay("turn");
}
}
i++;
}
i = 0;
while (i <= enemies) {
currentEnemy = eval ("enemy" + i);
if (mouse.hitTest(currentEnemy)) {
if (currentEnemy.tower == false) {
health = health - currentEnemy.damage;
}
}
if (currentEnemy.tower == true) {
currentBullet = eval ("bullet" + i);
if (mouse.hitTest(currentBullet)) {
health = health - currentEnemy.damage;
}
}
i++;
}
i = 0;
while (i <= buttons) {
currentButton = eval ("button" + i);
currentResponder = eval ("responder" + i);
hit = false;
r = 0;
while (r <= rocks) {
currentRock = eval ("rock" + r);
if (currentButton.hitTest(currentRock)) {
hit = true;
if (currentButton.pressed == false) {
currentButton.pressed = true;
currentResponder.oX = currentResponder.oX + 10000;
}
}
r++;
}
if (mousehitsbuttons == true) {
if (mouse.hitTest(currentButton)) {
hit = true;
if (currentButton.pressed == false) {
currentButton.pressed = true;
currentResponder.oX = currentResponder.oX + 10000;
}
}
}
if (hit == false) {
if (currentButton.pressed == true) {
currentButton.pressed = false;
currentResponder.oX = currentResponder.oX - 10000;
currentResponder.alpha = 0;
}
}
i++;
}
currentResponder.fadeOut = false;
currentResponder.alpha = 100;
currentResponder.speed = 6;
if (mouse.hitTest(end)) {
if (win == false) {
level++;
winS.start(0, 1);
end.gotoAndPlay("win");
win = true;
}
}
i = 0;
while (i <= enemies) {
currentTower = eval ("enemy" + i);
if (currentTower.tower == true) {
currentTop = eval ("towertop" + i);
currentBullet = eval ("bullet" + i);
currentTop._x = currentTower._x;
currentTop._y = currentTower._y - (95 * (currentTower._yscale / 100));
currentTop._yscale = currentTower._yscale;
dx = currentTop._x - mouse._x;
dy = currentTop._y - mouse._y;
radians = Math.atan(dy / dx);
degrees = (radians * 180) / Math.PI;
if (dx > 0) {
degrees = degrees + 180;
}
radians = (degrees / 180) * Math.PI;
degrees = degrees + 90;
currentTop._rotation = degrees;
distance = Math.sqrt((dx * dx) + (dy * dy));
currentTower.counter++;
if (currentTower.counter >= currentTower.counterLimit) {
currentTower.counter = 0;
currentBullet.oX = currentTower.oX;
currentBullet.oY = currentTower.oY - (95 * (currentTower._yscale / 100));
currentBullet.dx = Math.cos(radians) * currentTower.launchSpeed;
currentBullet.dy = Math.sin(radians) * currentTower.launchSpeed;
}
currentBullet.oX = currentBullet.oX + currentBullet.dx;
currentBullet.oY = currentBullet.oY + currentBullet.dy;
}
i++;
}
};
menu.onRelease = function () {
gotoAndStop ("menu");
};
currentAlpha = 100;
faderbox._alpha = currentAlpha;
fadeOut = function () {
if (loading == true) {
faderbox.gotoAndStop("blue");
}
if (loading == false) {
faderbox.gotoAndStop("red");
}
currentAlpha = currentAlpha + speed;
if (currentAlpha >= 100) {
currentAlpha = 100;
if (loading == true) {
gotoAndStop ("loading");
}
if (loading == false) {
gotoAndStop ("lose");
}
}
faderbox._x = 0;
faderbox._y = 0;
faderbox._alpha = currentAlpha;
};
fadeIn = function () {
faderbox.gotoAndStop("blue");
currentAlpha = currentAlpha - speed;
if (currentAlpha <= 0) {
currentAlpha = 0;
faderbox._x = -10000;
faderbox._y = -10000;
}
faderbox._alpha = currentAlpha;
if (health < topHealth) {
faderbox.gotoAndStop("red");
faderbox._x = 0;
faderbox._y = 0;
faderbox._alpha = (100 - (health * healthMultiplier)) - 20;
if (faderbox._alpha < 0) {
faderbox._alpha = 0;
}
currentAlpha = faderbox._alpha;
}
};
Frame 103
lands = 12;
total = 0;
rocks = 6;
objects = 1;
buttons = 0;
enemies = 1;
notputdown = -1;
health = topHealth;
healthMultiplier = 100 / health;
flightJuice = topFlightJuice;
flightMultiplier = 100 / flightJuice;
mouse.maxWidth = 62.1;
landWidth = 188;
onLandNum = 0;
globalX = 0;
globalY = 0;
win = false;
mousehitsbuttons = false;
topsmoke = 5;
smoke = 1;
smokedelay = 2;
smokepauser = 0;
thrustsoundpauser = 0;
totalforthruster = 4;
fadein = true;
loading = true;
stop();
mouse = eval (type);
mouse._x = startX._x;
mouse._y = startX._y;
startX._x = -100;
startX._y = -100;
mouse.dy = 0;
mouse.dx = 0;
mouse.oX = mouse._x;
mouse.oY = mouse._y;
explosion.oX = -10000;
explosion.oY = -10000;
leftbarrier.oX = leftbarrier._x;
leftbarrier.oY = leftbarrier._y;
rightbarrier.oX = rightbarrier._x;
rightbarrier.oY = rightbarrier._y;
topbarrier.oX = topbarrier._x;
topbarrier.oY = topbarrier._y;
bottombarrier.oX = bottombarrier._x;
bottombarrier.oY = bottombarrier._y;
end.oX = end._x;
end.oY = end._y;
enemy1.tower = true;
i = 0;
while (i <= objects) {
currentObject = eval ("object" + i);
currentObject.oX = currentObject._x;
currentObject.oY = currentObject._y;
i++;
}
i = 0;
while (i <= enemies) {
currentEnemy = eval ("enemy" + i);
if (currentEnemy.tower == true) {
currentEnemy.counter = 0;
currentEnemy.counterLimit = 60;
currentEnemy.launchSpeed = 5;
currentEnemy.health = 15;
currentEnemy.divisor = 100 / currentEnemy.health;
currentBullet = eval ("bullet" + i);
currentBullet.oX = -1000;
currentBullet.oY = -1000;
}
currentEnemy.damage = 2;
currentEnemy.oX = currentEnemy._x;
currentEnemy.oY = currentEnemy._y;
currentEnemy.dead = false;
currentEnemy.movespeed = 2;
i++;
}
i = 0;
while (i <= buttons) {
currentButton = eval ("button" + i);
currentButton.pressed = false;
currentButton.oX = currentButton._x;
currentButton.oY = currentButton._y;
currentResponder = eval ("responder" + i);
currentResponder.oX = currentResponder._x;
currentResponder.oY = currentResponder._y;
currentResponder.fadeOut = false;
currentResponder.alpha = 100;
currentResponder.speed = 6;
i++;
}
i = 0;
while (i <= rocks) {
currentRock = eval ("rock" + i);
currentRock.oX = currentRock._x;
currentRock.oY = currentRock._y;
currentRock.dx = 0;
currentRock.dy = 0;
currentRock.originX = currentRock._x;
currentRock.originY = currentRock._y;
i++;
}
i = 0;
while (i <= lands) {
currentLand = eval ("land" + i);
currentLand.oX = currentLand._x;
currentLand.oY = currentLand._y;
i++;
}
mouse.onEnterFrame = function () {
if (smoke < topsmoke) {
if (smokepauser == smokedelay) {
smoke++;
duplicateMovieClip (smokeS, "smoke" + smoke, smoke);
cSmoke = eval ("smoke" + smoke);
cSmoke.oX = enemy1.oX;
cSmoke.oY = enemy1.oY - 30;
goX = Math.cos(radians) * -50;
goY = Math.sin(radians) * -50;
cSmoke.oX = cSmoke.oX + goX;
cSmoke.oY = cSmoke.oY + goY;
cSmoke.dx = goX / 3;
cSmoke.dy = goY / 3;
smokepauser = 0;
} else {
smokepauser++;
}
} else {
smoke = 1;
}
walrushealth._xscale = enemy1.health * enemy1.divisor;
if (fadein == true) {
fadeIn();
} else {
fadeOut();
}
mouse.dy = mouse.dy + gravity;
mouse._y = mouse._y + mouse.dy;
mouse._x = mouse._x + mouse.dx;
healthbar._xscale = health * healthMultiplier;
if (flightJuice > 0) {
flightbar._xscale = flightJuice * flightMultiplier;
}
if (health <= 0) {
fadein = false;
loading = false;
}
if (health < topHealth) {
health = health + (regenerateRate / 5);
}
if (flightJuice < topFlightJuice) {
flightJuice = flightJuice + regenerateRate;
}
dx = (Stage.width / 2) - mouse._x;
dy = (Stage.width / 2) - mouse._y;
dx = dx / 4;
dy = dy / 4;
if (mouse.dx > topspeed) {
mouse.dx = topspeed;
}
if (mouse.dx < (-topspeed)) {
mouse.dx = -topspeed;
}
if (mouse.dy > topspeed) {
mouse.dy = topspeed;
}
if (mouse.dy < (-topspeed)) {
mouse.dy = -topspeed;
}
globalX = globalX + dx;
globalY = globalY + dy;
i = 1;
while (i <= lands) {
currentLand = eval ("land" + i);
currentLand._x = currentLand.oX + globalX;
currentLand._y = currentLand.oY + globalY;
i++;
}
i = 1;
while (i <= rocks) {
currentRock = eval ("rock" + i);
currentRock._x = currentRock.oX + globalX;
currentRock._y = currentRock.oY + globalY;
i++;
}
i = 1;
while (i <= topsmoke) {
cSmoke = eval ("smoke" + i);
cSmoke.oX = cSmoke.oX + cSmoke.dx;
cSmoke.oY = cSmoke.oY + cSmoke.dy;
cSmoke._x = cSmoke.oX + globalX;
cSmoke._y = cSmoke.oY + globalY;
i++;
}
i = 1;
while (i <= enemies) {
currentEnemy = eval ("enemy" + i);
currentEnemy._x = currentEnemy.oX + globalX;
currentEnemy._y = currentEnemy.oY + globalY;
if (currentEnemy.tower) {
currentBullet = eval ("bullet" + i);
currentBullet._x = currentBullet.oX + globalX;
currentBullet._y = currentBullet.oY + globalY;
}
i++;
}
explosion._x = explosion.oX + globalX;
explosion._y = explosion.oY + globalY;
i = 0;
while (i <= buttons) {
currentButton = eval ("button" + i);
currentResponder = eval ("responder" + i);
currentButton._x = currentButton.oX + globalX;
currentButton._y = currentButton.oY + globalY;
currentResponder._x = currentResponder.oX + globalX;
currentResponder._y = currentResponder.oY + globalY;
i++;
}
i = 0;
while (i <= objects) {
currentObject = eval ("object" + i);
currentObject._x = currentObject.oX + globalX;
currentObject._y = currentObject.oY + globalY;
i++;
}
leftbarrier._x = leftbarrier.oX + globalX;
leftbarrier._y = leftbarrier.oY + globalY;
rightbarrier._x = rightbarrier.oX + globalX;
rightbarrier._y = rightbarrier.oY + globalY;
topbarrier._x = topbarrier.oX + globalX;
topbarrier._y = topbarrier.oY + globalY;
bottombarrier._x = bottombarrier.oX + globalX;
bottombarrier._y = bottombarrier.oY + globalY;
end._x = end.oX + globalX;
end._y = end.oY + globalY;
mouse.oX = mouse.oX + dx;
mouse.oY = mouse.oY + dy;
mouse._y = mouse._y + dy;
mouse._x = mouse._x + dx;
bg._x = bg._x + (dx / 3);
bg._y = bg._y + (dy / 3);
if (notputdown != -1) {
currentRock = eval ("rock" + notputdown);
currentRock._x = mouse._x;
currentRock._y = mouse._y + 25;
currentRock.dx = mouse.dx;
currentRock.dy = mouse.dy;
}
onLand = false;
i = 1;
while (i <= lands) {
currentLand = eval ("land" + i);
if (mouse.hitTest(currentLand)) {
if (mouse._y < (currentLand._y + (mouse.dy * 1.2))) {
mouse.dy = 0;
mouse._y = currentLand._y;
onLand = true;
onLandNum = i;
} else if (mouse._y > (((currentLand._y + 35.5) + 25.4) + (mouse.dy * 1.2))) {
mouse.dy = mouse.dy * -1;
mouse._y = mouse._y + (mouse.dy * 1.5);
} else {
mouse.dx = mouse.dx * -1;
mouse._x = mouse._x + (mouse.dx * 2);
}
}
i++;
}
if (notputdown != -1) {
currentRock = eval ("rock" + notputdown);
i = 1;
while (i <= lands) {
currentLand = eval ("land" + i);
if (currentRock.hitTest(currentLand)) {
if (currentRock._y < (currentLand._y + (mouse.dy * 1.2))) {
mouse.dy = 0;
mouse._y = currentLand._y - 25;
onLand = true;
onLandNum = i;
} else if (currentRock._y > (((currentLand._y + 35) + 27) + (mouse.dy * 1.2))) {
mouse.dy = mouse.dy * -1;
mouse._y = mouse._y + (mouse.dy * 1.5);
} else {
mouse.dx = mouse.dx * -1;
mouse._x = mouse._x + (mouse.dx * 2);
}
}
i++;
}
notDropRock = eval ("rock" + notputdown);
i = 1;
while (i <= rocks) {
if (i != notputdown) {
currentRock = eval ("rock" + i);
if (notDropRock.hitTest(currentRock)) {
if (notDropRock._y < ((currentRock._y - 25) + (mouse.dy * 1.2))) {
mouse.dy = 0;
mouse._y = currentRock._y - 54;
onLand = true;
} else {
mouse.dx = mouse.dx * -1;
mouse._x = mouse._x + (mouse.dx * 2);
}
}
}
i++;
}
}
if (mouse.hitTest(leftbarrier)) {
mouse.dx = mouse.dx * -1;
mouse.oX = mouse.oX + (mouse.dx * 6);
}
if (mouse.hitTest(rightbarrier)) {
mouse.dx = mouse.dx * -1;
mouse.oX = mouse.oX + (mouse.dx * 6);
}
if (mouse.hitTest(topbarrier)) {
mouse.dy = mouse.dy * -1;
mouse.oY = mouse.oY + (mouse.dy * 6);
}
if (mouse.hitTest(bottombarrier)) {
mouse.dy = mouse.dy * -1;
mouse.oY = mouse.oY + (mouse.dy * 6);
}
i = 0;
while (i <= rocks) {
currentRock = eval ("rock" + i);
if (currentRock.hitTest(leftbarrier)) {
currentRock.dx = currentRock.dx * -1;
currentRock.oX = currentRock.oX + (currentRock.dx * 6);
}
if (currentRock.hitTest(rightbarrier)) {
currentRock.dx = currentRock.dx * -1;
currentRock.oX = currentRock.oX + (currentRock.dx * 6);
}
if (currentRock.hitTest(topbarrier)) {
currentRock.dy = currentRock.dy * -1;
currentRock.oY = currentRock.oY + (currentRock.dy * 6);
}
if (currentRock.hitTest(bottombarrier)) {
currentRock.dy = currentRock.dy * -1;
currentRock.oX = currentRock.oX + (currentRock.dy * 6);
}
i++;
}
i = 1;
while (i <= rocks) {
currentRock = eval ("rock" + i);
e = 1;
while (e <= enemies) {
currentEnemy = eval ("enemy" + e);
if (currentRock.hitTest(currentEnemy)) {
if (currentRock._y < currentEnemy._y) {
if (currentRock.dy > 0) {
if (playsounds) {
}
currentEnemy.health = currentEnemy.health - currentRock.dy;
if (currentEnemy.tower == false) {
}
currentEnemy.speed = 0;
currentRock.dy = 0;
currentRock.dx = 0;
if (notputdown == i) {
mouse._y = mouse._y - 5;
mouse.dy = mouse.dy - 1;
currentX = currentRock.oX + globalX;
currentY = currentRock.oY + globalY;
dx = mouse._x - currentX;
dy = mouse._y - currentY;
currentRock.oX = currentRock.oX + dx;
currentRock.oY = currentRock.oY + (dy + 27);
notputdown = -1;
}
if (currentEnemy.health <= 1) {
if (i != notputdown) {
if (playsounds) {
bossexplosion.start(0, 1);
}
explosion.oX = currentEnemy.oX;
explosion.oY = currentEnemy.oY;
if (currentEnemy.tower == true) {
explosion._yscale = 500;
explosion._xscale = 500;
} else {
explosion._yscale = 65;
explosion._xscale = 65;
}
explosion.gotoAndPlay(1);
currentEnemy.oX = -1000;
currentEnemy.oY = -1000;
currentEnemy.dead = true;
speed = 1.5;
fadein = false;
healthbar._xscale = 0;
} else {
if (playsounds) {
explosionS.start(0, 1);
}
if (currentEnemy.tower == true) {
explosion._yscale = 200;
explosion._xscale = 100;
} else {
explosion._yscale = 65;
explosion._xscale = 65;
}
explosion.gotoAndPlay(1);
currentEnemy.oX = -1000;
currentEnemy.oY = -1000;
mouse._y = mouse._y - 5;
mouse.dy = mouse.dy - 1;
currentX = currentRock.oX + globalX;
currentY = currentRock.oY + globalY;
dx = mouse._x - currentX;
dy = mouse._y - currentY;
currentRock.oX = currentRock.oX + dx;
currentRock.oY = currentRock.oY + (dy + 27);
notputdown = -1;
}
currentEnemy.dead = true;
}
}
}
}
e++;
}
i++;
}
i = 1;
while (i <= rocks) {
if (i != notputdown) {
currentRock = eval ("rock" + i);
if (mouse.hitTest(currentRock)) {
if (mouse._y < ((currentRock._y - 25) + (mouse.dy * 1.2))) {
mouse.dy = 0;
mouse._y = (currentRock.oY + globalY) - 26;
onLand = true;
} else {
mouse.dx = mouse.dx * -1;
mouse._x = mouse._x + (mouse.dx * 2);
}
}
}
i++;
}
i = 0;
while (i <= buttons) {
currentResponder = eval ("responder" + i);
if (mouse.hitTest(currentResponder)) {
mouse.dx = mouse.dx * -1;
mouse._x = mouse._x + (mouse.dx * 2);
}
i++;
}
pressed = false;
if (Key.isDown(38)) {
if (onLand) {
mouse.dy = -2;
mouse._y = mouse._y + mouse.dy;
} else if (flightJuice > 0) {
pressed = true;
mouse.gotoAndStop("up");
mouse.dy = mouse.dy - thrust;
flightJuice = flightJuice - 1;
}
}
if (Key.isDown(40)) {
if (onLand) {
} else if (flightJuice > 0) {
pressed = true;
mouse.gotoAndStop("down");
mouse.dy = mouse.dy + thrust;
flightJuice = flightJuice - 1;
}
if (mouse.hitTest(topbarrier)) {
mouse._y = mouse._y + 7;
}
i = 0;
while (i <= lands) {
currentLand = eval ("land" + i);
if (mouse.hitTest(currentLand)) {
if (currentLand._y < (mouse._y - 5)) {
mouse._y = mouse._y + 7;
}
}
i++;
}
}
if (Key.isDown(37)) {
pressed = true;
if (onLand) {
mouse.dx = mouse.dx - thrust;
mouse.gotoAndStop("left");
} else if (flightJuice > 0) {
pressed = true;
mouse.dx = mouse.dx - thrust;
mouse.gotoAndStop("left");
flightJuice = flightJuice - 1;
}
i = 1;
while (i <= lands) {
currentLand = eval ("land" + i);
if (mouse.hitTest(currentLand)) {
if (i != onLandNum) {
if (mouse._y > currentLand._y) {
mouse._x = mouse._x - 7;
}
}
}
i++;
}
i = 1;
while (i <= rocks) {
currentRock = eval ("rock" + i);
if (mouse.hitTest(currentRock)) {
if (mouse._y > (currentRock._y - 26)) {
if (i != notputdown) {
mouse._x = mouse._x - 7;
}
}
}
i++;
}
i = 0;
while (i <= buttons) {
currentResponder = eval ("responder" + i);
if (mouse.hitTest(currentResponder)) {
mouse._x = mouse._x - 7;
}
i++;
}
if (mouse.hitTest(rightbarrier)) {
mouse._x = mouse._x - 7;
}
} else if (Key.isDown(39)) {
pressed = true;
if (onLand) {
mouse.dx = mouse.dx + thrust;
mouse.gotoAndStop("left");
} else if (flightJuice > 0) {
pressed = true;
mouse.dx = mouse.dx + thrust;
mouse.gotoAndStop("left");
flightJuice = flightJuice - 1;
}
mouse.gotoAndStop("right");
i = 1;
while (i <= lands) {
currentLand = eval ("land" + i);
if (mouse.hitTest(currentLand)) {
if (i != onLandNum) {
if (mouse._y > currentLand._y) {
mouse._x = mouse._x + 7;
}
}
}
i++;
}
i = 1;
while (i <= rocks) {
currentRock = eval ("rock" + i);
if (mouse.hitTest(currentRock)) {
if (mouse._y > (currentRock._y - 26)) {
if (i != notputdown) {
mouse._x = mouse._x + 7;
}
}
}
i++;
}
i = 0;
while (i <= buttons) {
currentResponder = eval ("responder" + i);
if (mouse.hitTest(currentResponder)) {
mouse._x = mouse._x + 7;
}
i++;
}
if (mouse.hitTest(leftbarrier)) {
mouse._x = mouse._x + 7;
}
} else if (mouse.dx < 0) {
mouse.dx = mouse.dx + thrust;
} else if (mouse.dx > 0) {
mouse.dx = mouse.dx - thrust;
}
if (mouse.dx < 0.1) {
if (mouse.dx > 0) {
mouse.dx = 0;
}
}
if (mouse.dx > -0.1) {
if (mouse.dx < 0) {
mouse.dx = 0;
}
}
if (pressed == false) {
mouse.gotoAndStop("center");
}
if (pressed == true) {
if (playsounds) {
thrustsoundpauser++;
if (thrustsoundpauser == totalforthruster) {
thruster.start(0, 1);
thrustsoundpauser = 0;
}
}
}
if (Key.isDown(32)) {
if (donePressSpace) {
donePressSpace = false;
if (notputdown == -1) {
i = 1;
while (i <= rocks) {
currentRock = eval ("rock" + i);
if (mouse.hitTest(currentRock)) {
if (playsounds) {
pickup.start(0, 1);
}
notputdown = i;
dx = mouse._x - currentRock._x;
dy = mouse._y - currentRock._y;
currentRock.oX = currentRock.oX + dx;
currentRock.oY = currentRock.oY + (dy + 27);
}
i++;
}
} else {
mouse._y = mouse._y - 5;
mouse.dy = mouse.dy - 1;
if (playsounds) {
pickup.start(0, 1);
}
currentRock = eval ("rock" + notputdown);
currentX = currentRock.oX + globalX;
currentY = currentRock.oY + globalY;
dx = mouse._x - currentX;
dy = mouse._y - currentY;
currentRock.oX = currentRock.oX + dx;
currentRock.oY = currentRock.oY + (dy + 27);
notputdown = -1;
}
}
} else {
donePressSpace = true;
}
i = 1;
while (i <= rocks) {
currentRock = eval ("rock" + i);
if (i != notputdown) {
currentRock.dy = currentRock.dy + gravity;
currentRock.oX = currentRock.oX + currentRock.dx;
currentRock.oY = currentRock.oY + currentRock.dy;
}
l = 1;
while (l <= lands) {
currentLand = eval ("land" + l);
if (currentRock.hitTest(currentLand)) {
if (currentRock._y < ((currentLand._y + currentRock.dy) + 0.5)) {
currentRock.oY = currentLand.oY;
currentRock.dy = 0;
currentRock.dx = 0;
} else if (currentRock._y > (currentLand._y + 25.5)) {
currentRock.dy = currentRock.dy * -1;
currentRock.oY = currentRock.oY + (currentRock.dy * 2);
} else {
currentRock.dx = currentRock.dx * -1;
currentRock.oX = currentRock.oX + (currentRock.dx * 4);
}
}
l++;
}
b = 1;
while (b <= rocks) {
otherRock = eval ("rock" + b);
if (b != i) {
if (currentRock.hitTest(otherRock)) {
if (currentRock.oY < otherRock.oY) {
currentRock.oY = otherRock.oY - 29;
currentRock.dy = 0;
currentRock.dx = 0;
}
}
}
b++;
}
b = 0;
while (b <= buttons) {
currentResponder = eval ("responder" + b);
if (currentRock.hitTest(currentResponder)) {
currentRock.dx = currentRock.dx * -1;
currentRock.oX = currentRock.oX + (currentRock.dx * 6);
}
b++;
}
i++;
}
i = 1;
while (i <= enemies) {
currentEnemy = eval ("enemy" + i);
if (currentEnemy.tower == false) {
if (currentEnemy.gotoLeft == true) {
if (currentEnemy.patrolPoint < currentEnemy.patrolLength) {
currentEnemy.oX = currentEnemy.oX + currentEnemy.speed;
currentEnemy.patrolPoint = currentEnemy.patrolPoint + currentEnemy.speed;
} else {
currentEnemy.speed = 0;
currentEnemy.gotoAndPlay("turn");
}
} else if (currentEnemy.patrolPoint > 0) {
currentEnemy.oX = currentEnemy.oX - currentEnemy.speed;
currentEnemy.patrolPoint = currentEnemy.patrolPoint - currentEnemy.speed;
} else {
currentEnemy.speed = 0;
currentEnemy.gotoAndPlay("turn");
}
} else if (currentEnemy.dead != true) {
dx = currentEnemy._x - mouse._x;
dy = currentEnemy._y - mouse._y;
radians = Math.atan(dy / dx);
degrees = (radians * 180) / Math.PI;
if (dx > 0) {
degrees = degrees + 180;
}
radians = (degrees / 180) * Math.PI;
moveX = Math.cos(radians);
moveY = Math.sin(radians);
moveX = moveX * currentEnemy.movespeed;
moveY = moveY * currentEnemy.movespeed;
currentEnemy.oX = currentEnemy.oX + moveX;
currentEnemy.oY = currentEnemy.oY + moveY;
}
i++;
}
i = 0;
while (i <= enemies) {
currentEnemy = eval ("enemy" + i);
if (mouse.hitTest(currentEnemy)) {
health = health - currentEnemy.damage;
}
if (currentEnemy.tower == true) {
currentBullet = eval ("bullet" + i);
if (mouse.hitTest(currentBullet)) {
health = health - currentEnemy.damage;
}
}
i++;
}
i = 0;
while (i <= buttons) {
currentButton = eval ("button" + i);
currentResponder = eval ("responder" + i);
hit = false;
r = 0;
while (r <= rocks) {
currentRock = eval ("rock" + r);
if (currentButton.hitTest(currentRock)) {
hit = true;
if (currentButton.pressed == false) {
currentButton.pressed = true;
currentResponder.oX = currentResponder.oX + 10000;
}
}
r++;
}
if (mousehitsbuttons == true) {
if (mouse.hitTest(currentButton)) {
hit = true;
if (currentButton.pressed == false) {
currentButton.pressed = true;
currentResponder.oX = currentResponder.oX + 10000;
}
}
}
if (hit == false) {
if (currentButton.pressed == true) {
currentButton.pressed = false;
currentResponder.oX = currentResponder.oX - 10000;
currentResponder.alpha = 0;
}
}
i++;
}
currentResponder.fadeOut = false;
currentResponder.alpha = 100;
currentResponder.speed = 6;
if (mouse.hitTest(end)) {
if (win == false) {
level++;
winS.start(0, 1);
end.gotoAndPlay("win");
win = true;
}
}
i = 0;
while (i <= enemies) {
currentTower = eval ("enemy" + i);
if (currentTower.tower == true) {
currentTop = eval ("towertop" + i);
currentBullet = eval ("bullet" + i);
currentTop._x = currentTower._x;
currentTop._y = currentTower._y;
currentTop._yscale = currentTower._yscale;
dx = currentTower._x - mouse._x;
dy = currentTower._y - mouse._y;
radians = Math.atan(dy / dx);
degrees = (radians * 180) / Math.PI;
if (dx > 0) {
degrees = degrees + 180;
}
radians = (degrees / 180) * Math.PI;
degrees = degrees + 90;
currentTop._rotation = degrees;
distance = Math.sqrt((dx * dx) + (dy * dy));
currentTower.counter++;
if (currentTower.counter >= currentTower.counterLimit) {
currentTower.counter = 0;
currentBullet.oX = currentTower.oX;
currentBullet.oY = currentTower.oY;
currentBullet.dx = Math.cos(radians) * currentTower.launchSpeed;
currentBullet.dy = Math.sin(radians) * currentTower.launchSpeed;
}
currentBullet.oX = currentBullet.oX + currentBullet.dx;
currentBullet.oY = currentBullet.oY + currentBullet.dy;
}
i++;
}
};
menu.onRelease = function () {
gotoAndStop ("menu");
};
currentAlpha = 100;
faderbox._alpha = currentAlpha;
fadeOut = function () {
if (loading == true) {
faderbox.gotoAndStop("blue");
}
if (loading == false) {
faderbox.gotoAndStop("red");
}
currentAlpha = currentAlpha + speed;
if (currentAlpha >= 100) {
currentAlpha = 100;
if (loading == true) {
gotoAndStop ("win");
}
if (loading == false) {
gotoAndStop ("lose");
}
}
faderbox._x = 0;
faderbox._y = 0;
faderbox._alpha = currentAlpha;
};
fadeIn = function () {
faderbox.gotoAndStop("blue");
currentAlpha = currentAlpha - speed;
if (currentAlpha <= 0) {
currentAlpha = 0;
faderbox._x = -10000;
faderbox._y = -10000;
}
faderbox._alpha = currentAlpha;
if (health < topHealth) {
faderbox.gotoAndStop("red");
faderbox._x = 0;
faderbox._y = 0;
faderbox._alpha = (100 - (health * healthMultiplier)) - 20;
if (faderbox._alpha < 0) {
faderbox._alpha = 0;
}
currentAlpha = faderbox._alpha;
}
};
Frame 106
lands = 12;
total = 0;
rocks = 6;
objects = 5;
buttons = 3;
enemies = 8;
notputdown = -1;
health = topHealth;
healthMultiplier = 100 / health;
flightJuice = topFlightJuice;
flightMultiplier = 100 / flightJuice;
mouse.maxWidth = 62.1;
landWidth = 188;
onLandNum = 0;
globalX = 0;
globalY = 0;
win = false;
mousehitsbuttons = false;
topsmoke = 5;
smoke = 0;
thrustsoundpauser = 0;
totalforthruster = 4;
fadein = true;
loading = true;
stop();
mouse = eval (type);
mouse._x = startX._x;
mouse._y = startX._y;
startX._x = -100;
startX._y = -100;
mouse.dy = 0;
mouse.dx = 0;
mouse.oX = mouse._x;
mouse.oY = mouse._y;
explosion.oX = -10000;
explosion.oY = -10000;
leftbarrier.oX = leftbarrier._x;
leftbarrier.oY = leftbarrier._y;
rightbarrier.oX = rightbarrier._x;
rightbarrier.oY = rightbarrier._y;
topbarrier.oX = topbarrier._x;
topbarrier.oY = topbarrier._y;
bottombarrier.oX = bottombarrier._x;
bottombarrier.oY = bottombarrier._y;
end.oX = end._x;
end.oY = end._y;
enemy1.tower = false;
enemy2.tower = false;
enemy3.tower = false;
enemy4.tower = false;
enemy5.tower = true;
enemy6.tower = true;
enemy7.tower = true;
enemy8.tower = true;
i = 0;
while (i <= objects) {
currentObject = eval ("object" + i);
currentObject.oX = currentObject._x;
currentObject.oY = currentObject._y;
i++;
}
enemy1.gotoLeft = true;
i = 1;
while (i <= enemies) {
currentEnemy = eval ("enemy" + i);
currentEnemy.health = 8;
currentEnemy.speed = 2;
firstFlag = eval ("firstPatrolMarker" + i);
secondFlag = eval ("secondPatrolMarker" + i);
currentEnemy.patrolLength = secondFlag._x - firstFlag._x;
currentEnemy.patrolPoint = currentEnemy._x - firstFlag._x;
firstFlag._x = -100;
secondFlag._x = -100;
currentEnemy.damage = 1;
currentEnemy.oX = currentEnemy._x;
currentEnemy.oY = currentEnemy._y;
currentEnemy.dead = false;
currentEnemy.gotoLeft = true;
i++;
}
i = 0;
while (i <= enemies) {
currentEnemy = eval ("enemy" + i);
if (currentEnemy.tower == true) {
currentEnemy.counter = 0;
currentEnemy.counterLimit = 60;
currentEnemy.launchSpeed = 2;
currentEnemy.health = 20;
}
i++;
}
i = 0;
while (i <= buttons) {
currentButton = eval ("button" + i);
currentButton.pressed = false;
currentButton.oX = currentButton._x;
currentButton.oY = currentButton._y;
currentResponder = eval ("responder" + i);
currentResponder.oX = currentResponder._x;
currentResponder.oY = currentResponder._y;
currentResponder.fadeOut = false;
currentResponder.alpha = 100;
currentResponder.speed = 6;
i++;
}
i = 0;
while (i <= rocks) {
currentRock = eval ("rock" + i);
currentRock.oX = currentRock._x;
currentRock.oY = currentRock._y;
currentRock.dx = 0;
currentRock.dy = 0;
currentRock.originX = currentRock._x;
currentRock.originY = currentRock._y;
i++;
}
i = 0;
while (i <= lands) {
currentLand = eval ("land" + i);
currentLand.oX = currentLand._x;
currentLand.oY = currentLand._y;
i++;
}
mouse.onEnterFrame = function () {
if (fadein == true) {
fadeIn();
} else {
fadeOut();
}
mouse.dy = mouse.dy + gravity;
mouse._y = mouse._y + mouse.dy;
mouse._x = mouse._x + mouse.dx;
healthbar._xscale = health * healthMultiplier;
if (flightJuice > 0) {
flightbar._xscale = flightJuice * flightMultiplier;
}
if (health <= 0) {
fadein = false;
loading = false;
}
if (health < topHealth) {
health = health + (regenerateRate / 5);
}
if (flightJuice < topFlightJuice) {
flightJuice = flightJuice + regenerateRate;
}
dx = (Stage.width / 2) - mouse._x;
dy = (Stage.width / 2) - mouse._y;
dx = dx / 4;
dy = dy / 4;
if (mouse.dx > topspeed) {
mouse.dx = topspeed;
}
if (mouse.dx < (-topspeed)) {
mouse.dx = -topspeed;
}
if (mouse.dy > topspeed) {
mouse.dy = topspeed;
}
if (mouse.dy < (-topspeed)) {
mouse.dy = -topspeed;
}
globalX = globalX + dx;
globalY = globalY + dy;
i = 1;
while (i <= lands) {
currentLand = eval ("land" + i);
currentLand._x = currentLand.oX + globalX;
currentLand._y = currentLand.oY + globalY;
i++;
}
i = 1;
while (i <= rocks) {
currentRock = eval ("rock" + i);
currentRock._x = currentRock.oX + globalX;
currentRock._y = currentRock.oY + globalY;
i++;
}
i = 1;
while (i <= enemies) {
currentEnemy = eval ("enemy" + i);
currentEnemy._x = currentEnemy.oX + globalX;
currentEnemy._y = currentEnemy.oY + globalY;
if (currentEnemy.tower) {
currentBullet = eval ("bullet" + i);
currentBullet._x = currentBullet.oX + globalX;
currentBullet._y = currentBullet.oY + globalY;
}
i++;
}
explosion._x = explosion.oX + globalX;
explosion._y = explosion.oY + globalY;
i = 0;
while (i <= buttons) {
currentButton = eval ("button" + i);
currentResponder = eval ("responder" + i);
currentButton._x = currentButton.oX + globalX;
currentButton._y = currentButton.oY + globalY;
currentResponder._x = currentResponder.oX + globalX;
currentResponder._y = currentResponder.oY + globalY;
i++;
}
i = 0;
while (i <= objects) {
currentObject = eval ("object" + i);
currentObject._x = currentObject.oX + globalX;
currentObject._y = currentObject.oY + globalY;
i++;
}
leftbarrier._x = leftbarrier.oX + globalX;
leftbarrier._y = leftbarrier.oY + globalY;
rightbarrier._x = rightbarrier.oX + globalX;
rightbarrier._y = rightbarrier.oY + globalY;
topbarrier._x = topbarrier.oX + globalX;
topbarrier._y = topbarrier.oY + globalY;
bottombarrier._x = bottombarrier.oX + globalX;
bottombarrier._y = bottombarrier.oY + globalY;
end._x = end.oX + globalX;
end._y = end.oY + globalY;
mouse.oX = mouse.oX + dx;
mouse.oY = mouse.oY + dy;
mouse._y = mouse._y + dy;
mouse._x = mouse._x + dx;
bg._x = bg._x + (dx / 3);
bg._y = bg._y + (dy / 3);
if (notputdown != -1) {
currentRock = eval ("rock" + notputdown);
currentRock._x = mouse._x;
currentRock._y = mouse._y + 25;
currentRock.dx = mouse.dx;
currentRock.dy = mouse.dy;
}
onLand = false;
i = 1;
while (i <= lands) {
currentLand = eval ("land" + i);
if (mouse.hitTest(currentLand)) {
if (mouse._y < (currentLand._y + (mouse.dy * 1.2))) {
mouse.dy = 0;
mouse._y = currentLand._y;
onLand = true;
onLandNum = i;
} else if (mouse._y > (((currentLand._y + 35.5) + 25.4) + (mouse.dy * 1.2))) {
mouse.dy = mouse.dy * -1;
mouse._y = mouse._y + (mouse.dy * 1.5);
} else {
mouse.dx = mouse.dx * -1;
mouse._x = mouse._x + (mouse.dx * 2);
}
}
i++;
}
if (notputdown != -1) {
currentRock = eval ("rock" + notputdown);
i = 1;
while (i <= lands) {
currentLand = eval ("land" + i);
if (currentRock.hitTest(currentLand)) {
if (currentRock._y < (currentLand._y + (mouse.dy * 1.2))) {
mouse.dy = 0;
mouse._y = currentLand._y - 25;
onLand = true;
onLandNum = i;
} else if (currentRock._y > (((currentLand._y + 35) + 27) + (mouse.dy * 1.2))) {
mouse.dy = mouse.dy * -1;
mouse._y = mouse._y + (mouse.dy * 1.5);
} else {
mouse.dx = mouse.dx * -1;
mouse._x = mouse._x + (mouse.dx * 2);
}
}
i++;
}
notDropRock = eval ("rock" + notputdown);
i = 1;
while (i <= rocks) {
if (i != notputdown) {
currentRock = eval ("rock" + i);
if (notDropRock.hitTest(currentRock)) {
if (notDropRock._y < ((currentRock._y - 25) + (mouse.dy * 1.2))) {
mouse.dy = 0;
mouse._y = currentRock._y - 54;
onLand = true;
} else {
mouse.dx = mouse.dx * -1;
mouse._x = mouse._x + (mouse.dx * 2);
}
}
}
i++;
}
}
if (mouse.hitTest(leftbarrier)) {
mouse.dx = mouse.dx * -1;
mouse.oX = mouse.oX + (mouse.dx * 6);
}
if (mouse.hitTest(rightbarrier)) {
mouse.dx = mouse.dx * -1;
mouse.oX = mouse.oX + (mouse.dx * 6);
}
if (mouse.hitTest(topbarrier)) {
mouse.dy = mouse.dy * -1;
mouse.oY = mouse.oY + (mouse.dy * 6);
}
if (mouse.hitTest(bottombarrier)) {
mouse.dy = mouse.dy * -1;
mouse.oY = mouse.oY + (mouse.dy * 6);
}
i = 0;
while (i <= rocks) {
currentRock = eval ("rock" + i);
if (currentRock.hitTest(leftbarrier)) {
currentRock.dx = currentRock.dx * -1;
currentRock.oX = currentRock.oX + (currentRock.dx * 6);
}
if (currentRock.hitTest(rightbarrier)) {
currentRock.dx = currentRock.dx * -1;
currentRock.oX = currentRock.oX + (currentRock.dx * 6);
}
if (currentRock.hitTest(topbarrier)) {
currentRock.dy = currentRock.dy * -1;
currentRock.oY = currentRock.oY + (currentRock.dy * 6);
}
if (currentRock.hitTest(bottombarrier)) {
currentRock.dy = currentRock.dy * -1;
currentRock.oX = currentRock.oX + (currentRock.dy * 6);
}
i++;
}
i = 1;
while (i <= rocks) {
currentRock = eval ("rock" + i);
e = 1;
while (e <= enemies) {
currentEnemy = eval ("enemy" + e);
if (currentRock.hitTest(currentEnemy)) {
if (currentRock._y < currentEnemy._y) {
if (currentRock.dy > 0) {
if (playsounds) {
}
currentEnemy.health = currentEnemy.health - currentRock.dy;
if (currentEnemy.tower == false) {
currentEnemy._yscale = currentEnemy.health * 10;
} else {
currentEnemy._yscale = currentEnemy.health * 5;
}
currentEnemy.speed = 0;
currentRock.dy = 0;
currentRock.dx = 0;
if (notputdown == i) {
mouse._y = mouse._y - 5;
mouse.dy = mouse.dy - 1;
currentX = currentRock.oX + globalX;
currentY = currentRock.oY + globalY;
dx = mouse._x - currentX;
dy = mouse._y - currentY;
currentRock.oX = currentRock.oX + dx;
currentRock.oY = currentRock.oY + (dy + 27);
notputdown = -1;
}
if (currentEnemy.health <= 1) {
if (i != notputdown) {
if (playsounds) {
explosionS.start(0, 1);
}
explosion.oX = currentEnemy.oX;
explosion.oY = currentEnemy.oY;
if (currentEnemy.tower == true) {
explosion._yscale = 200;
explosion._xscale = 100;
} else {
explosion._yscale = 65;
explosion._xscale = 65;
}
explosion.gotoAndPlay(1);
currentEnemy.oX = -1000;
currentEnemy.oY = -1000;
} else {
if (playsounds) {
explosionS.start(0, 1);
}
if (currentEnemy.tower == true) {
explosion._yscale = 200;
explosion._xscale = 100;
} else {
explosion._yscale = 65;
explosion._xscale = 65;
}
explosion.gotoAndPlay(1);
currentEnemy.oX = -1000;
currentEnemy.oY = -1000;
mouse._y = mouse._y - 5;
mouse.dy = mouse.dy - 1;
currentX = currentRock.oX + globalX;
currentY = currentRock.oY + globalY;
dx = mouse._x - currentX;
dy = mouse._y - currentY;
currentRock.oX = currentRock.oX + dx;
currentRock.oY = currentRock.oY + (dy + 27);
notputdown = -1;
}
currentEnemy.dead = true;
}
}
}
}
e++;
}
i++;
}
i = 1;
while (i <= rocks) {
if (i != notputdown) {
currentRock = eval ("rock" + i);
if (mouse.hitTest(currentRock)) {
if (mouse._y < ((currentRock._y - 25) + (mouse.dy * 1.2))) {
mouse.dy = 0;
mouse._y = (currentRock.oY + globalY) - 26;
onLand = true;
} else {
mouse.dx = mouse.dx * -1;
mouse._x = mouse._x + (mouse.dx * 2);
}
}
}
i++;
}
i = 0;
while (i <= buttons) {
currentResponder = eval ("responder" + i);
if (mouse.hitTest(currentResponder)) {
mouse.dx = mouse.dx * -1;
mouse._x = mouse._x + (mouse.dx * 2);
}
i++;
}
pressed = false;
if (Key.isDown(38)) {
if (onLand) {
mouse.dy = -2;
mouse._y = mouse._y + mouse.dy;
} else if (flightJuice > 0) {
pressed = true;
mouse.gotoAndStop("up");
mouse.dy = mouse.dy - thrust;
flightJuice = flightJuice - 1;
}
}
if (Key.isDown(40)) {
if (onLand) {
} else if (flightJuice > 0) {
pressed = true;
mouse.gotoAndStop("down");
mouse.dy = mouse.dy + thrust;
flightJuice = flightJuice - 1;
}
if (mouse.hitTest(topbarrier)) {
mouse._y = mouse._y + 7;
}
i = 0;
while (i <= lands) {
currentLand = eval ("land" + i);
if (mouse.hitTest(currentLand)) {
if (currentLand._y < (mouse._y - 5)) {
mouse._y = mouse._y + 7;
}
}
i++;
}
}
if (Key.isDown(37)) {
pressed = true;
if (onLand) {
mouse.dx = mouse.dx - thrust;
mouse.gotoAndStop("left");
} else if (flightJuice > 0) {
pressed = true;
mouse.dx = mouse.dx - thrust;
mouse.gotoAndStop("left");
flightJuice = flightJuice - 1;
}
i = 1;
while (i <= lands) {
currentLand = eval ("land" + i);
if (mouse.hitTest(currentLand)) {
if (i != onLandNum) {
if (mouse._y > currentLand._y) {
mouse._x = mouse._x - 7;
}
}
}
i++;
}
i = 1;
while (i <= rocks) {
currentRock = eval ("rock" + i);
if (mouse.hitTest(currentRock)) {
if (mouse._y > (currentRock._y - 26)) {
if (i != notputdown) {
mouse._x = mouse._x - 7;
}
}
}
i++;
}
i = 0;
while (i <= buttons) {
currentResponder = eval ("responder" + i);
if (mouse.hitTest(currentResponder)) {
mouse._x = mouse._x - 7;
}
i++;
}
if (mouse.hitTest(rightbarrier)) {
mouse._x = mouse._x - 7;
}
} else if (Key.isDown(39)) {
pressed = true;
if (onLand) {
mouse.dx = mouse.dx + thrust;
mouse.gotoAndStop("left");
} else if (flightJuice > 0) {
pressed = true;
mouse.dx = mouse.dx + thrust;
mouse.gotoAndStop("left");
flightJuice = flightJuice - 1;
}
mouse.gotoAndStop("right");
i = 1;
while (i <= lands) {
currentLand = eval ("land" + i);
if (mouse.hitTest(currentLand)) {
if (i != onLandNum) {
if (mouse._y > currentLand._y) {
mouse._x = mouse._x + 7;
}
}
}
i++;
}
i = 1;
while (i <= rocks) {
currentRock = eval ("rock" + i);
if (mouse.hitTest(currentRock)) {
if (mouse._y > (currentRock._y - 26)) {
if (i != notputdown) {
mouse._x = mouse._x + 7;
}
}
}
i++;
}
i = 0;
while (i <= buttons) {
currentResponder = eval ("responder" + i);
if (mouse.hitTest(currentResponder)) {
mouse._x = mouse._x + 7;
}
i++;
}
if (mouse.hitTest(leftbarrier)) {
mouse._x = mouse._x + 7;
}
} else if (mouse.dx < 0) {
mouse.dx = mouse.dx + thrust;
} else if (mouse.dx > 0) {
mouse.dx = mouse.dx - thrust;
}
if (mouse.dx < 0.1) {
if (mouse.dx > 0) {
mouse.dx = 0;
}
}
if (mouse.dx > -0.1) {
if (mouse.dx < 0) {
mouse.dx = 0;
}
}
if (pressed == false) {
mouse.gotoAndStop("center");
}
if (pressed == true) {
if (playsounds) {
thrustsoundpauser++;
if (thrustsoundpauser == totalforthruster) {
thruster.start(0, 1);
thrustsoundpauser = 0;
}
}
}
if (Key.isDown(32)) {
if (donePressSpace) {
donePressSpace = false;
if (notputdown == -1) {
i = 1;
while (i <= rocks) {
currentRock = eval ("rock" + i);
if (mouse.hitTest(currentRock)) {
if (playsounds) {
pickup.start(0, 1);
}
notputdown = i;
dx = mouse._x - currentRock._x;
dy = mouse._y - currentRock._y;
currentRock.oX = currentRock.oX + dx;
currentRock.oY = currentRock.oY + (dy + 27);
}
i++;
}
} else {
mouse._y = mouse._y - 5;
mouse.dy = mouse.dy - 1;
if (playsounds) {
pickup.start(0, 1);
}
currentRock = eval ("rock" + notputdown);
currentX = currentRock.oX + globalX;
currentY = currentRock.oY + globalY;
dx = mouse._x - currentX;
dy = mouse._y - currentY;
currentRock.oX = currentRock.oX + dx;
currentRock.oY = currentRock.oY + (dy + 27);
notputdown = -1;
}
}
} else {
donePressSpace = true;
}
i = 1;
while (i <= rocks) {
currentRock = eval ("rock" + i);
if (i != notputdown) {
currentRock.dy = currentRock.dy + gravity;
currentRock.oX = currentRock.oX + currentRock.dx;
currentRock.oY = currentRock.oY + currentRock.dy;
}
l = 1;
while (l <= lands) {
currentLand = eval ("land" + l);
if (currentRock.hitTest(currentLand)) {
if (currentRock._y < ((currentLand._y + currentRock.dy) + 0.5)) {
currentRock.oY = currentLand.oY;
currentRock.dy = 0;
currentRock.dx = 0;
} else if (currentRock._y > (currentLand._y + 25.5)) {
currentRock.dy = currentRock.dy * -1;
currentRock.oY = currentRock.oY + (currentRock.dy * 2);
} else {
currentRock.dx = currentRock.dx * -1;
currentRock.oX = currentRock.oX + (currentRock.dx * 4);
}
}
l++;
}
b = 1;
while (b <= rocks) {
otherRock = eval ("rock" + b);
if (b != i) {
if (currentRock.hitTest(otherRock)) {
if (currentRock.oY < otherRock.oY) {
currentRock.oY = otherRock.oY - 29;
currentRock.dy = 0;
currentRock.dx = 0;
}
}
}
b++;
}
b = 0;
while (b <= buttons) {
currentResponder = eval ("responder" + b);
if (currentRock.hitTest(currentResponder)) {
currentRock.dx = currentRock.dx * -1;
currentRock.oX = currentRock.oX + (currentRock.dx * 6);
}
b++;
}
i++;
}
i = 1;
while (i <= enemies) {
currentEnemy = eval ("enemy" + i);
if (currentEnemy.tower == false) {
if (currentEnemy.gotoLeft == true) {
if (currentEnemy.patrolPoint < currentEnemy.patrolLength) {
currentEnemy.oX = currentEnemy.oX + currentEnemy.speed;
currentEnemy.patrolPoint = currentEnemy.patrolPoint + currentEnemy.speed;
} else {
currentEnemy.gotoLeft = false;
currentEnemy.gotoAndPlay("turn");
}
} else if (currentEnemy.patrolPoint > 0) {
currentEnemy.oX = currentEnemy.oX - currentEnemy.speed;
currentEnemy.patrolPoint = currentEnemy.patrolPoint - currentEnemy.speed;
} else {
currentEnemy.gotoLeft = true;
currentEnemy.gotoAndPlay("turn");
}
}
i++;
}
i = 0;
while (i <= enemies) {
currentEnemy = eval ("enemy" + i);
if (mouse.hitTest(currentEnemy)) {
if (currentEnemy.tower == false) {
health = health - currentEnemy.damage;
}
}
if (currentEnemy.tower == true) {
currentBullet = eval ("bullet" + i);
if (mouse.hitTest(currentBullet)) {
health = health - currentEnemy.damage;
}
}
i++;
}
i = 0;
while (i <= buttons) {
currentButton = eval ("button" + i);
currentResponder = eval ("responder" + i);
hit = false;
r = 0;
while (r <= rocks) {
currentRock = eval ("rock" + r);
if (currentButton.hitTest(currentRock)) {
hit = true;
if (currentButton.pressed == false) {
currentButton.pressed = true;
currentResponder.oX = currentResponder.oX + 10000;
}
}
r++;
}
if (mousehitsbuttons == true) {
if (mouse.hitTest(currentButton)) {
hit = true;
if (currentButton.pressed == false) {
currentButton.pressed = true;
currentResponder.oX = currentResponder.oX + 10000;
}
}
}
if (hit == false) {
if (currentButton.pressed == true) {
currentButton.pressed = false;
currentResponder.oX = currentResponder.oX - 10000;
currentResponder.alpha = 0;
}
}
i++;
}
currentResponder.fadeOut = false;
currentResponder.alpha = 100;
currentResponder.speed = 6;
if (mouse.hitTest(end)) {
if (win == false) {
level++;
winS.start(0, 1);
end.gotoAndPlay("win");
win = true;
}
}
i = 0;
while (i <= enemies) {
currentTower = eval ("enemy" + i);
if (currentTower.tower == true) {
currentTop = eval ("towertop" + i);
currentBullet = eval ("bullet" + i);
currentTop._x = currentTower._x;
currentTop._y = currentTower._y - (95 * (currentTower._yscale / 100));
currentTop._yscale = currentTower._yscale;
dx = currentTop._x - mouse._x;
dy = currentTop._y - mouse._y;
radians = Math.atan(dy / dx);
degrees = (radians * 180) / Math.PI;
if (dx > 0) {
degrees = degrees + 180;
}
radians = (degrees / 180) * Math.PI;
degrees = degrees + 90;
currentTop._rotation = degrees;
distance = Math.sqrt((dx * dx) + (dy * dy));
currentTower.counter++;
if (currentTower.counter >= currentTower.counterLimit) {
currentTower.counter = 0;
currentBullet.oX = currentTower.oX;
currentBullet.oY = currentTower.oY - (95 * (currentTower._yscale / 100));
currentBullet.dx = Math.cos(radians) * currentTower.launchSpeed;
currentBullet.dy = Math.sin(radians) * currentTower.launchSpeed;
}
currentBullet.oX = currentBullet.oX + currentBullet.dx;
currentBullet.oY = currentBullet.oY + currentBullet.dy;
}
i++;
}
};
menu.onRelease = function () {
gotoAndStop ("menu");
};
currentAlpha = 100;
faderbox._alpha = currentAlpha;
fadeOut = function () {
if (loading == true) {
faderbox.gotoAndStop("blue");
}
if (loading == false) {
faderbox.gotoAndStop("red");
}
currentAlpha = currentAlpha + speed;
if (currentAlpha >= 100) {
currentAlpha = 100;
if (loading == true) {
gotoAndStop ("loading");
}
if (loading == false) {
gotoAndStop ("lose");
}
}
faderbox._x = 0;
faderbox._y = 0;
faderbox._alpha = currentAlpha;
};
fadeIn = function () {
faderbox.gotoAndStop("blue");
currentAlpha = currentAlpha - speed;
if (currentAlpha <= 0) {
currentAlpha = 0;
faderbox._x = -10000;
faderbox._y = -10000;
}
faderbox._alpha = currentAlpha;
if (health < topHealth) {
faderbox.gotoAndStop("red");
faderbox._x = 0;
faderbox._y = 0;
faderbox._alpha = (100 - (health * healthMultiplier)) - 20;
if (faderbox._alpha < 0) {
faderbox._alpha = 0;
}
currentAlpha = faderbox._alpha;
}
};
Frame 143
faderbox.gotoAndStop("red");
bg.gotoAndStop("red");
bg._x = 0;
bg._y = 0;
fadein = true;
alpha = 100;
menu.onRelease = function () {
fadein = false;
};
faderbox.onEnterFrame = function () {
if (fadein) {
fadeIn();
} else {
fadeOut();
}
};
fadeIn = function () {
faderbox._x = 0;
faderbox._y = 0;
alpha = alpha - speed;
if (alpha <= 0) {
alpha = 0;
faderbox._y = -500;
} else {
faderbox._alpha = alpha;
}
};
fadeOut = function () {
faderbox.gotoAndStop("blue");
faderbox._x = 0;
faderbox._y = 0;
alpha = alpha + speed;
if (alpha >= 100) {
faderbox._y = -500;
gotoAndStop ("menu");
} else {
faderbox._alpha = alpha;
}
};
Frame 147
winnumber = 15;
if (level == 2) {
code = "hogwash";
}
if (level == 3) {
code = "diesel";
}
if (level == 4) {
code = "dwarfer";
}
if (level == 5) {
code = "penguins";
}
if (level == 6) {
code = "partridge";
}
if (level == 7) {
code = "bearmeat";
}
if (level == 8) {
code = "blondie";
}
if (level == 9) {
code = "deathcab";
}
if (level == 10) {
code = "stillalive";
}
if (level == 11) {
code = "suicide";
}
if (level == 12) {
code = "bonkers";
}
if (level == 13) {
code = "lucky13";
}
if (level == 14) {
code = "theboss";
}
fadein = true;
codeinput = code;
faderbox.gotoAndStop("blue");
codebox.onEnterFrame = function () {
if (Key.isDown(32)) {
fadein = false;
}
if (fadein) {
fadeIn();
} else {
fadeOut();
}
};
menu.onRelease = function () {
gotoAndStop ("menu");
};
currentAlpha = 100;
faderbox._alpha = currentAlpha;
fadeOut = function () {
currentAlpha = currentAlpha + speed;
if (currentAlpha >= 100) {
currentAlpha = 100;
if (level < winnumber) {
gotoAndStop("level" + level);
} else {
gotoAndStop ("win");
}
}
faderbox._x = 0;
faderbox._y = 0;
faderbox._alpha = currentAlpha;
};
fadeIn = function () {
currentAlpha = currentAlpha - speed;
if (currentAlpha <= 0) {
currentAlpha = 0;
faderbox._x = -10000;
faderbox._y = -10000;
}
faderbox._x = 0;
faderbox._y = 0;
faderbox._alpha = currentAlpha;
};
Frame 149
winnumber = 12;
fadein = true;
codeinput = code;
codebox.onEnterFrame = function () {
if (Key.isDown(32)) {
fadein = false;
}
if (fadein) {
fadeIn();
} else {
fadeOut();
}
};
menu.onRelease = function () {
gotoAndStop ("menu");
};
speed = 6;
currentAlpha = 100;
faderbox._alpha = currentAlpha;
faderbox.gotoAndStop("blue");
fadeOut = function () {
currentAlpha = currentAlpha + speed;
if (currentAlpha >= 100) {
currentAlpha = 100;
if (level < winnumber) {
gotoAndStop("level" + level);
} else {
gotoAndStop ("win");
}
}
faderbox._x = 0;
faderbox._y = 0;
faderbox._alpha = currentAlpha;
};
fadeIn = function () {
currentAlpha = currentAlpha - speed;
if (currentAlpha <= 0) {
currentAlpha = 0;
faderbox._x = -10000;
faderbox._y = -10000;
}
faderbox._alpha = currentAlpha;
};
Frame 151
fadein = true;
codeinput = code;
currentAlpha = 100;
faderbox._alpha = currentAlpha;
faderbox.gotoAndStop("blue");
soundefx.onRelease = function () {
if (playsounds == true) {
playsounds = false;
soundfx = "Off";
} else {
playsounds = true;
soundfx = "On";
}
};
cryingSoulB.onRelease = function () {
cryingSoul.stop();
fallIntoTheBlazingCold.stop();
roseAtDawn.stop();
cryingSoul.start(0, 9999);
};
fall.onRelease = function () {
cryingSoul.stop();
fallIntoTheBlazingCold.stop();
roseAtDawn.stop();
fallIntoTheBlazingCold.start(0, 9999);
};
rose.onRelease = function () {
cryingSoul.stop();
fallIntoTheBlazingCold.stop();
roseAtDawn.stop();
roseAtDawn.start(0, 9999);
};
none.onRelease = function () {
cryingSoul.stop();
fallIntoTheBlazingCold.stop();
roseAtDawn.stop();
};
menu.onRelease = function () {
fadein = false;
};
faderbox.onEnterFrame = function () {
if (fadein) {
fadeIn();
} else {
fadeOut();
}
};
fadeOut = function () {
currentAlpha = currentAlpha + speed;
if (currentAlpha >= 100) {
currentAlpha = 100;
gotoAndStop ("menu");
}
faderbox._x = 0;
faderbox._y = 0;
faderbox._alpha = currentAlpha;
};
fadeIn = function () {
currentAlpha = currentAlpha - speed;
faderbox._x = 0;
faderbox._y = 0;
if (currentAlpha <= 0) {
currentAlpha = 0;
faderbox._x = -1000;
faderbox._y = -1000;
}
faderbox._alpha = currentAlpha;
};
Frame 157
skipbutton.onRelease = function () {
gotoAndStop ("menu");
};
Frame 674
gotoAndStop ("menu");
Frame 1191
gotoAndStop ("menu");
Symbol 300 MovieClip [__Packages.MochiAd] Frame 0
class MochiAd
{
function MochiAd () {
}
static function getVersion() {
return("2.2");
}
static function showPreGameAd(options) {
var _local27 = {clip:_root, ad_timeout:3000, fadeout_time:250, regpt:"o", method:"showPreloaderAd", color:16747008, background:16777161, outline:13994812, ad_started:function () {
this.clip.stop();
}, ad_finished:function () {
this.clip.play();
}};
options = _parseOptions(options, _local27);
var clip = options.clip;
var _local23 = 11000;
var _local26 = options.ad_timeout;
delete options.ad_timeout;
var fadeout_time = options.fadeout_time;
delete options.fadeout_time;
if (!load(options)) {
options.ad_finished();
return(undefined);
}
options.ad_started();
var mc = clip._mochiad;
mc.onUnload = function () {
options.ad_finished();
};
var _local14 = _getRes(options);
var _local4 = _local14[0];
var _local13 = _local14[1];
mc._x = _local4 * 0.5;
mc._y = _local13 * 0.5;
var chk = mc.createEmptyMovieClip("_mochiad_wait", 3);
chk._x = _local4 * -0.5;
chk._y = _local13 * -0.5;
var _local7 = chk.createEmptyMovieClip("_mochiad_bar", 4);
_local7._x = 10;
_local7._y = _local13 - 20;
var _local22 = options.color;
delete options.color;
var _local19 = options.background;
delete options.background;
var _local24 = options.outline;
delete options.outline;
var _local5 = _local7.createEmptyMovieClip("_outline", 1);
_local5.beginFill(_local19);
_local5.moveTo(0, 0);
_local5.lineTo(_local4 - 20, 0);
_local5.lineTo(_local4 - 20, 10);
_local5.lineTo(0, 10);
_local5.lineTo(0, 0);
_local5.endFill();
var _local3 = _local7.createEmptyMovieClip("_inside", 2);
_local3.beginFill(_local22);
_local3.moveTo(0, 0);
_local3.lineTo(_local4 - 20, 0);
_local3.lineTo(_local4 - 20, 10);
_local3.lineTo(0, 10);
_local3.lineTo(0, 0);
_local3.endFill();
_local3._xscale = 0;
var _local6 = _local7.createEmptyMovieClip("_outline", 3);
_local6.lineStyle(0, _local24, 100);
_local6.moveTo(0, 0);
_local6.lineTo(_local4 - 20, 0);
_local6.lineTo(_local4 - 20, 10);
_local6.lineTo(0, 10);
_local6.lineTo(0, 0);
chk.ad_msec = _local23;
chk.ad_timeout = _local26;
chk.started = getTimer();
chk.showing = false;
chk.last_pcnt = 0;
chk.fadeout_time = fadeout_time;
chk.fadeFunction = function () {
var _local2 = 100 * (1 - ((getTimer() - this.fadeout_start) / this.fadeout_time));
if (_local2 > 0) {
this._parent._alpha = _local2;
} else {
var _local3 = this._parent._parent;
MochiAd.unload(_local3);
delete this.onEnterFrame;
}
};
mc.lc.adLoaded = function (width, height) {
};
mc.lc.adjustProgress = function (msec) {
var _local2 = this.mc._mochiad_wait;
_local2.server_control = true;
_local2.started = getTimer();
_local2.ad_msec = msec;
};
chk.onEnterFrame = function () {
var _local6 = this._parent._parent;
var _local12 = this._parent._mochiad_ctr;
var _local5 = getTimer() - this.started;
var _local3 = false;
var _local4 = _local6.getBytesTotal();
var _local8 = _local6.getBytesLoaded();
var _local10 = (100 * _local8) / _local4;
var _local11 = (100 * _local5) / chk.ad_msec;
var _local9 = this._mochiad_bar._inside;
var _local2 = Math.min(100, Math.min(_local10 || 0, _local11));
_local2 = Math.max(this.last_pcnt, _local2);
this.last_pcnt = _local2;
_local9._xscale = _local2;
if (!chk.showing) {
var _local7 = _local12.getBytesTotal();
if ((_local7 > 0) || (typeof(_local7) == "undefined")) {
chk.showing = true;
chk.started = getTimer();
} else if (_local5 > chk.ad_timeout) {
_local3 = true;
}
}
if (_local5 > chk.ad_msec) {
_local3 = true;
}
if (((_local4 > 0) && (_local8 >= _local4)) && (_local3)) {
if (this.server_control) {
delete this.onEnterFrame;
} else {
this.fadeout_start = getTimer();
this.onEnterFrame = chk.fadeFunction;
}
}
};
}
static function showInterLevelAd(options) {
var _local13 = {clip:_root, ad_timeout:2000, fadeout_time:250, regpt:"o", method:"showTimedAd", ad_started:function () {
this.clip.stop();
}, ad_finished:function () {
this.clip.play();
}};
options = _parseOptions(options, _local13);
var clip = options.clip;
var _local10 = 11000;
var _local12 = options.ad_timeout;
delete options.ad_timeout;
var fadeout_time = options.fadeout_time;
delete options.fadeout_time;
if (!load(options)) {
options.ad_finished();
return(undefined);
}
options.ad_started();
var mc = clip._mochiad;
mc.onUnload = function () {
options.ad_finished();
};
var _local5 = _getRes(options);
var _local14 = _local5[0];
var _local11 = _local5[1];
mc._x = _local14 * 0.5;
mc._y = _local11 * 0.5;
var chk = mc.createEmptyMovieClip("_mochiad_wait", 3);
chk.ad_msec = _local10;
chk.ad_timeout = _local12;
chk.started = getTimer();
chk.showing = false;
chk.fadeout_time = fadeout_time;
chk.fadeFunction = function () {
var _local2 = 100 * (1 - ((getTimer() - this.fadeout_start) / this.fadeout_time));
if (_local2 > 0) {
this._parent._alpha = _local2;
} else {
var _local3 = this._parent._parent;
MochiAd.unload(_local3);
delete this.onEnterFrame;
}
};
mc.lc.adLoaded = function (width, height) {
};
mc.lc.adjustProgress = function (msec) {
var _local2 = this.mc._mochiad_wait;
_local2.server_control = true;
_local2.started = getTimer();
_local2.ad_msec = msec - 250;
};
chk.onEnterFrame = function () {
var _local5 = this._parent._mochiad_ctr;
var _local4 = getTimer() - this.started;
var _local2 = false;
if (!chk.showing) {
var _local3 = _local5.getBytesTotal();
if ((_local3 > 0) || (typeof(_local3) == "undefined")) {
chk.showing = true;
chk.started = getTimer();
} else if (_local4 > chk.ad_timeout) {
_local2 = true;
}
}
if (_local4 > chk.ad_msec) {
_local2 = true;
}
if (_local2) {
if (this.server_control) {
delete this.onEnterFrame;
} else {
this.fadeout_start = getTimer();
this.onEnterFrame = this.fadeFunction;
}
}
};
}
static function showTimedAd(options) {
showInterLevelAd(options);
}
static function showPreloaderAd(options) {
showPreGameAd(options);
}
static function _allowDomains(server) {
var _local1 = server.split("/")[2].split(":")[0];
if (System.security) {
if (System.security.allowDomain) {
System.security.allowDomain("*");
System.security.allowDomain(_local1);
}
if (System.security.allowInsecureDomain) {
System.security.allowInsecureDomain("*");
System.security.allowInsecureDomain(_local1);
}
}
return(_local1);
}
static function _loadCommunicator(options) {
var _local26 = {clip:_root, com_server:"http://x.mochiads.com/com/1/", method:"loadCommunicator", depth:10337, id:"_UNKNOWN_"};
options = _parseOptions(options, _local26);
options.swfv = options.clip.getSWFVersion() || 6;
options.mav = getVersion();
var _local18 = options.clip;
var _local20 = "_mochiad_com_" + options.id;
if (!_isNetworkAvailable()) {
return(null);
}
if (_local18[_local20]) {
return(_local18[_local20].lc);
}
var _local21 = options.com_server + options.id;
_allowDomains(_local21);
delete options.id;
delete options.com_server;
var _local25 = options.depth;
delete options.depth;
var _local17 = _local18.createEmptyMovieClip(_local20, _local25);
var _local11 = _local17.createEmptyMovieClip("_mochiad_com", 1);
for (var _local15 in options) {
_local11[_local15] = options[_local15];
}
var _local6 = new LocalConnection();
var _local16 = ["", Math.floor(new Date().getTime()), random(999999)].join("_");
_local6.mc = _local17;
_local6.name = _local16;
_local6.allowDomain = function (d) {
return(true);
};
_local6.allowInsecureDomain = _local6.allowDomain;
_local6.connect(_local16);
_local17.lc = _local6;
_local11.lc = _local16;
_local6._id = 0;
_local6._queue = [];
_local6.rpcResult = function (cb_arg) {
var _local8 = parseInt(cb_arg);
var _local4 = this._callbacks[_local8];
if (!_local4) {
return(undefined);
}
delete this._callbacks[_local8];
var _local5 = [];
var _local3 = 2;
while (_local3 < _local4.length) {
_local5.push(_local4[_local3]);
_local3++;
}
_local3 = 1;
while (_local3 < arguments.length) {
_local5.push(arguments[_local3]);
_local3++;
}
var _local6 = _local4[1];
var _local7 = _local4[0];
if (_local7 && (typeof(_local6) == "string")) {
_local6 = _local7[_local6];
}
if (_local6) {
_local6.apply(_local7, _local5);
}
};
_local6._didConnect = function (endpoint) {
this._endpoint = endpoint;
var _local4 = this._queue;
delete this._queue;
var _local5 = this.doSend;
var _local2 = 0;
while (_local2 < _local4.length) {
var _local3 = _local4[_local2];
_local5.apply(this, _local3);
_local2++;
}
};
_local6.doSend = function (args, cbobj, cbfn) {
if (this._endpoint == null) {
var _local4 = [];
var _local3 = 0;
while (_local3 < arguments.length) {
_local4.push(arguments[_local3]);
_local3++;
}
this._queue.push(_local4);
return(undefined);
}
this._id = this._id + 1;
var _local5 = this._id;
if ((cbfn === undefined) || (cbfn === null)) {
cbfn = cbobj;
}
this._callbacks[_local5] = [cbobj, cbfn];
var _local7 = new LocalConnection();
var _local9 = _local7.send(this._endpoint, "rpc", _local5, args);
};
_local6._callbacks = {};
_local6._callbacks[0] = [_local6, "_didConnect"];
_local11.st = getTimer();
_local11.loadMovie(_local21 + ".swf", "POST");
return(_local6);
}
static function fetchHighScores(options, callbackObj, callbackMethod) {
var _local1 = _loadCommunicator({id:options.id});
if (!_local1) {
return(false);
}
var _local4 = ["fetchHighScores", options];
_local1.doSend(["fetchHighScores", options], callbackObj, callbackMethod);
return(true);
}
static function sendHighScore(options, callbackObj, callbackMethod) {
var _local1 = _loadCommunicator({id:options.id});
if (!_local1) {
return(false);
}
var _local4 = ["sendHighScore", options];
_local1.doSend(["sendHighScore", options], callbackObj, callbackMethod);
return(true);
}
static function load(options) {
var _local13 = {clip:_root, server:"http://x.mochiads.com/srv/1/", method:"load", depth:10333, id:"_UNKNOWN_"};
options = _parseOptions(options, _local13);
options.swfv = options.clip.getSWFVersion() || 6;
options.mav = getVersion();
var _local9 = options.clip;
if (!_isNetworkAvailable()) {
return(null);
}
if (_local9._mochiad_loaded) {
return(null);
}
var _local12 = options.depth;
delete options.depth;
var _local6 = _local9.createEmptyMovieClip("_mochiad", _local12);
var _local11 = _getRes(options);
options.res = (_local11[0] + "x") + _local11[1];
options.server = options.server + options.id;
delete options.id;
_local9._mochiad_loaded = true;
var _local4 = _local6.createEmptyMovieClip("_mochiad_ctr", 1);
for (var _local7 in options) {
_local4[_local7] = options[_local7];
}
var _local10 = _local4.server;
delete _local4.server;
var _local14 = _allowDomains(_local10);
_local6.onEnterFrame = function () {
if (this._mochiad_ctr._url != this._url) {
this.onEnterFrame = function () {
if (!this._mochiad_ctr) {
delete this.onEnterFrame;
MochiAd.unload(this._parent);
}
};
}
};
var _local5 = new LocalConnection();
var _local8 = ["", Math.floor(new Date().getTime()), random(999999)].join("_");
_local5.mc = _local6;
_local5.name = _local8;
_local5.hostname = _local14;
_local5.allowDomain = function (d) {
return(true);
};
_local5.allowInsecureDomain = _local5.allowDomain;
_local5.connect(_local8);
_local6.lc = _local5;
_local4.lc = _local8;
_local4.st = getTimer();
_local4.loadMovie(_local10 + ".swf", "POST");
return(_local6);
}
static function unload(clip) {
if (typeof(clip) == "undefined") {
clip = _root;
}
if (clip.clip && (clip.clip._mochiad)) {
clip = clip.clip;
}
if (!clip._mochiad) {
return(false);
}
clip._mochiad.removeMovieClip();
delete clip._mochiad_loaded;
delete clip._mochiad;
return(true);
}
static function _isNetworkAvailable() {
if (System.security) {
var _local1 = System.security;
if (_local1.sandboxType == "localWithFile") {
return(false);
}
}
return(true);
}
static function _getRes(options) {
var _local3 = options.clip.getBounds();
var _local2 = 0;
var _local1 = 0;
if (typeof(options.res) != "undefined") {
var _local4 = options.res.split("x");
_local2 = parseFloat(_local4[0]);
_local1 = parseFloat(_local4[1]);
} else {
_local2 = _local3.xMax - _local3.xMin;
_local1 = _local3.yMax - _local3.yMin;
}
if ((_local2 == 0) || (_local1 == 0)) {
_local2 = Stage.width;
_local1 = Stage.height;
}
return([_local2, _local1]);
}
static function _parseOptions(options, defaults) {
var _local4 = {};
for (var _local8 in defaults) {
_local4[_local8] = defaults[_local8];
}
if (options) {
for (var _local8 in options) {
_local4[_local8] = options[_local8];
}
}
if (_root.mochiad_options) {
var _local5 = _root.mochiad_options.split("&");
var _local2 = 0;
while (_local2 < _local5.length) {
var _local3 = _local5[_local2].split("=");
_local4[unescape(_local3[0])] = unescape(_local3[1]);
_local2++;
}
}
if (_local4.id == "test") {
trace("[MochiAd] WARNING: Using the MochiAds test identifier, make sure to use the code from your dashboard, not this example!");
}
return(_local4);
}
}
Symbol 71 MovieClip Frame 1
Symbol 71 MovieClip Frame 7
gotoAndPlay (1);
Symbol 106 MovieClip Frame 1
stop();
Symbol 106 MovieClip Frame 22
_root.fadein = false;
stop();
Symbol 111 MovieClip Frame 1
stop();
Symbol 112 MovieClip Frame 1
stop();
Symbol 122 MovieClip Frame 31
gotoAndPlay ("main");
Symbol 122 MovieClip Frame 56
this._xscale = this._xscale * -1;
this.gotoAndPlay("main");
Symbol 133 MovieClip Frame 9
this.oX = -1000;
this.oY = -1000;
Symbol 138 MovieClip Frame 10
stop();
Symbol 142 MovieClip Frame 1
stop();
Symbol 143 MovieClip Frame 1
stop();
Symbol 174 MovieClip Frame 22
this.gotoAndPlay("go");
Symbol 174 MovieClip Frame 36
this._xscale = this._xscale * -1;
this.gotoAndPlay("go");
Symbol 182 MovieClip Frame 1
this.invincible = true;
Symbol 196 MovieClip Frame 1
this.invincible = true;
Symbol 290 MovieClip Frame 29
stop();