Frame 1
function shipparent() {
this.rotation = 0;
this.xpos = 100;
this.ypos = 300;
this.xlration = 0;
this.rockets = 1;
this.xspeed = 0;
this.yspeed = 0;
this.hitstatus = 0;
}
function rocketparent() {
this.rotation = 0;
this.xpos = -50;
this.ypos = -50;
this.xlration = 0;
this.distancetravelled = 0;
this.xspeedship = 0;
this.yspeedship = 0;
this.xspeed = 0;
this.yspeed = 0;
}
function rightturn() {
ship.rotation = ship.rotation + 5;
}
function leftturn() {
ship.rotation = ship.rotation - 5;
}
function forward() {
tellTarget (car) {
gotoAndPlay (5);
};
if (8 >= ship.xlration) {
ship.xlration = ship.xlration + 0.3;
}
}
function slowdown() {
if (0 < ship.xlration) {
ship.xlration = ship.xlration - 0.1;
}
}
function fire() {
if (counter >= 30) {
counter = 0;
if (ship.rockets < 50) {
rocketarray.unshift(ship.rockets);
rocket[ship.rockets].xspeedship = ship.xspeed;
rocket[ship.rockets].yspeedship = ship.yspeed;
setProperty(rocket add ship.rockets, _rotation , ship.rotation);
setProperty(rocket add ship.rockets, _x , ship.xpos);
setProperty(rocket add ship.rockets, _y , ship.ypos);
rocket[ship.rockets].rotation = ship.rotation;
ship.rockets = ship.rockets + 1;
rocketsleft = rocketsleft - 1;
if (rocketsleft == 0) {
gotoAndStop (10);
}
}
}
}
function moverockets() {
x = 0;
while (rocketarray.length >= x) {
i = rocketarray[x];
if (eval (rocket add i).hitTest(_root.enemy)) {
ship.hitstatus = ship.hitstatus + 1;
shipscore = ship.hitstatus;
blah = rocketarray.pop();
tellTarget (rocket add i) {
play();
};
}
rocket[i].xpos = getProperty(rocket add i, _x);
rocket[i].ypos = getProperty(rocket add i, _y);
rocket[i].xlration = rocket[i].xlration + 0.5;
rocket[i].xspeed = Math.sin((Math.PI/180) * rocket[i].rotation) + rocket[i].xspeedship;
rocket[i].yspeed = (-Math.cos((Math.PI/180) * rocket[i].rotation)) + rocket[i].yspeedship;
rocket[i].xpos = rocket[i].xpos + (rocket[i].xspeed * rocket[i].xlration);
rocket[i].ypos = rocket[i].ypos + (rocket[i].yspeed * rocket[i].xlration);
setProperty(rocket add i, _x , rocket[i].xpos);
setProperty(rocket add i, _y , rocket[i].ypos);
rocket[i].distancetravelled = rocket[i].distancetravelled + 1;
if (140 < rocket[i].distancetravelled) {
blah = rocketarray.pop();
tellTarget (rocket add i) {
play();
};
}
x++;
}
}
function moveship() {
dir = car._rotation + 180;
ship.xspeed = newsin[dir] * (-ship.xlration);
ship.yspeed = newcos[dir] * ship.xlration;
ship.xpos = ship.xpos + ship.xspeed;
ship.ypos = ship.ypos + ship.yspeed;
if (ship.xpos >= 650) {
ship.xpos = -40;
} else if (-40 >= ship.xpos) {
ship.xpos = 650;
}
if (ship.ypos >= 400) {
ship.ypos = -40;
} else if (-40 >= ship.ypos) {
ship.ypos = 400;
}
setProperty(car, _rotation , ship.rotation);
setProperty(car, _x , ship.xpos);
setProperty(car, _y , ship.ypos);
}
ship = new shipparent();
i = 1;
while (50 >= i) {
rocket[i] = new rocketparent();
duplicateMovieClip (rocket, "rocket" add i, i);
i++;
}
shipscore = 0;
rocketsleft = 49;
rocketarray = [];
counter = 0;
statecounter = 0;
statelength = 0;
newsin = [];
newcos = [];
i = 1;
while (360 >= i) {
newsin[i] = Math.sin((Math.PI/180) * i);
newcos[i] = Math.cos((Math.PI/180) * i);
i++;
}
Instance of Symbol 8 MovieClip "rocket" in Frame 1
/* no clip actions */
Frame 2
function enemyparent() {
this.rotation = 0;
this.xpos = 400;
this.ypos = 300;
this.speed = 0;
this.xlration = 0;
this.rockets = 1;
this.xspeed = 0;
this.yspeed = 0;
}
function enemyrocketparent() {
this.rotation = 0;
this.xpos = 200;
this.ypos = 200;
this.speed = 0;
this.xlration = 0;
this.hitstatus = 0;
this.distancetravelled = 0;
this.xspeed = 0;
this.yspeed = 0;
this.xspeedship = 0;
this.yspeedship = 0;
}
function enemyrightturn() {
enemyship.rotation = enemyship.rotation + 5;
}
function enemyleftturn() {
enemyship.rotation = enemyship.rotation - 5;
}
function enemyforward() {
tellTarget (enemy) {
gotoAndPlay (5);
};
if (5 >= enemyship.xlration) {
enemyship.xlration = enemyship.xlration + 0.1;
}
}
function enemyslowdown() {
if (0 < enemyship.xlration) {
enemyship.xlration = enemyship.xlration - 0.1;
}
}
function enemyfire() {
if (enemycounter >= 30) {
enemycounter = 0;
if (enemyship.rockets < 50) {
enemyrocketarray.unshift(enemyship.rockets);
enemyrocket[enemyship.rockets].xspeedship = enemyship.xspeed;
enemyrocket[enemyship.rockets].yspeedship = enemyship.yspeed;
setProperty(enemyrocket add enemyship.rockets, _rotation , enemyship.rotation);
setProperty(enemyrocket add enemyship.rockets, _x , enemyship.xpos);
setProperty(enemyrocket add enemyship.rockets, _y , enemyship.ypos);
enemyrocket[enemyship.rockets].rotation = enemyship.rotation;
enemyship.rockets = enemyship.rockets + 1;
}
}
}
function enemymoverockets() {
x = 0;
while (enemyrocketarray.length >= x) {
i = enemyrocketarray[x];
if (eval (enemyrocket add i).hitTest(_root.car)) {
enemy.hitstatus = enemy.hitstatus + 1;
enemyscore = enemy.hitstatus;
enemyblah = enemyrocketarray.pop();
tellTarget (enemyrocket add i) {
play();
};
}
enemyrocket[i].xpos = getProperty(enemyrocket add i, _x);
enemyrocket[i].ypos = getProperty(enemyrocket add i, _y);
enemyrocket[i].xlration = enemyrocket[i].xlration + 0.5;
enemyrocket[i].xspeed = Math.sin((Math.PI/180) * enemyrocket[i].rotation) + enemyrocket[i].xspeedship;
enemyrocket[i].yspeed = (-Math.cos((Math.PI/180) * enemyrocket[i].rotation)) + enemyrocket[i].yspeedship;
enemyrocket[i].xpos = enemyrocket[i].xpos + (enemyrocket[i].xspeed * enemyrocket[i].xlration);
enemyrocket[i].ypos = enemyrocket[i].ypos + (enemyrocket[i].yspeed * enemyrocket[i].xlration);
setProperty(enemyrocket add i, _x , enemyrocket[i].xpos);
setProperty(enemyrocket add i, _y , enemyrocket[i].ypos);
enemyrocket[i].distancetravelled = enemyrocket[i].distancetravelled + 1;
if (140 < enemyrocket[i].distancetravelled) {
enemyblah = enemyrocketarray.pop();
}
x++;
}
}
function enemymoveship() {
enemydir = enemy._rotation + 180;
enemyship.xspeed = newsin[enemydir] * (-enemyship.xlration);
enemyship.yspeed = newcos[enemydir] * enemyship.xlration;
enemyship.xpos = enemyship.xpos + enemyship.xspeed;
enemyship.ypos = enemyship.ypos + enemyship.yspeed;
if (enemyship.xpos >= 650) {
enemyship.xpos = -40;
} else if (-40 >= enemyship.xpos) {
enemyship.xpos = 650;
}
if (enemyship.ypos >= 400) {
enemyship.ypos = -40;
} else if (-40 >= enemyship.ypos) {
enemyship.ypos = 400;
}
setProperty(enemy, _rotation , enemyship.rotation);
setProperty(enemy, _x , enemyship.xpos);
setProperty(enemy, _y , enemyship.ypos);
}
enemyship = new enemyparent();
i = 1;
while (50 >= i) {
enemyrocket[i] = new enemyrocketparent();
duplicateMovieClip (enemyrocket, "enemyrocket" add i, i + 100);
i++;
}
enemyscore = 0;
enemyrocketarray = [];
enemycounter = 0;
Frame 3
function choosestate() {
statecounter = statecounter + 1;
if (statecounter >= statelength) {
changestate();
statecounter = 0;
statelength = random(100);
}
}
function changestate() {
chance = random(10);
if (chance >= 6) {
state = "attack";
} else if (chance >= 2) {
state = "defend";
} else if (chance >= 0) {
state = "idle";
}
}
function fight() {
if (state == "attack") {
attack();
} else if (state == "defend") {
defend();
} else if (state == "idle") {
idle();
}
}
function idle() {
enemyslowdown();
}
function attack() {
enemyleftturn();
enemyfire();
}
function defend() {
enemyforward();
}
Frame 4
if (Key.isDown(Key.RIGHT) == true) {
rightturn();
}
if (Key.isDown(Key.LEFT) == true) {
leftturn();
}
if (Key.isDown(Key.UP) == true) {
forward();
} else {
slowdown();
}
if (Key.isDown(Key.SPACE) == true) {
fire();
}
moverockets();
counter = counter + 1;
moveship();
enemymoverockets();
enemycounter = enemycounter + 1;
enemymoveship();
choosestate();
fight();
Frame 5
gotoAndPlay (4);
Symbol 5 MovieClip Frame 1
stop();
Symbol 8 MovieClip Frame 1
stop();
Symbol 8 MovieClip Frame 11
stop();
Symbol 11 MovieClip Frame 1
stop();
Symbol 12 MovieClip Frame 1
stop();
Symbol 12 MovieClip Frame 11
stop();
Symbol 32 Button
on (release) {
gotoAndPlay (1);
}