Frame 1
function title_screen() {
attachMovie("main_menu", "main_menu", 1);
if (_root.plname) {
main_menu.player_name.text = _root.plname;
}
main_menu.play_button.onPress = function () {
_root.plname = main_menu.player_name.text;
removeMovieClip(main_menu);
game_init();
};
}
function game_init() {
game_playing = 1;
level = 1;
game_over = 0;
firing = 0;
score = 0;
Mouse.hide();
_root.createEmptyMovieClip("game_scene", 1);
game_scene.attachMovie("back", "back", 2);
game_scene.attachMovie("hero", "hero", 3, {_y:400});
game_scene.hero.onEnterFrame = function () {
((_xmouse < 40) ? ((this._x = 40)) : (((_xmouse > 460) ? ((this._x = 460)) : ((this._x = _xmouse)))));
if (slow_enemy > 1) {
slow_enemy = slow_enemy - 0.1;
}
};
game_scene.attachMovie("crosshair", "crosshair", 4);
game_scene.crosshair.onEnterFrame = function () {
this._x = game_scene.hero._x;
this._y = _ymouse;
};
game_scene.attachMovie("points", "points", 10003);
game_scene.points.my_score.text = 0;
enterlevel(1);
}
function enterlevel() {
combo = 0;
kills = 0;
slow_enemy = 1;
x = 1;
while (x <= (_root.level + 2)) {
enemy = game_scene.attachMovie("alien", "alien_" + game_scene.getNextHighestDepth(), game_scene.getNextHighestDepth(), {_x:50 + (Math.random() * 400), _y:50 + (Math.random() * 200)});
enemy.enemynum.text = x;
enemy.points = x;
dir = Math.random() * 360;
enemy.speedx = (Math.cos((dir * Math.PI) / 180) * x) / 2;
enemy.speedy = (Math.sin((dir * Math.PI) / 180) * x) / 2;
enemy.onEnterFrame = function () {
this._x = this._x + (this.speedx / slow_enemy);
this._y = this._y + (this.speedy / slow_enemy);
if ((((this._x - 25) < 0) and (this.speedx < 0)) or (((this._x + 25) > 500) and (this.speedx > 0))) {
this.speedx = this.speedx * -1;
}
if ((((this._y - 25) < 0) and (this.speedy < 0)) or (((this._y + 25) > 400) and (this.speedy > 0))) {
this.speedy = this.speedy * -1;
}
dist_x = this._x - _root.game_scene.hero._x;
dist_y = this._y - _root.game_scene.hero._y;
abs_dist = Math.sqrt((dist_x * dist_x) + (dist_y * dist_y));
if (abs_dist < 65) {
pop_sound.start();
removeMovieClip(this);
removeMovieClip(game_scene.crosshair);
removeMovieClip(game_scene.hero);
Mouse.show();
game_over = 1;
game_scene.attachMovie("play_again", "play_again", game_scene.getNextHighestDepth());
game_scene.play_again._x = 250;
game_scene.play_again._y = 300;
game_scene.play_again.onRelease = function () {
removeMovieClip(game_scene);
title_screen();
};
}
bullet_dist_x = this._x - game_scene.fire._x;
bullet_dist_y = this._y - game_scene.fire._y;
bullet_abs_dist = Math.sqrt((bullet_dist_x * bullet_dist_x) + (bullet_dist_y * bullet_dist_y));
if (bullet_abs_dist < 28) {
if (this.points == combo) {
combo_bonus = combo_bonus + (this.points * 100);
} else {
combo_bonus = 0;
}
combo = this.points + 1;
height_bonus = (this.points * 100) * (Math.ceil((400 - this._y) / 40) - 1);
score = score + (((this.points * 100) + height_bonus) + combo_bonus);
game_scene.points.my_score.text = score;
earned = game_scene.attachMovie("disp_score", "disp_score_" + game_scene.getNextHighestDepth(), game_scene.getNextHighestDepth(), {_x:this._x, _y:this._y});
earned.disp.text = (((("Bubble score: " + (this.points * 100)) + "\nHeight bonus: ") + height_bonus) + "\nCombo bonus: ") + combo_bonus;
earned.rem = 0;
earned.onEnterFrame = function () {
this._y = this._y - 0.5;
this.rem++;
if (this.rem > 100) {
removeMovieClip(this);
}
};
pop_sound.start();
removeMovieClip(this);
removeMovieClip(_root.game_scene.fire);
firing = 0;
kills++;
slow_enemy = 3;
if (kills == (_root.level + 2)) {
_root.level++;
enterlevel(_root.level);
}
}
};
x++;
}
}
function onMouseDown() {
if (((!firing) and (!game_over)) and game_playing) {
firing = 1;
shot_sound.start();
game_scene.attachMovie("fire", "fire", 1000, {_x:_xmouse, _y:357});
game_scene.fire.onEnterFrame = function () {
this._y = this._y - 5;
if (this._y < 0) {
removeMovieClip(this);
firing = 0;
}
};
}
}
game_playing = 0;
shot_sound = new Sound();
shot_sound.attachSound("shoot_sound");
pop_sound = new Sound();
pop_sound.attachSound("ppop_sound");
title_screen();