Combined Code
movieClip 7 playerShip {
}
movieClip 19 playerExplosion {
frame 29 {
_root.spawnPlayer();
this.removeMovieClip();
}
}
frame 1 {
function spawnPlayer() {
if (playerLives > 0) {
player = attachMovie('playerShip', 'player', 1);
player._xscale = playerScale;
player._yscale = playerScale;
playerX = 100;
playerY = 300;
player._x = playerX;
player._y = playerY;
playerIsAlive = true;
}
}
function playerKill() {
deadPlayer = attachMovie('playerExplosion', 'deadPlayer', 2);
deadPlayer._xscale = playerScale;
deadPlayer._yscale = playerScale;
deadPlayer._x = player._x;
deadPlayer._y = player._y;
--playerLives;
player.removeMovieClip();
playerIsAlive = false;
}
function playerMovement() {
if (player._y - playerSpeed >= 50) {
if (Key.isDown(87) || Key.isDown(38)) {
player._y -= playerSpeed;
}
}
if (player._y + playerSpeed <= 550) {
if (Key.isDown(83) || Key.isDown(40)) {
player._y += playerSpeed;
}
}
if (player._x - playerSpeed >= 100) {
if (Key.isDown(65) || Key.isDown(37)) {
player._x -= playerSpeed;
}
}
if (player._x + playerSpeed <= 750) {
if (Key.isDown(68) || Key.isDown(39)) {
player._x += playerSpeed;
}
}
}
function getNewAsteroid() {
astNum += 1;
duplicateMovieClip(_root.asteroid, 'asteroid' + astNum, astNum);
}
var playerSpeed = 12;
var playerScale = 20;
var player;
var deadPlayer;
var playerX;
var playerY;
var playerIsAlive;
var playerLives;
var astCount;
var astNum;
this.onLoad = function () {
astNum = 1;
astCount = 1;
playerIsAlive = true;
playerLives = 3;
bgSound = new Sound(this);
bgSound.attachSound('bgMusic');
bgSound.start(0, 99);
spawnPlayer();
astCount;
while (astCount <= 8) {
getNewAsteroid();
++astCount;
}
};
this.onEnterFrame = function () {
if (playerIsAlive == true) {
playerMovement();
}
};
}
movieClip 21 {
}
movieClip 22 {
}
// unknown tag 88 length 73
movieClip 27 {
frame 1 {
function reLoad() {
var v2 = random(40) + 10;
var v3 = random(28) + 2;
this._x = 1000;
this._y = random(550) + 50;
this._xscale = v2;
this._yscale = v2;
}
}
}
instance asteroid of movieClip 27 {
onClipEvent (load) {
var scale = random(40) + 10;
var astSpeed = random(28) + 2;
this._x = 1000;
this._y = random(550) + 50;
this._xscale = scale;
this._yscale = scale;
}
onClipEvent (enterFrame) {
this._x -= astSpeed;
this._rotation -= astSpeed;
this;
if (hitTest(_root.player)) {
_root.playerKill();
this.reLoad();
}
this;
if (hitTest(_root.xBoundary)) {
this.reLoad();
}
}
}
movieClip 29 {
}