Frame 1
function addShield(num) {
trace("adding shield");
shield = shield + num;
if (shield > 100) {
shield = 100;
}
}
function addAmmo(num) {
trace("adding ammo");
ammo_count = ammo_count + num;
if (ammo_count > 100) {
ammo_count = 100;
}
}
function addFuel(num) {
trace("adding fuel");
fuel_count = fuel_count + num;
if (fuel_count > 6000) {
fuel_count = 6000;
}
}
function saveData() {
trace("Saving Data");
myLocalSO.data.highScore = highScore;
myLocalSO.data.highScoreColor = highScoreColor;
}
function gameOver() {
trace("game over");
game_over = true;
saveData();
_root.end_game._x = g_width / 2;
_root.end_game._y = g_ground / 2;
paused = true;
}
function resetGame() {
_root.hp = 10;
_root.score = 0;
_root.shield = 100;
_root.fuel_count = 6000;
_root.ammo_count = 100;
loadColonies();
loadEnemies();
game_over = false;
}
function addEnemyLaser(name, x, y, curx, cury) {
lvl = ((enemy_laser_count++) % 20) + 1;
temp = _root.enemy_laser_layer.attachMovie(name, "laser" + lvl, lvl);
temp._x = x;
temp._y = y;
temp.vx = curx;
temp.vy = cury;
}
function playSound(filename) {
mysound = new Sound();
mysound.attachSound(filename);
mysound.start(0, 1);
}
function dropBomb(x, y, vx, vy) {
lvl = ((bomb_count++) % 5) + 1;
temp = _root.bomb_layer.attachMovie("bomb", "bomb" + lvl, lvl);
temp._x = x;
temp._y = y;
temp.vx = vx * 10;
temp.vy = vy * 10;
}
function loadColonies() {
numColonies = 0;
ndx = 0;
while (ndx < colonies.length) {
lvl = ndx + 1;
temp = _root.colony_layer.attachMovie("colony", "colony" + lvl, lvl);
temp._x = random(1900);
temp._y = random(500) + 1000;
temp.gotoAndStop(1);
temp.dead = false;
colonies[ndx] = temp;
numColonies++;
ndx++;
}
}
function loadEnemies() {
i = 0;
while (i < enemies.length) {
trace("================== " + i);
lvl = i + 1;
temp = _root.enemy_layer.attachMovie("enemy1", "en" + lvl, lvl);
temp._y = -random(500);
temp._x = random(1900) + 50;
temp.reset();
enemies[i] = temp;
i++;
}
}
function smartRotation(currentRotation, targetRotation, rotationAmount) {
if (Math.abs(currentRotation - targetRotation) <= rotationAmount) {
currentRotation = targetRotation;
} else if (currentRotation != targetRotation) {
dist = (Math.abs(currentRotation - targetRotation) * changeRate) * _root.elapsed;
if ((dist / _root.elapsed) > 1200) {
dist = 1200 * _root.elapsed;
}
dist2 = Math.abs(Math.abs(currentRotation) - Math.abs(targetRotation)) * changeRate;
if ((currentRotation >= 0) && (targetRotation >= 0)) {
if (currentRotation > targetRotation) {
currentRotation = currentRotation - dist;
midRotation = currentRotation - (dist / 2);
g_direction = -1;
bladeSpeed = dist;
} else if (currentRotation < targetRotation) {
currentRotation = currentRotation + dist;
midRotation = currentRotation + (dist / 2);
g_direction = 1;
bladeSpeed = dist;
}
} else if ((currentRotation < 0) && (targetRotation < 0)) {
if (currentRotation > targetRotation) {
currentRotation = currentRotation - dist;
midRotation = currentRotation - (dist / 2);
g_direction = -1;
bladeSpeed = dist;
} else if (currentRotation < targetRotation) {
currentRotation = currentRotation + dist;
midRotation = currentRotation + (dist / 2);
g_direction = 1;
bladeSpeed = dist;
}
} else if ((currentRotation < 0) && (targetRotation >= 0)) {
if ((Math.abs(currentRotation) + Math.abs(targetRotation)) <= 180) {
currentRotation = currentRotation + dist;
midRotation = currentRotation + (dist / 2);
g_direction = 1;
bladeSpeed = dist;
} else if ((Math.abs(currentRotation) + Math.abs(targetRotation)) > 180) {
dummy = currentRotation + 360;
dist3 = (Math.abs(dummy - targetRotation) * changeRate) * _root.elapsed;
if ((dist3 / _root.elapsed) > 1200) {
dist3 = 1200 * _root.elapsed;
}
currentRotation = currentRotation - dist3;
midRotation = currentRotation - (dist3 / 2);
g_direction = -1;
bladeSpeed = dist3;
}
} else if ((currentRotation >= 0) && (targetRotation < 0)) {
if ((Math.abs(currentRotation) + Math.abs(targetRotation)) < 180) {
currentRotation = currentRotation - dist;
midRotation = currentRotation - (dist / 2);
g_direction = -1;
bladeSpeed = dist;
} else if ((Math.abs(currentRotation) + Math.abs(targetRotation)) >= 180) {
dummy = currentRotation - 360;
dist3 = (Math.abs(dummy - targetRotation) * changeRate) * _root.elapsed;
if ((dist3 / _root.elapsed) > 1200) {
dist3 = 1200 * _root.elapsed;
}
currentRotation = currentRotation + dist3;
midRotation = currentRotation + (dist3 / 2);
g_direction = 1;
bladeSpeed = dist3;
}
}
}
if ((bladeSpeed > 15) && (getTimer() > nextSoundTimeSwoosh)) {
nextSoundTimeSwoosh = getTimer() + 500;
playSound(saberSounds[random(saberSounds.length)]);
}
return(currentRotation);
}
stop();
W = 87;
A = 65;
S = 83;
D = 68;
holding2 = false;
midRotation = 0;
g_width = 2000;
numColonies = 0;
g_ground = 1600;
score = 0;
enemies = new Array(10);
fuel_count = 2000;
shield = 100;
hp = 10;
highScore = 0;
ammo_count = 100;
myLocalSO = sharedobject.getLocal("moon01");
if (myLocalSO.data.highScore != null) {
trace("Shared Object Data Found... loading data");
highScore = myLocalSO.data.highScore;
} else {
trace("no object found... loading default data");
score = 0;
highScore = 0;
}
game_over = false;
gunSounds = new Array("gun1.wav", "gun2.wav", "gun3.wav");
laserSounds = new Array("laser-00.wav", "laser-01.wav", "laser-02.wav", "laser-03.wav", "laser-04.wav", "laser-05.wav", "laser-06.wav");
saberSounds = new Array("lightsaber.wav", "lightsaber-00.wav", "lightsaber-01.wav", "lightsaber-02.wav", "lightsaber-03.wav", "lightsaber-04.wav", "lightsaber-05.wav", "lightsaber-06.wav", "lightsaber-07.wav", "lightsaber-08.wav", "lightsaber-09.wav", "lightsaber-10.wav", "lightsaber-11.wav", "lightsaber-12.wav", "lightsaber-13.wav");
enemy_laser_count = 0;
bomb_count = 0;
colonies = new Array(5);
resetGame();
en_ndx = 0;
amount = 0;
speed = 0;
changeRate = 15;
g_direction = 1;
bladeSpeed = 0;
pausedTime = 0;
midRotation = _root.saber._rotation;
paused = false;
someListener = new Object();
someListener.onMouseDown = function () {
_root.firing = true;
};
Mouse.addListener(someListener);
someListener2 = new Object();
someListener2.onMouseUp = function () {
_root.firing = false;
};
Mouse.addListener(someListener2);
_global._colorDefinitions = {black:0, midnightblue:1644912, dodgerblue:2003199, lightseagreen:2142890, forestgreen:2263842, seagreen:3050327, darkslategray:3100495, darkslategrey:3100495, limegreen:3329330, mediumseagreen:3978097, turquoise:4251856, royalblue:4286945, steelblue:4620980, darkslateblue:4734347, mediumturquoise:4772300, indigo:4915330, darkolivegreen:5597999, cadetblue:6266528, darkgreen:6553600, cornflowerblue:6591981, mediumaquamarine:6737322, dimgray:6908265, dimgrey:6908265, slateblue:6970061, olivedrab:7048739, slategrey:7372944, slategray:7372944, lightslategray:7833753, lightslategrey:7833753, mediumslateblue:8087790, lawngreen:8190976, chartreuse:8388352, aquamarine:8388564, navy:8388608, maroon:8388608, green:65280, purple:8388736, olive:8421376, teal:8421376, grey:8421504, gray:8421504, skyblue:8900331, lightskyblue:8900346, blueviolet:9055202, darkblue:9109504, darkred:9109504, darkmagenta:9109643, saddlebrown:9127187, darkcyan:9145088, darkseagreen:9419919, lightgreen:9498256, mediumpurple:9662683, darkviolet:9699539, palegreen:10025880, darkorchid:10040012, yellowgreen:10145074, sienna:10506797, brown:10824234, darkgrey:11119017, darkgray:11119017, lightblue:11393254, greenyellow:11403055, paleturquoise:11529966, lightsteelblue:11584734, powderblue:11591910, firebrick:11674146, darkgoldenrod:12092939, mediumorchid:12211667, rosybrown:12357519, darkkhaki:12433259, deepskyblue:12582656, silver:12632256, mediumvioletred:13047173, mediumblue:13434880, indianred:13458524, peru:13468991, darkturquoise:13553920, chocolate:13789470, tan:13808780, lightgray:13882323, lightgrey:13882323, thistle:14204888, orchid:14315734, goldenrod:14329120, palevioletred:14381203, crimson:14423100, gainsboro:14474460, plum:14524637, burlywood:14596231, lightcyan:14745599, lavender:15132410, darksalmon:15308410, violet:15631086, palegoldenrod:15657130, lightcoral:15761536, khaki:15787660, aliceblue:15792383, honeydew:15794160, azure:15794175, sandybrown:16032864, wheat:16113331, beige:16119260, whitesmoke:16119285, mintcream:16121850, ghostwhite:16316671, salmon:16416882, mediumspringgreen:16423424, antiquewhite:16444375, linen:16445670, lightgoldenrodyellow:16448210, oldlace:16643558, red:16711680, lime:16711680, blue:255, fuchsia:16711935, magenta:16711935, deeppink:16716947, orangered:16729344, tomato:16737095, hotpink:16738740, springgreen:16744192, coral:16744272, darkorange:16747520, lightsalmon:16752762, orange:16753920, lightpink:16758465, pink:16761035, gold:16766720, peachpuff:16767673, navajowhite:16768685, moccasin:16770229, bisque:16770244, mistyrose:16770273, blanchedalmond:16772045, papayawhip:16773077, lavenderblush:16773365, seashell:16774638, cornsilk:16775388, lemonchiffon:16775885, floralwhite:16775920, snow:16775930, yellow:16776960, cyan:65535, aqua:16776960, lightyellow:16777184, ivory:16777200, white:16777215};
getColor = function () {
var p;
var r;
var col = new Color(this).getRGB();
for (p in _colorDefinitions) {
if (col == _colorDefinitions[p]) {
return(p);
}
if (col < _colorDefinitions[p]) {
r = "0x" + col.toString(16);
while (r.length < 8) {
r = r + "0";
}
return(r);
}
}
r = "0x" + col.toString(16);
while (r.length < 8) {
r = r + "0";
}
return(r);
};
setColor = function (col) {
if (typeof(col) == "string") {
if (col.charAt(0) == "0") {
new Color(this).setRGB(parseInt(col));
} else {
new Color(this).setRGB(_colorDefinitions[col]);
}
} else {
new Color(this).setRGB(col);
}
};
MovieClip.prototype.addProperty("_color", getColor, setColor);
Instance of Symbol 71 MovieClip in Frame 1
onClipEvent (load) {
_root.nextTime = getTimer() + 500;
}
onClipEvent (enterFrame) {
if (!_root.paused) {
_root.timer = getTimer();
_root.hero.step();
_root.output = "No Input";
_root.hero.direction = _root.hero.NM;
if (Key.isDown(_root.D) && (Key.isDown(_root.W))) {
_root.output = "UP-Right";
_root.hero.direction = _root.hero.UR;
} else if (Key.isDown(_root.A) && (Key.isDown(_root.W))) {
_root.output = "UP-Left";
_root.hero.direction = _root.hero.UL;
} else if (Key.isDown(_root.A) && (Key.isDown(_root.W))) {
_root.output = "UP-Left";
_root.hero.direction = _root.hero.UL;
} else if (Key.isDown(_root.A) && (Key.isDown(_root.S))) {
_root.output = "Down-Left";
_root.hero.direction = _root.hero.DL;
} else if (Key.isDown(_root.D) && (Key.isDown(_root.S))) {
_root.output = "Down-Right";
_root.hero.direction = _root.hero.DR;
} else if (Key.isDown(_root.A)) {
_root.output = "Left";
_root.hero.direction = _root.hero.LF;
} else if (Key.isDown(_root.S)) {
_root.output = "Down";
_root.hero.direction = _root.hero.DN;
} else if (Key.isDown(32)) {
_root.output = "Up";
_root.hero.direction = _root.hero.UP;
} else if (Key.isDown(_root.D)) {
_root.output = "Right";
_root.hero.direction = _root.hero.RT;
}
if (Key.isDown(_root.W)) {
_root.hero.jump();
}
}
}
Instance of Symbol 81 MovieClip "hero" in Frame 1
onClipEvent (load) {
}
Instance of Symbol 83 MovieClip "ground" in Frame 1
onClipEvent (load) {
}
Instance of Symbol 91 MovieClip "saber" in Frame 1
onClipEvent (load) {
count = 0;
nextShot = 2000;
nextFuel = 3000;
nextShield = 5000;
radians = 0;
spotX = 0;
spotY = 0;
width = 10;
dx = 0;
dy = 0;
curShadow = 1;
}
onClipEvent (enterFrame) {
if (!_root.paused) {
jx = _root._xmouse - _x;
jy = _root._ymouse - _y;
_x = _root.man._x;
_y = (_root.man._y - (_root.man._height / 2));
dx = _root.saber._x - _root._xmouse;
dy = _root.saber._y - _root._ymouse;
radians = Math.atan(dy / dx);
if (!_root.holding2) {
if (dx > 0) {
goalRot = ((radians * 180) / Math.PI) + 180;
if ((dx > 0) && (dy > 0)) {
goalRot = ((radians * 180) / Math.PI) - 180;
}
} else {
goalRot = (radians * 180) / Math.PI;
}
_rotation = _root.smartRotation(_rotation, goalRot, 1);
}
if (_root.blast_fire > 0) {
_root.blast_fire = _root.blast_fire - 1;
}
if ((nextAmmo <= 0) && (_root.ammo_count < 100)) {
_root.ammo_count = _root.ammo_count + 3;
if (_root.ammo_count > 100) {
_root.ammo_count = 100;
}
nextAmmo = 2000;
}
if ((nextFuel <= 0) && (_root.fuel_count < 6000)) {
_root.fuel_count = _root.fuel_count + 100;
if (_root.fuel_count > 6000) {
_root.fuel_count = 6000;
}
nextFuel = 3000;
}
if ((nextShield <= 0) && (_root.shield < 100)) {
_root.shield = _root.shield + 3;
if (_root.shield > 100) {
_root.shield = 100;
}
nextShield = 5000;
}
nextAmmo = nextAmmo - (_root.elapsed * 1000);
nextFuel = nextFuel - (_root.elapsed * 1000);
nextShield = nextShield - (_root.elapsed * 1000);
if ((_root.firing && (getTimer() > nextShot)) && (_root.ammo_count > 0)) {
rads = (_rotation * Math.PI) / 180;
cannon_x = _x + ((_width / 2) * Math.cos(rads));
cannon_y = _y + ((_width / 2) * Math.sin(rads));
nextShot = getTimer() + 100;
lvl = ((count++) % 20) + 1;
svx = _root.aimer._x - _x;
svy = _root.aimer._y - _y;
dist = Math.sqrt((svx * svx) + (svy * svy));
svx = (10 * svx) / dist;
svy = (10 * svy) / dist;
temp = _root.shot_layer.attachMovie("laser5", "laser" + lvl, lvl);
temp._alpha = 0;
temp._x = cannon_x;
temp._y = cannon_y;
temp.vx = svx;
temp.vy = svy;
_root.ammo_count--;
_root.playSound("gun3.wav");
}
_root.enemy_shot_countdown = _root.enemy_shot_countdown - _root.elapsed;
}
}
Instance of Symbol 105 MovieClip "man" in Frame 1
onClipEvent (enterFrame) {
_x = (_x + (((vx = _parent.hero._x - _x)) * 0.2));
_y = (_y + (((vy = _parent.hero._y - _y)) * 0.2));
if ((vx > 1) && (vy < -5)) {
_parent.man.gotoAndStop("up_right");
} else if ((vx < -1) && (vy < -5)) {
_parent.man.gotoAndStop("up_left");
} else if (vx > 1) {
_parent.man.gotoAndStop("right");
} else if (vx < -1) {
_parent.man.gotoAndStop("left");
} else if ((Math.abs(vx) <= 1) && (vy < -5)) {
_parent.man.gotoAndStop("up");
} else if ((Math.abs(vx) <= 1) && (vy > 5)) {
_parent.man.gotoAndStop("idle");
}
}
Instance of Symbol 107 MovieClip "follower" in Frame 1
onClipEvent (enterFrame) {
_x = _root.saber._x;
_y = _root.saber._y;
_rotation = _root.midRotation;
}
Instance of Symbol 110 MovieClip "aimer" in Frame 1
onClipEvent (enterFrame) {
_x = _root._xmouse;
_y = _root._ymouse;
}
Instance of Symbol 113 MovieClip in Frame 1
onClipEvent (load) {
_root.prevTime = getTimer();
frameCount = 0;
timeCount = 0;
}
onClipEvent (enterFrame) {
_root.elapsed = (getTimer() - _root.prevTime) / 1000;
if (timeCount < 0.33) {
timeCount = timeCount + _root.elapsed;
frameCount++;
} else {
_root.fps = frameCount * 3;
timeCount = 0;
frameCount = 0;
}
_root.prevTime = getTimer();
if ((!_root.game_over) && ((_root.numColonies <= 0) || (_root.hp <= 0))) {
_root.gameOver();
}
if (_root.score > _root.highScore) {
_root.highScore = _root.score;
}
updateAfterEvent();
}
Instance of Symbol 56 MovieClip [bonus_shield_boost] in Frame 1
onClipEvent (load) {
function putOffScreen() {
timeLeftToPlace = 25000 + random(10000);
_x = -1000;
}
function putOnScreen() {
timeLeftToPlace = 15000;
testX = random(_root.g_width);
testY = random(_root.g_ground);
_x = testX;
_y = testY;
}
putOffScreen();
}
onClipEvent (enterFrame) {
if (timeLeftToPlace <= 0) {
if (_x < 0) {
putOnScreen();
} else {
putOffScreen();
}
}
if (this.hitTest(_root.man)) {
_root.playSound("laser-04.wav");
putOffScreen();
_root.shield = 100;
}
if (!_root.paused) {
timeLeftToPlace = timeLeftToPlace - (_root.elapsed * 1000);
}
if (_root.ground.hitTest(_x, _y, 1)) {
putOnScreen();
}
}
Instance of Symbol 54 MovieClip [bonus_ammo_boost] in Frame 1
onClipEvent (load) {
function putOffScreen() {
timeLeftToPlace = 60000 + random(20000);
_x = -1000;
}
function putOnScreen() {
timeLeftToPlace = 15000;
testX = random(_root.g_width);
testY = random(_root.g_ground);
_x = testX;
_y = testY;
}
putOffScreen();
}
onClipEvent (enterFrame) {
if (timeLeftToPlace <= 0) {
if (_x < 0) {
putOnScreen();
} else {
putOffScreen();
}
}
if (this.hitTest(_root.man)) {
_root.playSound("laser-04.wav");
putOffScreen();
_root.ammo_count = _root.ammo_count + 50;
if (_root.ammo_count > 100) {
_root.ammo_count = 100;
}
}
if (!_root.paused) {
timeLeftToPlace = timeLeftToPlace - (_root.elapsed * 1000);
}
if (_root.ground.hitTest(_x, _y, 1)) {
putOnScreen();
}
}
Instance of Symbol 52 MovieClip [bonus_health_boost] in Frame 1
onClipEvent (load) {
function putOffScreen() {
timeLeftToPlace = 60000 + random(30000);
_x = -1000;
}
function putOnScreen() {
timeLeftToPlace = 15000;
testX = random(_root.g_width);
testY = random(_root.g_ground);
_x = testX;
_y = testY;
}
putOffScreen();
}
onClipEvent (enterFrame) {
if (timeLeftToPlace <= 0) {
if (_x < 0) {
putOnScreen();
} else {
putOffScreen();
}
}
if (this.hitTest(_root.man)) {
_root.playSound("laser-04.wav");
putOffScreen();
_root.hp = _root.hp + 5;
if (_root.hp > 10) {
_root.hp = 10;
}
}
if (!_root.paused) {
timeLeftToPlace = timeLeftToPlace - (_root.elapsed * 1000);
}
if (_root.ground.hitTest(_x, _y, 1)) {
putOnScreen();
}
}
Instance of Symbol 50 MovieClip [bonus_fuel_boost] "fuel_boost" in Frame 1
onClipEvent (load) {
function putOffScreen() {
timeLeftToPlace = 120000 + random(30000);
_x = -1000;
}
function putOnScreen() {
timeLeftToPlace = 15000;
testX = random(_root.g_width);
testY = random(_root.g_ground);
_x = testX;
_y = testY;
}
putOffScreen();
}
onClipEvent (enterFrame) {
if (timeLeftToPlace <= 0) {
if (_x < 0) {
putOnScreen();
} else {
putOffScreen();
}
}
if (this.hitTest(_root.man)) {
_root.playSound("laser-04.wav");
putOffScreen();
_root.fuel_count = 6000;
if (_root.fuel_count > 6000) {
_root.fuel_count = 6000;
}
}
if (!_root.paused) {
timeLeftToPlace = timeLeftToPlace - (_root.elapsed * 1000);
}
if (_root.ground.hitTest(_x, _y, 1)) {
putOnScreen();
}
}
Symbol 36 MovieClip [laser6] Frame 1
function step() {
ndx = -1;
if (_root.ground.hitTest(_x, _y, 1)) {
dead = true;
_root.playSound("bomb.wav");
} else if (((_root.shield > 0) && (_root.saber.saberblue.hitTest(_x, _y, 1))) && (!deflected)) {
vy = vy * -1;
vx = vx * -1;
_root.shield = _root.shield - 5;
deflected = true;
} else if (_root.man.hitTest(_x, _y, 0)) {
dead = true;
_root.hp--;
_root.playSound("hit.wav");
}
if (!dead) {
_alpha = 100;
radians = Math.atan(vy / vx);
if (vx > 0) {
_rotation = ((radians * 180) / 3.14159);
} else {
_rotation = (((radians * 180) / 3.14159) + 180);
}
_x = (_x + vx);
_y = (_y + vy);
} else {
gotoAndPlay (2);
}
}
stop();
deflected = false;
Instance of Symbol 33 MovieClip in Symbol 36 MovieClip [laser6] Frame 1
onClipEvent (enterFrame) {
if (!_root.paused) {
_parent.step();
}
}
Symbol 36 MovieClip [laser6] Frame 7
stop();
Symbol 39 MovieClip [laser5] Frame 1
function step() {
ndx = -1;
while ((!dead) && ((ndx++) < _root.enemies.length)) {
dead = _root.enemies[ndx].hitTest(_x, _y, 0);
if (dead) {
_root.enemies[ndx].reload();
_root.playSound("flak.wav");
_root.score = _root.score + Math.floor((_root.g_ground - _root.enemies[ndx]._y) / 100);
}
}
if ((!dead) && (_root.ground.hitTest(_x, _y, 1) || (_y < -20))) {
dead = true;
if (_y > 0) {
_root.playSound("bomb.wav");
}
}
if (!dead) {
_alpha = 100;
radians = Math.atan(vy / vx);
if (vx > 0) {
_rotation = ((radians * 180) / 3.14159);
} else {
_rotation = (((radians * 180) / 3.14159) + 180);
}
_x = (_x + vx);
_y = (_y + vy);
} else {
gotoAndPlay (2);
}
}
stop();
Instance of Symbol 38 MovieClip in Symbol 39 MovieClip [laser5] Frame 1
onClipEvent (enterFrame) {
if (!_root.paused) {
_parent.step();
}
}
Symbol 39 MovieClip [laser5] Frame 7
stop();
Symbol 42 MovieClip [enemy1] Frame 1
function step() {
if (_root.saber.saberblue.hitTest(_x, _y, 1)) {
reload();
}
if (_y > dropAlt) {
_x = (_x + vx);
if (_x < 30) {
_x = 30;
vx = vx * -1;
} else if (_x > 1950) {
_x = 1950;
vx = vx * -1;
}
if (timeToDrop <= 0) {
timeToDrop = 5000 + random(5000);
_root.dropBomb(_x, _y, vx, vy);
}
} else {
_y = (_y + vy);
}
if (_y > 2000) {
_y = -50;
}
if ((timeToShoot <= 0) && (_y > _height)) {
timeToShoot = 20000 + random(5000);
shoot();
}
timeToShoot = timeToShoot - (_root.elapsed * 1000);
timeToDrop = timeToDrop - (_root.elapsed * 1000);
}
function shoot() {
toSaberX = _root.man._x - _x;
toSaberY = _root.man._y - _y;
total = 2;
degrees = -Math.ceil((3 * total) / 2);
rpd = 0.01745329;
theta = Math.atan(toSaberY / toSaberX);
d = Math.sqrt((toSaberX * toSaberX) + (toSaberY * toSaberY));
i = 0;
while (i < total) {
curx = (-Math.cos(theta + ((2 * degrees) * rpd))) * laserSpeed;
cury = (-Math.sin(theta + ((2 * degrees) * rpd))) * laserSpeed;
if (toSaberX > 0) {
curx = -curx;
cury = -cury;
}
degrees = degrees + 3;
_root.addEnemyLaser("laser6", _x, _y, curx, cury);
i++;
}
}
function reload() {
_x = (random(1900) - 50);
_y = ((-random(500)) - 250);
vy = vy + 0.1;
dropAlt = dropAlt - 10;
laserSpeed = laserSpeed + 0.5;
dead = false;
}
function reset() {
laserSpeed = 5;
vy = 0.5;
vx = -1.5;
dropAlt = 1950;
timeToDrop = 20000;
}
stop();
vy = 0.5;
vx = -1.5;
dropAlt = 1400;
laserSpeed = 5;
timeToDrop = 20000;
timeToShoot = random(30000) + 5000;
Instance of Symbol 41 MovieClip in Symbol 42 MovieClip [enemy1] Frame 1
onClipEvent (enterFrame) {
if (!_root.paused) {
_parent.step();
}
}
Symbol 45 MovieClip [bomb] Frame 1
function step() {
t = 0.1;
vy0 = vy;
vx0 = vx;
y0 = _y;
x0 = _x;
vx = (fx * t) + vx0;
vy = (fy * t) + vy0;
_x = (((((0.5 * fx) * t) * t) + (vx0 * t)) + x0);
_y = (((((0.5 * fy) * t) * t) + (vy0 * t)) + y0);
if (_root.ground.hitTest(_x, _y, 1) || (_root.game_over)) {
dead = true;
gotoAndPlay (2);
fy = 0;
fx = 0;
vy = 0;
vx = 0;
ndx = 0;
while (ndx < _root.colonies.length) {
trace("colony length: " + _root.colonies.length);
distx = _root.colonies[ndx]._x - _x;
disty = _root.colonies[ndx]._y - _y;
trace((("Colony X[" + ndx) + "]: ") + _root.colonies[ndx]._x);
range = Math.sqrt((distx * distx) + (disty * disty));
trace("Distance: " + range);
if ((!_root.colonies[ndx].dead) && (range < 110)) {
_root.colonies[ndx].gotoAndPlay("dead");
gotoAndPlay (2);
fy = 0;
fx = 0;
vy = 0;
vx = 0;
}
ndx++;
}
}
}
fy = 10;
stop();
Instance of Symbol 44 MovieClip in Symbol 45 MovieClip [bomb] Frame 1
onClipEvent (enterFrame) {
if ((!_root.paused) || (_root.game_over)) {
_parent.step();
}
}
Symbol 45 MovieClip [bomb] Frame 2
_root.playSound("bomb_hit.wav");
Symbol 45 MovieClip [bomb] Frame 47
stop();
Symbol 48 MovieClip [colony] Frame 1
function step() {
if ((!dead) && (timeLeftToScore <= 0)) {
timeLeftToScore = 5;
_root.score = _root.score + bonus;
_root.addFuel(50);
_root.addAmmo(5);
_root.addShield(1);
} else if (!dead) {
timeLeftToScore = timeLeftToScore - _root.elapsed;
}
if (!placed) {
t = 0.1;
vy0 = vy;
vx0 = vx;
y0 = _y;
x0 = _x;
vx = (fx * t) + vx0;
vy = (fy * t) + vy0;
_x = (((((0.5 * fx) * t) * t) + (vx0 * t)) + x0);
_y = (((((0.5 * fy) * t) * t) + (vy0 * t)) + y0);
if (_root.ground.hitTest(_x, _y, 1)) {
placed = true;
fy = 0;
fx = 0;
vy = 0;
vx = 0;
}
}
}
stop();
fx = 0;
fy = 10;
placed = false;
dead = false;
timeLeftToScore = 5;
bonus = 10;
Instance of Symbol 47 MovieClip in Symbol 48 MovieClip [colony] Frame 1
onClipEvent (enterFrame) {
if (!_root.paused) {
_parent.step();
}
}
Symbol 48 MovieClip [colony] Frame 2
_root.numColonies--;
dead = true;
Symbol 48 MovieClip [colony] Frame 30
stop();
Instance of Symbol 58 MovieClip "glow" in Symbol 69 MovieClip [light_saber2] Frame 1
/* no clip actions */
Symbol 81 MovieClip Frame 1
function jump() {
if (_root.fuel_count > 0) {
_root.fuel_count = _root.fuel_count - 10;
jumpTime = getTimer() + 100;
vy = vy - 5;
if (vy < -30) {
vy = -30;
}
newSpotY = _y;
count = 0;
amount = 0.05;
while (_root.ground.hitTest(_x, newSpotY, 1) && ((count++) < 20)) {
newSpotY = newSpotY - amount;
amount = amount + amount;
}
_y = newSpotY;
}
}
function step() {
if (direction == NM) {
} else if (direction == UP) {
moveUp();
} else if (direction == DN) {
moveDown();
} else if (direction == LF) {
moveLeft();
} else if (direction == RT) {
moveRight();
} else if (direction == DR) {
moveDown();
moveRight();
} else if (direction == UR) {
jump();
moveRight();
} else if (direction == DL) {
moveDown();
moveLeft();
} else if (direction == UL) {
jump();
moveLeft();
}
fly();
}
function fly() {
if (!_root.ground.hitTest(_x, _y, 1)) {
t = 0.1;
vy0 = vy;
vx0 = vx;
y0 = _y;
x0 = _x;
prevX = _x;
prevY = _y;
vy = (gravY * t) + vy0;
vx = (gravX * t) + vx0;
_y = (((((0.5 * gravY) * t) * t) + (vy0 * t)) + y0);
_x = (_x + vx);
if (_root.ground.hitTest(_x + (_width / 2), _y - _height, 1) && (vx > 0)) {
_x = (x0 - vx);
} else if (_root.ground.hitTest(_x - (_width / 2), _y - _height, 1) && (vx < 0)) {
_x = (x0 + vx);
}
if (_root.ground.hitTest(_x, _y - _height, 1) && (vy < 0)) {
vy = 0;
_y = y0;
}
} else if (direction != NM) {
vy = 0;
_x = (_x + vx);
count = 0;
newSpotX = _x;
newSpotY = _y;
dirY = 1;
dirX = 1;
amount = 1;
if ((_root.ground.hitTest(_x + 5, _y - 1, 1) || (_root.ground.hitTest(_x - 5, _y - 1, 1))) && (_root.ground.hitTest(newSpotX, newSpotY, 1))) {
while (_root.ground.hitTest(newSpotX, newSpotY, 1)) {
newSpotY = newSpotY - amount;
amount = amount * 2;
}
}
_y = newSpotY;
_x = newSpotX;
} else {
vx = 0;
vy = 0;
}
if (_x < 0) {
_x = (_root.g_width - 10);
_root.man._x = _x;
} else if (_x > _root.g_width) {
_x = 10;
_root.man._x = _x;
}
}
function moveRight() {
if (vx < 0) {
vx = vx + 0.2;
}
vx = vx + 0.1;
if (vx > 7) {
vx = 7;
}
}
function moveLeft() {
if (vx > 0) {
vx = vx - 0.2;
}
vx = vx - 0.1;
if (vx < -7) {
vx = -7;
}
}
function moveUp() {
if (_root.fuel_count > 0) {
_root.fuel_count = _root.fuel_count - 10;
vy = -0.5;
vx = vx * 0.9;
if (Math.abs(vx) < 0.02) {
vx = 0;
}
}
}
function moveDown() {
if (_root.fuel_count > 0) {
_root.fuel_count = _root.fuel_count - 10;
if (vy < 0) {
vy = vy + 3;
}
vy = vy + 2;
}
}
stop();
NM = 0;
RT = 1;
LF = 2;
DN = 3;
UP = 4;
JP = 5;
UR = 6;
UL = 7;
DR = 8;
DL = 9;
gravY = 5;
gravX = 0;
vx = 0;
vy = 0;
direction = NM;
flying = false;
jumpTime = getTimer() + 100;
Instance of Symbol 90 MovieClip "shield" in Symbol 91 MovieClip Frame 1
onClipEvent (enterFrame) {
_alpha = _root.shield;
}
Symbol 105 MovieClip Frame 1
stop();
Instance of Symbol 99 MovieClip in Symbol 105 MovieClip Frame 1
onClipEvent (enterFrame) {
_width = (_root.fuel_count / 120);
}
Instance of Symbol 99 MovieClip in Symbol 105 MovieClip Frame 1
onClipEvent (enterFrame) {
_width = (_root.hp * 5);
if (_root.hp < 3) {
_color = "red";
} else if (_root.hp <= 7) {
_color = "yellow";
} else {
_color = "green";
}
}
Instance of Symbol 100 MovieClip in Symbol 105 MovieClip Frame 1
onClipEvent (enterFrame) {
_height = (_root.ammo_count / 2);
}
Symbol 117 Button
on (release) {
_root.paused = !_root.paused;
}
on (keyPress "p") {
_root.paused = !_root.paused;
}
Symbol 124 Button
on (release) {
_root.end_game._y = -500;
_root.paused = false;
_root.resetGame();
}
Symbol 145 Button
on (release) {
_root.help._y = -500;
_root.paused = false;
}
Symbol 156 Button
on (release) {
_root.paused = !_root.paused;
}
Symbol 158 Button
on (press) {
_root.help._x = _root.g_width / 2;
_root.help._y = _root.g_ground / 2;
_root.paused = true;
}