Frame 1
stop();
Stage.showMenu = false;
this.onEnterFrame = function () {
sofar = this.getBytesLoaded();
total = this.getBytesTotal();
pc_txt.text = int((sofar / total) * 100) + "%";
if (sofar == total) {
delete this.onEnterFrame;
nextFrame();
}
};
Frame 2
stop();
clearInterval(beatTimeout);
Key.removeListener(keyListener);
MovieClip.prototype.wrapPos = function () {
if (this._x > (xMax + (this._width / 2))) {
if (this._name == "saucer_mc") {
this.hideSaucer();
} else {
this._x = this._x - (xMax + this._width);
}
}
if (this._y > (yMax + (this._height / 2))) {
this._y = this._y - (yMax + this._height);
}
if (this._x < ((-this._width) / 2)) {
if (this._name == "saucer_mc") {
this.hideSaucer();
} else {
this._x = this._x + (xMax + this._width);
}
}
if (this._y < ((-this._height) / 2)) {
this._y = this._y + (yMax + this._height);
}
};
introMover = function () {
this._x = this._x + this.vx;
this._y = this._y + this.vy;
this.wrapPos();
};
introAsteroids = function () {
var i = 10;
while (i--) {
var angle = (Math.random() * (Math.PI*2));
var s = [100, 50, 25][i % 3];
intro_mc.attachMovie("asteroid", i, i, {vx:Math.sin(angle) * 1.5, vy:Math.cos(angle) * 1.5, _x:Math.random() * xMax, _y:Math.random() * yMax, _xscale:s, _yscale:s, onEnterFrame:introMover}).gotoAndStop((i % 4) + 1);
}
};
game_so = SharedObject.getLocal("neaveAsteroids");
score = 0;
xMax = 500;
yMax = 375;
introAsteroids();
playGame_btn.onRelease = function () {
play();
};
highScores_btn.onRelease = function () {
gotoAndStop (4);
};
Frame 3
stop();
spaceship_mc.gotoAndStop(1);
spaceship_mc._visible = (spaceship_mc.hit_mc._visible = (safeArea_mc._visible = (gameOver_mc._visible = (quitGame_mc._visible = (missile0_mc._visible = (missile1_mc._visible = (missile2_mc._visible = (missile3_mc._visible = (missile4_mc._visible = (saucer_mc._visible = false))))))))));
dx = (dy = (explodeNum = (asteroidNum = (scoreMod = (score = 0)))));
level = 1;
lives = 3;
friction = 0.98;
rads = (Math.PI/180);
leftKey = (rightKey = (upKey = (fireKey = (paused = (exploded = (beatToggle = false))))));
asteroids_mc.createEmptyMovieClip("explode_mc", 0);
beat1_sound = new Sound(this);
beat1_sound.attachSound("beat1");
beat2_sound = new Sound(this);
beat2_sound.attachSound("beat2");
thrust_sound = new Sound(spaceship_mc);
thrust_sound.attachSound("thrust");
saucerBig_sound = new Sound(saucer_mc);
saucerBig_sound.attachSound("saucerBig");
saucerSmall_sound = new Sound(saucer_mc);
saucerSmall_sound.attachSound("saucerSmall");
setLives = function () {
lives_mc[lives].removeMovieClip();
var i = 0;
while (i < lives) {
var _mc = lives_mc.attachMovie("spaceship", i, i, {_x:i * 15, _xscale:60, _yscale:60});
_mc.gotoAndStop(1);
_mc.hit_mc._visible = false;
i++;
}
};
setLives();
keyListener = new Object();
keyListener.onKeyDown = function () {
switch (Key.getCode()) {
case Key.LEFT :
leftKey = true;
return;
case Key.RIGHT :
rightKey = true;
return;
case Key.UP :
if (paused) {
return(undefined);
}
if (!upKey) {
thrust_sound.start(0, 1000);
}
upKey = true;
spaceship_mc.play();
return;
case Key.SPACE :
fireKey = true;
return;
case 80 :
if (!quitGame_mc._visible) {
paused = !paused;
pauseSaucer();
}
return;
case 81 :
paused = (quitGame_mc._visible = true);
return;
case 78 :
if (quitGame_mc._visible) {
paused = (quitGame_mc._visible = false);
pauseSaucer();
}
return;
case 89 :
clearInterval(hyperTimeout);
clearInterval(newShipTimeout);
clearInterval(newGameTimeout);
gotoAndStop (2);
return;
case Key.SHIFT :
if (!(spaceship_mc._visible && (!paused))) {
break;
}
spaceship_mc._visible = false;
spaceship_mc.gotoAndStop(1);
leftKey = (rightKey = (upKey = (fireKey = false)));
dx = (dy = 0);
thrust_sound.stop();
hyperTimeout = setInterval(hyperspace, 500);
}
};
keyListener.onKeyUp = function () {
switch (Key.getCode()) {
case Key.LEFT :
leftKey = false;
return;
case Key.RIGHT :
rightKey = false;
return;
case Key.UP :
upKey = false;
thrust_sound.stop();
spaceship_mc.gotoAndStop(1);
return;
case Key.SPACE :
fireKey = false;
}
};
spaceship_mc.onEnterFrame = function () {
if (paused || (!this._visible)) {
return(undefined);
}
if (leftKey) {
this._rotation = this._rotation - 10;
}
if (rightKey) {
this._rotation = this._rotation + 10;
}
var vx = Math.sin(this._rotation * rads);
var vy = (-Math.cos(this._rotation * rads));
if (upKey) {
dx = dx + (vx / 4);
dy = dy + (vy / 4);
}
dx = dx * friction;
dy = dy * friction;
this._x = this._x + dx;
this._y = this._y + dy;
this.wrapPos();
if (fireKey) {
fireKey = false;
var i = 4;
var num = -1;
while (i--) {
if (!_root[("missile" + i) + "_mc"]._visible) {
num = i;
break;
}
}
if (num != -1) {
var _mc = _root[("missile" + num) + "_mc"];
_mc.fuse = 24;
_mc.vx = (vx * 10) + dx;
_mc.vy = (vy * 10) + dy;
_mc._x = this._x + (vx * 10);
_mc._y = this._y + (vy * 10);
_mc._visible = true;
_mc.onEnterFrame = missileMover;
sound_mc.gotoAndPlay("fire");
}
}
var s = int(score / 10000);
if (scoreMod != s) {
scoreMod = s;
lives++;
setLives();
sound_mc.gotoAndPlay("extra");
}
if (((missile4_mc.hitTest(this.hit_mc) && (!exploded)) && (this._visible)) && (missile4_mc._visible)) {
missile4_mc._visible = false;
exploded = true;
explodeSpaceship();
}
};
saucer_mc.hideSaucer = function () {
saucerBig_sound.stop();
saucerSmall_sound.stop();
this._visible = false;
delete this.onEnterFrame;
};
pauseSaucer = function () {
if (saucer_mc._visible) {
if (paused) {
saucerBig_sound.stop();
saucerSmall_sound.stop();
} else if (saucer_mc.small) {
saucerSmall_sound.start(0, 80);
} else {
saucerBig_sound.start(0, 80);
}
}
};
explodeSaucer = function () {
saucer_mc.hideSaucer();
var i = 6;
while (i--) {
var angle = (Math.random() * (Math.PI*2));
var vx = (Math.sin(angle) * 2);
var vy = (Math.cos(angle) * 2);
asteroids_mc.explode_mc.attachMovie("explosion", explodeNum, explodeNum, {vx:vx, vy:vy, fuse:Math.ceil(Math.random() * 40), _x:((vx * Math.random()) * 4) + saucer_mc._x, _y:((vy * Math.random()) * 4) + saucer_mc._y, onEnterFrame:explodeMover});
explodeNum++;
}
sound_mc.gotoAndPlay("bangMedium");
};
explodeSpaceship = function () {
spaceship_mc._visible = false;
explode_mc._x = spaceship_mc._x;
explode_mc._y = spaceship_mc._y;
lives--;
setLives();
var i = 4;
while (i--) {
var _mc = explode_mc.createEmptyMovieClip(i, i);
_mc.vx = Math.sin(Math.random() * (Math.PI*2));
_mc.vy = Math.cos(Math.random() * (Math.PI*2));
_mc.fuse = Math.ceil(Math.random() * 30) + 10;
_mc._x = (Math.random() * 12) - 6;
_mc._y = (Math.random() * 12) - 6;
_mc._rotation = Math.random() * 360;
_mc.lineStyle(0, 16777215);
_mc.moveTo(0, -8);
_mc.lineTo(0, 8);
_mc.onEnterFrame = explodeMover;
}
if (lives > 0) {
newShipTimeout = setInterval(newSpaceship, 1500);
} else {
gameOver_mc.gotoAndPlay(2);
gameOver_mc._visible = true;
quitGame_mc._visible = false;
Key.removeListener(keyListener);
clearInterval(hyperTimeout);
clearInterval(newShipTimeout);
clearInterval(newGameTimeout);
thrust_sound.stop();
saucerBig_sound.stop();
saucerSmall_sound.stop();
}
sound_mc.gotoAndPlay("bangMedium");
};
explodeMover = function () {
if (paused) {
return(undefined);
}
this._x = this._x + this.vx;
this._y = this._y + this.vy;
this.fuse--;
if (this.fuse < 0) {
this.removeMovieClip();
}
};
missileMover = function () {
if (paused) {
return(undefined);
}
this._x = this._x + this.vx;
this._y = this._y + this.vy;
this.wrapPos();
this.fuse--;
if (this.fuse == 0) {
this._visible = false;
delete this.onEnterFrame;
}
};
saucerMover = function () {
if (paused) {
return(undefined);
}
this._x = this._x + this.vx;
if (Math.random() < 0.02) {
this.vy = (int(Math.random() * 3) - 1) * 2;
}
if (this.vy != 0) {
this._y = this._y + this.vy;
}
this.wrapPos();
var i = 4;
while (i--) {
var _mc = _root[("missile" + i) + "_mc"];
if (_mc._visible) {
if (_mc.hitTest(this)) {
_mc._visible = false;
explodeSaucer();
if (this.small) {
score = score + 1000;
} else {
score = score + 200;
}
}
}
}
var _mc = missile4_mc;
if ((!_mc._visible) && (Math.random() < 0.1)) {
var angle = ((this.small && (spaceship_mc._visible)) ? (Math.atan2(((spaceship_mc._x - this._x) + (Math.random() * 64)) - 32, ((this._y - spaceship_mc._y) + (Math.random() * 64)) - 32)) : (Math.random() * (Math.PI*2)));
_mc.fuse = 24;
_mc.vx = Math.sin(angle) * 8;
_mc.vy = Math.cos(angle) * -8;
_mc._x = this._x + _mc.vx;
_mc._y = this._y + (_mc.vy * 2);
_mc._visible = true;
_mc.onEnterFrame = missileMover;
sound_mc.gotoAndPlay("fire");
}
if ((spaceship_mc.hit_mc.hitTest(this) && (!exploded)) && (spaceship_mc._visible)) {
exploded = true;
explodeSpaceship();
}
};
asteroidMover = function () {
if (paused) {
return(undefined);
}
this._x = this._x + this.vx;
this._y = this._y + this.vy;
this.wrapPos();
var asteroidHit = false;
var spaceshipShot = false;
if (saucer_mc._visible && (saucer_mc.hitTest(this))) {
asteroidHit = true;
explodeSaucer();
}
if ((spaceship_mc.hit_mc.hitTest(this) && (!exploded)) && (spaceship_mc._visible)) {
exploded = (asteroidHit = (spaceshipShot = true));
explodeSpaceship();
}
var i = 5;
while (i--) {
var _mc = _root[("missile" + i) + "_mc"];
if (_mc._visible && (_mc.hitTest(this))) {
_mc._visible = false;
asteroidHit = true;
if (i < 4) {
spaceshipShot = true;
}
break;
}
}
if (asteroidHit) {
var s = ((this._xscale = (this._yscale = this._yscale / 2)));
var angle = (Math.random() * (Math.PI*2));
this.vx = this.vx + Math.sin(angle);
this.vy = this.vy + Math.cos(angle);
asteroidCount--;
var j = (int(s / 25) + 4);
while (j--) {
var angle = (Math.random() * (Math.PI*2));
var vx = (Math.sin(angle) * 2);
var vy = (Math.cos(angle) * 2);
asteroids_mc.explode_mc.attachMovie("explosion", explodeNum, explodeNum, {vx:vx, vy:vy, fuse:Math.ceil(Math.random() * s), _x:((vx * Math.random()) * 4) + this._x, _y:((vy * Math.random()) * 4) + this._y, onEnterFrame:explodeMover});
explodeNum++;
}
if (s < 25) {
this.removeMovieClip();
sound_mc.gotoAndPlay("bangSmall");
if (spaceshipShot) {
score = score + 100;
}
} else {
if (s == 50) {
sound_mc.gotoAndPlay("bangLarge");
if (spaceshipShot) {
score = score + 20;
}
} else {
sound_mc.gotoAndPlay("bangMedium");
if (spaceshipShot) {
score = score + 50;
}
}
this.gotoAndStop((i % 4) + 1);
var angle = (Math.random() * (Math.PI*2));
makeAsteroid(this._x, this._y, this.vx + Math.sin(angle), this.vy + Math.cos(angle), s);
}
}
};
makeAsteroid = function (x, y, vx, vy, s) {
asteroidNum++;
var _mc = asteroids_mc.attachMovie("asteroid", asteroidNum, asteroidNum, {vx:vx, vy:vy, _x:x, _y:y, _xscale:s, _yscale:s, onEnterFrame:asteroidMover});
_mc.gotoAndStop((asteroidNum % 4) + 1);
return(_mc);
};
hyperspace = function () {
if (paused) {
return(undefined);
}
with (spaceship_mc) {
_visible = true;
_x = (Math.random() * (xMax - (_width * 2))) + _width;
_y = (Math.random() * (yMax - (_height * 2))) + _height;
}
clearInterval(hyperTimeout);
};
beatSound = function () {
if (paused) {
return(undefined);
}
beatToggle = !beatToggle;
if (beatToggle) {
beat1_sound.start();
} else {
beat2_sound.start();
}
if (gameOver_mc._visible) {
return(undefined);
}
if (beatCount > 300) {
beatCount = beatCount - 10;
clearInterval(beatTimeout);
beatTimeout = setInterval(beatSound, beatCount);
}
if (((beatCount < 700) && (!saucer_mc._visible)) && (Math.random() < 0.05)) {
if ((beatCount < 400) && (Math.random() < 0.4)) {
saucer_mc._xscale = (saucer_mc._yscale = 50);
saucer_mc.small = true;
saucerSmall_sound.start(0, 100);
} else {
saucer_mc._xscale = (saucer_mc._yscale = 100);
saucer_mc.small = false;
saucerBig_sound.start(0, 100);
}
if (Math.random() < 0.5) {
saucer_mc.vx = -2;
saucer_mc._x = (saucer_mc._width / 2) + xMax;
} else {
saucer_mc.vx = 2;
saucer_mc._x = saucer_mc._width / -2;
}
saucer_mc.vy = 0;
saucer_mc._y = Math.random() * yMax;
saucer_mc._visible = true;
saucer_mc.onEnterFrame = saucerMover;
}
if ((asteroidCount == 0) && (!saucer_mc._visible)) {
clearInterval(beatTimeout);
level++;
newGameTimeout = setInterval(newGame, 1000);
}
};
newSpaceship = function () {
spaceship_mc._x = 250;
spaceship_mc._y = 190;
spaceship_mc._rotation = 0;
var asteroidHit = false;
for (var i in asteroids_mc) {
if (spaceship_mc.hitTest(asteroids_mc[i])) {
asteroidHit = true;
break;
}
}
if (!asteroidHit) {
spaceship_mc._visible = true;
exploded = false;
dx = (dy = 0);
clearInterval(newShipTimeout);
}
};
newGame = function () {
var i = ((level < 7) ? (level + 3) : 10);
asteroidCount = i * 7;
while (i--) {
var angle = (Math.random() * (Math.PI*2));
var _mc = makeAsteroid(Math.random() * xMax, Math.random() * yMax, Math.sin(angle) * 1.5, Math.cos(angle) * 1.5, 100);
if (_mc.hitTest(spaceship_mc) || (_mc.hitTest(safeArea_mc))) {
i++;
asteroidNum--;
}
}
beatCount = ((level < 7) ? (1100 - (level * 100)) : 400);
beatSound();
Key.addListener(keyListener);
clearInterval(newGameTimeout);
};
newGameTimeout = setInterval(newGame, 1000);
newShipTimeout = setInterval(newSpaceship, 1100);
Frame 4
stop();
clearInterval(beatTimeout);
showScores = function () {
var i = 10;
while (i > 0) {
var n = scoreboard_lv["name" + (page + i)];
var s = scoreboard_lv["score" + (page + i)];
var l_mc = this[("line" + i) + "_mc"];
l_mc.rank_txt.text = (page + i) + ".";
l_mc.name_txt.text = (n.length ? (n.toUpperCase()) : "-");
l_mc.score_txt.text = (s.length ? (s) : "-");
l_mc._visible = true;
loading_mc._visible = false;
i--;
}
};
page = 0;
maxScore = 100;
scoreboard_lv = new LoadVars();
if ((score > 0) && (game_so.data.playerName.length > 0)) {
scoreboard_lv.score = score;
scoreboard_lv.name = game_so.data.playerName.toLowerCase();
}
scoreboard_lv.game = "asteroids";
scoreboard_lv.sendAndLoad("/media/flash_asteroids/fa.php", scoreboard_lv, "POST");
scoreboard_lv.onLoad = function (success) {
if (success) {
if (Boolean(scoreboard_lv.success)) {
next_btn._visible = true;
if (scoreboard_lv.maxScore.length > 0) {
maxScore = Number(scoreboard_lv.maxScore);
}
showScores();
} else {
loading_mc.errorMsg = scoreboard_lv.errorMsg.toUpperCase();
loading_mc.gotoAndStop(2);
}
} else {
loading_mc.errorMsg = "COULD NOT ACCESS SCORES.";
loading_mc.gotoAndStop(2);
}
};
score = 0;
next_btn._visible = (last_btn._visible = false);
last_btn.onPress = function () {
page = page - 10;
if (page < 0) {
page = 0;
}
if (page < 10) {
last_btn._visible = false;
}
next_btn._visible = true;
showScores();
};
next_btn.onPress = function () {
page = page + 10;
if (page > maxScore) {
page = maxScore;
}
if (page > (maxScore - 20)) {
next_btn._visible = false;
}
last_btn._visible = true;
showScores();
};
newGame_btn.onRelease = function () {
gotoAndStop (2);
};
Symbol 30 Button
on (press) {
getURL ("http://www.thepcmanwebsite.com/", "_top");
}
Symbol 44 MovieClip Frame 1
stop();
Symbol 44 MovieClip Frame 3
stop();
Symbol 44 MovieClip Frame 5
stop();
Symbol 44 MovieClip Frame 7
stop();
Symbol 44 MovieClip Frame 9
stop();
Symbol 44 MovieClip Frame 11
stop();
Symbol 52 MovieClip Frame 1
stop();
Symbol 52 MovieClip Frame 61
stop();
name_txt.restrict = "A-Z 0-9.\\-";
if (_root.game_so.data.playerName.length > 0) {
name_txt.text = _root.game_so.data.playerName;
}
Selection.setFocus(name_txt);
Selection.setSelection(name_txt.length, name_txt.length);
ok_btn.onRelease = function () {
if (name_txt.length > 0) {
_root.game_so.data.playerName = name_txt.text;
}
_root.nextFrame();
};
ok_btn.onKeyDown = function () {
if (Key.getCode() == 13) {
Key.removeListener(ok_btn);
this.onRelease();
}
};
Key.addListener(ok_btn);
Symbol 66 MovieClip Frame 1
stop();
errorMsg = "";