Frame 1
function xgtl(xcoord) {
switch (CURRENT_SCREEN) {
case 1 :
return(xcoord - SCREEN1_X);
case 2 :
return(xcoord - SCREEN2_X);
case 3 :
return(xcoord - SCREEN3_X);
case 4 :
return(xcoord - SCREEN4_X);
case 5 :
return(xcoord - SCREEN5_X);
case 6 :
return(xcoord - SCREEN6_X);
case 7 :
return(xcoord - SCREEN7_X);
case 8 :
return(xcoord - SCREEN8_X);
case 9 :
return(xcoord - SCREEN9_X);
}
}
function ygtl(ycoord) {
switch (CURRENT_SCREEN) {
case 1 :
return(ycoord - SCREEN1_Y);
case 2 :
return(ycoord - SCREEN2_Y);
case 3 :
return(ycoord - SCREEN3_Y);
case 4 :
return(ycoord - SCREEN4_Y);
case 5 :
return(ycoord - SCREEN5_Y);
case 6 :
return(ycoord - SCREEN6_Y);
case 7 :
return(ycoord - SCREEN7_Y);
case 8 :
return(ycoord - SCREEN8_Y);
case 9 :
return(ycoord - SCREEN9_Y);
}
}
function updatescore() {
score_display.text = SCORE;
if (SCORE >= Math.pow(2, ENEMYCNT)) {
levelup();
}
}
function levelup() {
var _local1 = ENEMYCNT;
ENEMYCNT = ENEMYCNT * 2;
SCORE_INCREMENT = SCORE_INCREMENT * 2;
RESPAWN_TIMER = RESPAWN_TIMER / 2;
while (_local1++ , _local1 <= ENEMYCNT) {
ENEMIES[_local1] = false;
}
}
function earnpoints() {
SCORE = SCORE + SCORE_INCREMENT;
SCORE_INCREMENT = Math.floor(SCORE_INCREMENT * POINTS_BONUS);
updatescore();
}
function spawn() {
removeMovieClip("spaceship");
var _local1 = 0;
while (_local1++ , _local1 <= ENEMYCNT) {
removeMovieClip("ENEMY_" + _local1);
ENEMIES[_local1] = false;
}
STATE = STATE & 0;
SAVOR_COUNTER = DEFAULT_SAVORTIME;
SCORE_INCREMENT = BASE_POINTS;
ENEMYCNT = STARTING_ENEMIES;
LEVEL_COUNTDOWN = DIFFICULTY_TIMER;
CURRENT_SCREEN = 5;
THRUST_X = 0;
THRUST_Y = 0;
BEAM_TIMER = BEAM_TIME;
RECHARGE_TIMER = RECHARGE_TIME;
ENEMY_RESPAWN_TIME = DEFAULT_EN_R_TIME;
RESPAWN_TIMER = ENEMY_RESPAWN_TIME;
LEVEL_TIMER = RESPAWN_TIMER;
SCORE = 0;
updatescore();
attachMovie("hero", "spaceship", 1);
X = Math.floor(Math.random() * MAPSIZE_X);
Y = Math.floor(Math.random() * MAPSIZE_Y);
}
function destroy(enemy) {
_root["ENEMY_" + enemy].gotoAndStop(2);
ENEMIES[enemy] = false;
earnpoints();
}
function d2r(v) {
return(Math.PI * (v / 180));
}
function spawn_enemy() {
var _local1 = 0;
_local1++;
while (ENEMIES[_local1]) {
}
if (_local1 > ENEMYCNT) {
return(undefined);
}
removeMovieClip("ENEMY_" + _local1);
var _local4 = attachMovie("badguy", "ENEMY_" + _local1, 1 + _local1);
var _local3 = Math.floor(Math.random() * MAPSIZE_X);
var _local2 = Math.floor(Math.random() * MAPSIZE_Y);
ENEMIES_X[_local1] = _local3;
ENEMIES_Y[_local1] = _local2;
ENEMIES[_local1] = true;
LEVEL_TIMER = RESPAWN_TIMER;
}
function rotate_cw() {
if ((STATE & (SPAWNING | SAVOR_TIME)) == 0) {
spaceship._rotation = spaceship._rotation + (((STATE & THRUSTING) == 0) ? (AGILITY) : (AGILITY * AGILITY_PENALTY));
}
}
function rotate_ccw() {
if ((STATE & (SPAWNING | SAVOR_TIME)) == 0) {
spaceship._rotation = spaceship._rotation - (((STATE & THRUSTING) == 0) ? (AGILITY) : (AGILITY * AGILITY_PENALTY));
}
}
function do_thrust() {
if (0 == (STATE & FIRING)) {
}
STATE = STATE ^ THRUSTING;
THRUST_Y = THRUST_Y - (Math.cos(d2r(spaceship._rotation)) * ENGINE_POWER);
THRUST_X = THRUST_X + (Math.sin(d2r(spaceship._rotation)) * ENGINE_POWER);
}
function enemy_do_thrust(enem_number) {
if (ENEMY_X[enem_number] == X) {
die();
return(undefined);
}
_root["ENEMY_" + enem_number]._rotation = _root["ENEMY_" + enem_number]._rotation + ((Math.random * 360) * ENEMY_AGILITY);
ENEMIES_Y[enem_number] = ENEMIES_Y[enem_number] + (((Math.random() * 2) - 1) * ENEMY_ENGINE_POWER);
ENEMIES_X[enem_number] = ENEMIES_X[enem_number] + (((Math.random() * 2) - 1) * ENEMY_ENGINE_POWER);
}
function beam() {
spaceship.gotoAndStop(3);
var _local2 = 0;
while (_local2++ , _local2 <= ENEMYCNT) {
if (ENEMIES[_local2]) {
if (spaceship.hitTest(_root["ENEMY_" + _local2])) {
destroy(_local2);
}
}
}
}
function change_room() {
if (X > MAPSIZE_X) {
X = X - MAPSIZE_X;
} else if (X < 0) {
X = X + MAPSIZE_X;
}
if (Y > MAPSIZE_Y) {
Y = Y - MAPSIZE_Y;
} else if (Y < 0) {
Y = Y + MAPSIZE_Y;
}
if (((X - SCREEN1_X) < SCREENSIZE_X) && ((Y - SCREEN1_Y) < SCREENSIZE_Y)) {
CURRENT_SCREEN = 1;
} else if (((X - SCREEN2_X) < SCREENSIZE_X) && ((Y - SCREEN2_Y) < SCREENSIZE_Y)) {
CURRENT_SCREEN = 2;
} else if (((X - SCREEN3_X) < SCREENSIZE_X) && ((Y - SCREEN3_Y) < SCREENSIZE_Y)) {
CURRENT_SCREEN = 3;
} else if (((X - SCREEN4_X) < SCREENSIZE_X) && ((Y - SCREEN4_Y) < SCREENSIZE_Y)) {
CURRENT_SCREEN = 4;
} else if (((X - SCREEN5_X) < SCREENSIZE_X) && ((Y - SCREEN5_Y) < SCREENSIZE_Y)) {
CURRENT_SCREEN = 5;
} else if (((X - SCREEN6_X) < SCREENSIZE_X) && ((Y - SCREEN6_Y) < SCREENSIZE_Y)) {
CURRENT_SCREEN = 6;
} else if (((X - SCREEN7_X) < SCREENSIZE_X) && ((Y - SCREEN7_Y) < SCREENSIZE_Y)) {
CURRENT_SCREEN = 7;
} else if (((X - SCREEN8_X) < SCREENSIZE_X) && ((Y - SCREEN8_Y) < SCREENSIZE_Y)) {
CURRENT_SCREEN = 8;
} else if (((X - SCREEN9_X) < SCREENSIZE_X) && ((Y - SCREEN9_Y) < SCREENSIZE_Y)) {
CURRENT_SCREEN = 9;
}
floor.gotoAndStop(CURRENT_SCREEN);
}
function die() {
spaceship.gotoAndPlay(8);
STATE = STATE | SAVOR_TIME;
}
function render() {
change_room();
spaceship._x = xgtl(X);
spaceship._y = ygtl(Y);
var _local2 = 0;
while (_local2++ , _local2 <= ENEMYCNT) {
if (ENEMIES_X[_local2] < 0) {
ENEMIES_X[_local2] = ENEMIES_X[_local2] + MAPSIZE_X;
}
if (ENEMIES_Y[_local2] < 0) {
ENEMIES_Y[_local2] = ENEMIES_Y[_local2] + MAPSIZE_Y;
}
if (ENEMIES_X[_local2] > MAPSIZE_X) {
ENEMIES_X[_local2] = ENEMIES_X[_local2] - MAPSIZE_X;
}
if (ENEMIES_X[_local2] > MAPSIZE_Y) {
ENEMIES_Y[_local2] = ENEMIES_Y[_local2] - MAPSIZE_Y;
}
_root["ENEMY_" + _local2]._x = xgtl(ENEMIES_X[_local2]);
_root["ENEMY_" + _local2]._y = ygtl(ENEMIES_Y[_local2]);
}
}
var X = 100;
var Y = 100;
var DEFAULT_SAVORTIME = 120;
var DIFFICULTY_TIMER = 1600;
var STARTING_ENEMIES = 4;
var BASE_POINTS = 10;
var POINTS_BONUS = 1.2;
var RECHARGE_TIME = 40;
var AGILITY = 4.5;
var ENGINE_POWER = 0.32;
var BEAM_TIME = 30;
var DEFAULT_EN_R_TIME = 100;
var AGILITY_PENALTY = 0.3;
var ENEMY_ENGINE_POWER = 5.5;
var ENEMY_AGILITY = 0.9;
var SPAWNING = 8;
var RECHARGING = 1;
var FIRING = 2;
var SAVOR_TIME = 4;
var THRUSTING = 16;
var STATE = 8;
var CURRENT_SCREEN = 1;
var SCORE = 0;
var SCORE_INCREMENT = BASE_POINTS;
var LEVEL_COUNTDOWN = DIFFICULTY_TIMER;
var SAVOR_COUNTER = DEFAULT_SAVORTIME;
var ENEMYCNT = STARTING_ENEMIES;
var ENEMIES_X = new Array();
var ENEMIES_Y = new Array();
var ENEMIES = new Array();
var THRUST_X = 0;
var THRUST_Y = 0;
var BEAM_TIMER = BEAM_TIME;
var RECHARGE_TIMER = RECHARGE_TIME;
var ENEMY_RESPAWN_TIME = DEFAULT_EN_R_TIME;
var RESPAWN_TIMER = ENEMY_RESPAWN_TIME;
var LEVEL_TIMER = RESPAWN_TIMER;
var SCREENSIZE_X = 550;
var SCREENSIZE_Y = 400;
var MAPSIZE_X = 1650;
var MAPSIZE_Y = 1200;
var SCREEN1_X = (SCREENSIZE_X * 0);
var SCREEN1_Y = (SCREENSIZE_Y * 0);
var SCREEN2_X = (SCREENSIZE_X * 1);
var SCREEN2_Y = (SCREENSIZE_Y * 0);
var SCREEN3_X = (SCREENSIZE_X * 2);
var SCREEN3_Y = (SCREENSIZE_Y * 0);
var SCREEN4_X = (SCREENSIZE_X * 0);
var SCREEN4_Y = (SCREENSIZE_Y * 1);
var SCREEN5_X = (SCREENSIZE_X * 1);
var SCREEN5_Y = (SCREENSIZE_Y * 1);
var SCREEN6_X = (SCREENSIZE_X * 2);
var SCREEN6_Y = (SCREENSIZE_Y * 1);
var SCREEN7_X = (SCREENSIZE_X * 0);
var SCREEN7_Y = (SCREENSIZE_Y * 2);
var SCREEN8_X = (SCREENSIZE_X * 1);
var SCREEN8_Y = (SCREENSIZE_Y * 2);
var SCREEN9_X = (SCREENSIZE_X * 2);
var SCREEN9_Y = (SCREENSIZE_Y * 2);
stop();
onEnterFrame = function () {
STATE = STATE & (~THRUSTING);
if ((STATE & SPAWNING) != 0) {
spawn();
}
var _local2 = 0;
while (_local2++ , _local2 <= ENEMYCNT) {
if (ENEMIES[_local2]) {
enemy_do_thrust(_local2);
}
}
X = X + THRUST_X;
Y = Y + THRUST_Y;
if ((STATE & SAVOR_TIME) != 0) {
if ((SAVOR_COUNTER--) <= 0) {
spawn();
}
} else {
if ((STATE & RECHARGING) == 0) {
if (0 == (STATE & FIRING)) {
if (Key.isDown(32)) {
STATE = STATE | FIRING;
}
if (Key.isDown(38)) {
do_thrust();
spaceship.gotoAndStop(2);
} else {
spaceship.gotoAndStop(1);
}
_local2 = 0;
while (_local2++ , _local2 <= ENEMYCNT) {
if (ENEMIES[_local2]) {
if (spaceship.hitTest(_root["ENEMY_" + _local2])) {
die();
}
}
}
} else if ((BEAM_TIMER--) == 0) {
STATE = STATE & (~FIRING);
BEAM_TIMER = BEAM_TIME;
STATE = STATE | RECHARGING;
spaceship.gotoAndPlay(4);
} else {
beam();
}
if (Key.isDown(37)) {
rotate_ccw();
} else if (Key.isDown(39)) {
rotate_cw();
}
} else if ((RECHARGE_TIMER--) == 0) {
RECHARGE_TIMER = RECHARGE_TIME;
STATE = STATE & (~RECHARGING);
}
if ((--LEVEL_TIMER) <= 0) {
spawn_enemy();
}
}
render();
};
Symbol 21 MovieClip [hero] Frame 1
stop();
Symbol 21 MovieClip [hero] Frame 2
stop();
Symbol 21 MovieClip [hero] Frame 3
stop();
Symbol 21 MovieClip [hero] Frame 7
gotoAndPlay (4);
Symbol 21 MovieClip [hero] Frame 21
stop();
Symbol 26 MovieClip [badguy] Frame 1
stop();
Symbol 26 MovieClip [badguy] Frame 3
stop();
Symbol 36 MovieClip [Space] Frame 1
stop();
Symbol 36 MovieClip [Space] Frame 2
stop();
Symbol 36 MovieClip [Space] Frame 3
stop();
Symbol 36 MovieClip [Space] Frame 4
stop();
Symbol 36 MovieClip [Space] Frame 5
stop();
Symbol 36 MovieClip [Space] Frame 6
stop();
Symbol 36 MovieClip [Space] Frame 7
stop();
Symbol 36 MovieClip [Space] Frame 8
stop();
Symbol 36 MovieClip [Space] Frame 9
stop();