Frame 1
function moveHero(speed) {
if (Key.isDown(38) and (_root.hero._y > 30)) {
_root.hero._y = _root.hero._y - speed;
}
if (Key.isDown(37) and (_root.hero._x > 25)) {
_root.hero._x = _root.hero._x - speed;
}
if (Key.isDown(40) and (_root.hero._y < 290)) {
_root.hero._y = _root.hero._y + speed;
}
if (Key.isDown(39) and (_root.hero._x < 530)) {
_root.hero._x = _root.hero._x + speed;
}
if (Key.isDown(32)) {
if ((fire == false) and (fire_c < 4)) {
_root.hero.gotoAndPlay("shoot");
}
}
}
function fireBullets() {
fire = true;
fire_c++;
i++;
var _local4 = "bullet" + i;
_root.attachMovie("bullet", _local4, i * 100);
_root[_local4]._y = _root.hero._y + 2;
_root[_local4]._x = _root.hero._x + 2;
_root[_local4].onEnterFrame = function () {
var _local4 = 8;
this._x = this._x + _local4;
if (this._x > 555) {
this.removeMovieClip();
fire_c--;
}
var _local3 = 1;
while (_local3 <= numEnemy) {
if (this.hitTest(_root["enemy" + _local3])) {
this.removeMovieClip();
_root["enemy" + _local3].gotoAndPlay("blow");
fire_c--;
}
_local3++;
}
};
}
function Enemys() {
j = 2;
while (j <= numEnemy) {
var _local2 = "enemy" + j;
_root.enemy1.duplicateMovieClip(_local2, j);
j++;
}
}
function enemyBullets(enemy) {
j++;
var _local3 = "ebullet" + j;
_root.attachMovie("ebullet", _local3, j * 400);
_root[_local3]._y = enemy._y + 8.5;
_root[_local3]._x = enemy._x;
_root[_local3].onEnterFrame = function () {
var _local3 = 6;
this._x = this._x - _local3;
if (this._x < 0) {
this.removeMovieClip();
}
if (this.hitTest(_root.hero)) {
this.removeMovieClip();
_root.hero.gotoAndPlay("hit");
if (_root.life == 0) {
_root.gotoAndStop(2);
}
}
};
}
stop();
var fire = false;
var fire_c = 0;
var life = 100;
gameBGM = new Sound();
gameBGM.attachSound("area_1");
gameBGM.onSoundComplete = function () {
gameBGM.start(5.04);
};
gameBGM.start();
gameBGM.setVolume(50);
_root.onEnterFrame = function () {
_root.lifebar._xscale = life;
moveHero(5);
x_pos.text = _root.hero._x;
y_pos.text = _root.hero._y;
};
var i = 0;
if (_root.hero.hitTest(_root.enemy)) {
_root.hero.gotoAndPlay("hit");
}
var numEnemy = 5;
Enemys();
Instance of Symbol 36 MovieClip "enemy1" in Frame 1
onClipEvent (load) {
function reset() {
clearInterval(shoot);
this._x = 550;
this._y = Math.random() * 300;
maxH = this._y + 100;
minH = this._y - 100;
enemySpeed = (Math.random() * 3) + 1;
interval = (Math.random() * 2000) + 1000;
shoot = setInterval(_root.enemyBullets, interval, this);
}
reset();
var upspeed = (-enemySpeed);
}
onClipEvent (enterFrame) {
this._x = this._x - enemySpeed;
this._y = this._y + upspeed;
if ((this._y < minH) || (this._y < 0)) {
upspeed = enemySpeed;
} else if ((this._y > maxH) || (this._y > 290)) {
upspeed = upspeed * -1;
}
if (this._x < -10) {
reset();
}
if (this.hitTest(_root.hero)) {
_root.hero.gotoAndPlay("hit");
if (_root.life == 0) {
_root.gotoAndStop(2);
}
}
}
Frame 2
gameBGM.stop();
Symbol 14 MovieClip [ebullet] Frame 25
gotoAndPlay (1);
Symbol 31 MovieClip Frame 1
stop();
Symbol 31 MovieClip Frame 10
_root.fireBullets();
_root.fire = false;
Symbol 31 MovieClip Frame 16
gotoAndPlay (1);
Symbol 31 MovieClip Frame 25
gotoAndPlay (1);
_root.life = _root.life - 10;
Symbol 36 MovieClip Frame 25
gotoAndPlay (1);
Symbol 36 MovieClip Frame 32
this.reset();
gotoAndPlay (1);
Symbol 50 Button
on (release) {
gotoAndPlay (1);
}