Frame 1
function runGame() {
if (Key.isDown(38) || (Key.isDown(87))) {
if (velocityY < velocityYMax) {
velocityY = velocityY + acceleration;
}
}
if (Key.isDown(40) || (Key.isDown(83))) {
if (velocityY > velocityYMaxReverse) {
velocityY = velocityY - acceleration;
}
}
if (Key.isDown(39) || (Key.isDown(68))) {
mcMain.gotoAndPlay(3);
if (velocityX > velocityXMaxReverse) {
velocityX = velocityX - acceleration;
}
} else {
mcMain.gotoAndPlay(1);
}
if (Key.isDown(37) || (Key.isDown(65))) {
mcMain.gotoAndPlay(2);
if (velocityX < velocityXMax) {
velocityX = velocityX + acceleration;
}
}
velocityX = velocityX * friction;
velocityY = velocityY * friction;
mcMain._x = mcMain._x - velocityX;
mcMain._y = mcMain._y - velocityY;
if (mcMain._x < boundryLeft) {
mcMain._x = boundryLeft;
}
if (mcMain._x > boundryRight) {
mcMain._x = boundryRight;
}
if (mcMain._y < boundryTop) {
mcMain._y = boundryTop;
}
if (mcMain._y > boundryBot) {
mcMain._y = boundryBot;
}
}
stop();
var gameOver = false;
var mainSpeed = 15;
var cTime = 0;
var cLimit = 15;
var shootAllow = false;
var enemyTime = 0;
var enemyLimit = 20;
var enemyTotal = 0;
var score = 0;
_root.createEmptyMovieClip("bgHolder", _root.getNextHighestDepth());
_root.createEmptyMovieClip("bulletHolder", _root.getNextHighestDepth());
var velocityX = 0;
var velocityY = 0;
var velocityXMax = 5;
var velocityYMax = 5;
var velocityXMaxReverse = -5;
var velocityYMaxReverse = -5;
var acceleration = 1;
var friction = 0.98;
var boundryTop = 0;
var boundryBot = (Stage.height - 200);
var boundryLeft = 0;
var boundryRight = Stage.width;
mcMain.onEnterFrame = function () {
runGame();
};
onEnterFrame = function () {
if (Key.isDown(32) && (shootAllow)) {
var _local3 = Math.random();
bulletHolder.attachMovie("mcBullet", "Bullet" + _local3, bulletHolder.getNextHighestDepth());
bulletHolder["Bullet" + _local3]._x = mcMain._x;
bulletHolder["Bullet" + _local3]._y = mcMain._y - 40;
bulletHolder["Bullet" + _local3].onEnterFrame = function () {
this._y = this._y - 7;
if (this._y < (-1 * this._height)) {
this.removeMovieClip();
}
if (gameOver) {
this.removeMovieClip();
}
};
shootAllow = false;
}
cTime++;
if (cTime == cLimit) {
shootAllow = true;
cTime = 0;
}
enemyTime++;
if (enemyTime == enemyLimit) {
_root.attachMovie("mcEnemy", "en" + enemyTotal, _root.getNextHighestDepth());
_root["en" + enemyTotal]._x = int(Math.random() * Stage.width);
_root["en" + enemyTotal]._y = -800;
_root["en" + enemyTotal].onEnterFrame = function () {
this._y = this._y + 3;
for (var _local3 in _root.bulletHolder) {
if ((this._y >= (_root.bulletHolder[_local3]._y - 30)) && (this._y <= _root.bulletHolder[_local3]._y)) {
if ((this._x <= (_root.bulletHolder[_local3]._x + 5)) && (this._x >= (_root.bulletHolder[_local3]._x - 35))) {
this.gotoAndPlay(2);
_root.bulletHolder[_local3].removeMovieClip();
_root.score = _root.score + 25;
}
}
}
if (this.hitTest(_root.mcMain)) {
gameOver = true;
stopAllSounds();
gotoAndStop ("lose");
mcMain.removeMovieClip();
}
if (gameOver || (this._y > 850)) {
this.removeMovieClip();
}
};
enemyTime = 0;
enemyTotal++;
}
txtScore.text = "Score: " + score;
};
mcMain.swapDepths(1000);
_root.ascore.swapDepths(999999);
Frame 5
stop();
_root.onEnterFrame = function () {
if (Key.isDown(82)) {
gotoAndStop (1);
}
};
txtFinalScore.text = score;
Symbol 17 MovieClip [mcEnemy] Frame 1
stop();
Symbol 17 MovieClip [mcEnemy] Frame 10
onEnterFrame = function () {
this.removeMovieClip();
};
Symbol 36 MovieClip Frame 1
stop();
Symbol 36 MovieClip Frame 2
stop();
Symbol 36 MovieClip Frame 3
stop();