Frame 1
function makeBullet(x, y, velx, vely, type) {
if (type == "missile") {
var _local1 = new logic.Missile(x, y, velx, vely, "thing2");
} else if (type == "grenade") {
var _local1 = new logic.Grenade(x, y, velx, vely, "grenade");
}
}
_root.game = new logic.Game();
_root.entities = new Array();
Instance of Symbol 21 MovieClip in Frame 1
onClipEvent (load) {
woo = new logic.Turret(this);
}
Instance of Symbol 21 MovieClip in Frame 1
onClipEvent (load) {
woo = new logic.Turret(this);
}
Frame 2
stop();
Instance of Symbol 25 MovieClip "timePlaying" in Frame 2
onClipEvent (load) {
woo = new logic.TextWindow(this);
woo.SetText("Survived: ");
}
onClipEvent (enterFrame) {
woo.SetText(("Survived: " + _root.game.GetTimePlaying()) + " Seconds.");
}
Instance of Symbol 38 MovieClip "player" in Frame 2
onClipEvent (load) {
this.velx = 0;
this.vely = 0;
}
onClipEvent (enterFrame) {
this.velx = (this._x - _root._xmouse) * -0.5;
this.vely = (this._y - _root._ymouse) * -0.5;
this._x = this._x + this.velx;
this._y = this._y + this.vely;
play();
}
Instance of Symbol 21 MovieClip in Frame 2
onClipEvent (load) {
woo = new logic.GrenadeTurret(this);
}
Instance of Symbol 21 MovieClip in Frame 2
onClipEvent (load) {
woo = new logic.GrenadeTurret(this);
}
Instance of Symbol 21 MovieClip in Frame 2
onClipEvent (load) {
woo = new logic.Turret(this);
}
Instance of Symbol 21 MovieClip in Frame 2
onClipEvent (load) {
woo = new logic.Turret(this);
}
Instance of Symbol 21 MovieClip in Frame 2
onClipEvent (load) {
woo = new logic.Turret(this);
}
Instance of Symbol 21 MovieClip in Frame 2
onClipEvent (load) {
woo = new logic.Turret(this);
}
Instance of Symbol 46 MovieClip "text" in Frame 2
onClipEvent (load) {
this._visible = false;
}
Symbol 7 MovieClip [explosion] Frame 1
this._rotation = Math.random() * 360;
if (this.hitTest(_root.player._x, _root.player._y)) {
_root.game.gameOver();
}
Symbol 7 MovieClip [explosion] Frame 17
this.removeMovieClip();
Symbol 12 MovieClip [grenade] Frame 1
stop();
Symbol 14 MovieClip [puff] Frame 8
this.removeMovieClip();
Symbol 21 MovieClip Frame 1
stop();
Symbol 51 MovieClip [__Packages.logic.Entity] Frame 0
class logic.Entity
{
var x, clip, y;
function Entity (clip) {
PrepareClip(clip);
}
function UpdateMC() {
clip._x = x;
clip._y = y;
}
function ClearClass() {
clip.removeMovieClip();
Think = null;
}
function OnGameActivate() {
}
function PrepareClip(clip) {
this.clip = clip;
this.clip.code = this;
this.clip.onEnterFrame = function () {
if (_root.game.gameInSession()) {
this.code.Think();
}
};
x = this.clip._x;
y = this.clip._y;
_root.entities.push(this);
}
function Remove() {
ClearClass();
}
function Think() {
}
}
Symbol 52 MovieClip [__Packages.logic.TProjectile] Frame 0
class logic.TProjectile extends logic.Entity
{
var x, y, velx, vely, bounces, nextTrail, PrepareClip, Remove, clip, UpdateMC;
function TProjectile (x, y, velx, vely, symbol) {
super();
this.x = x;
this.y = y;
this.velx = velx;
this.vely = vely;
bounces = 0;
nextTrail = 0;
var _local3 = lib.Control.blankMC("projectile");
_local3.attachMovie(symbol, "symbol", 1);
_local3._x = x;
_local3._y = y;
_local3.code = this;
PrepareClip(_local3);
}
function Trail() {
var _local2 = lib.Control.blankMC("puff");
_local2.attachMovie("puff", "puff", 1);
_local2._x = x;
_local2._y = y;
var _local3 = Math.atan2(vely, velx);
_local2._rotation = _local3 * 57.3;
_local2._rotation = _local2._rotation + ((Math.random() * 30) - 15);
}
function Explode() {
velx = 0;
vely = 0;
var _local2 = lib.Control.blankMC("explosion");
_local2.attachMovie("explosion", "explosion", 1);
_local2._x = x;
_local2._y = y;
Remove();
}
function Think() {
x = x + velx;
y = y + vely;
if (nextTrail < getTimer()) {
Trail();
nextTrail = getTimer() + 70;
}
clip._rotation = Math.atan2(vely, velx) * 57.3;
if (bounces >= 1) {
if ((x > 550) or (x < 0)) {
velx = velx * -1;
bounces--;
return(undefined);
}
if ((y > 400) or (y < 0)) {
vely = vely * -1;
bounces--;
return(undefined);
}
}
UpdateMC();
if ((x > 550) or (x < 0)) {
Explode();
}
if ((y > 400) or (y < 0)) {
Explode();
}
if (_root.player.hitTest(clip._x, clip._y, true)) {
Explode();
}
}
}
Symbol 53 MovieClip [__Packages.lib.Control] Frame 0
class lib.Control
{
function Control () {
}
static function blankMC(name) {
return(_root.createEmptyMovieClip((name + "_") + _root.getNextHighestDepth(), _root.getNextHighestDepth()));
}
static function timer(delay, func, target) {
var _local2 = blankMC();
_local2.attachMovie("thing", "timer", 1);
_local2._x = 20;
_local2._y = 20;
_local2.func = func;
_local2.target = target;
_local2.mytime = getTimer() + delay;
_local2.onEnterFrame = function () {
if (this.mytime < getTimer()) {
this.func.call(this.target);
this.removeMovieClip();
}
};
}
static function getAllEntities() {
return(_root.entities);
}
static function getClipsByName(prefix, target) {
var _local3 = length(prefix);
var _local2 = new Array();
for (var _local5 in target) {
if (typeof(target[_local5]) == "movieclip") {
if (target[_local5]._name.substr(0, _local3) == prefix) {
_local2.push(target[_local5]);
}
}
}
return(_local2);
}
}
Symbol 54 MovieClip [__Packages.logic.Missile] Frame 0
class logic.Missile extends logic.TProjectile
{
function Missile (x, y, velx, vely, symbol) {
super(x, y, velx, vely, symbol);
}
}
Symbol 55 MovieClip [__Packages.logic.Grenade] Frame 0
class logic.Grenade extends logic.TProjectile
{
var bounces, x, velx, y, vely, clip, UpdateMC, Explode;
function Grenade (x, y, velx, vely, symbol) {
super(x, y, velx, vely, symbol);
bounces = 10;
}
function Think() {
x = x + velx;
y = y + vely;
vely = vely + 0.28;
clip._rotation = Math.atan2(vely, velx) * 57.3;
if (bounces >= 1) {
if ((x > 550) or (x < 0)) {
velx = velx * -1;
bounces--;
clip.gotoAndPlay(1);
return(undefined);
}
if (y > 400) {
vely = vely * -0.6;
y = 400;
bounces--;
clip.gotoAndPlay(1);
return(undefined);
}
}
UpdateMC();
if ((x > 550) or (x < 0)) {
Explode();
}
if (y > 400) {
Explode();
}
if (_root.player.hitTest(clip._x, clip._y, true)) {
Explode();
}
}
}
Symbol 56 MovieClip [__Packages.logic.Game] Frame 0
class logic.Game
{
function Game () {
Mouse.hide();
PrepareClip();
}
function PrepareClip() {
var _local2 = lib.Control.blankMC();
_local2.code = this;
_local2.onEnterFrame = function () {
this.code.Think();
};
}
function Think() {
if (gameInSession()) {
timePlaying++;
}
}
function Activate() {
inSession = true;
_root.beginButton._visible = false;
var _local3 = lib.Control.getAllEntities();
for (var _local4 in _local3) {
_local3[_local4].OnGameActivate();
}
}
function Restart() {
var _local3 = lib.Control.getClipsByName("projectile", _root);
for (var _local4 in _local3) {
_local3[_local4].code.Remove();
}
_root.player._visible = true;
_root.play();
_root.beginButton._visible = true;
timePlaying = 0;
Mouse.hide();
}
function GetTimePlaying() {
return((Math.floor(timePlaying / 60) + ".") + (Math.floor(timePlaying) % 60));
}
function gameOver() {
_root.text._visible = true;
_root.player._visible = false;
Mouse.show();
inSession = false;
}
function gameInSession() {
return(inSession);
}
var inSession = false;
var timePlaying = 0;
}
Symbol 57 MovieClip [__Packages.logic.ProjectileLauncher] Frame 0
class logic.ProjectileLauncher extends logic.Entity
{
var fireDelay, projectiles, fireTimer, clip;
function ProjectileLauncher (clip) {
super(clip);
fireDelay = 4000;
projectiles = new Array();
}
function OnGameActivate() {
fireTimer = getTimer() + (fireDelay - ((Math.random() * fireDelay) / 2));
}
function FireThink(angle, speed, startdist, type) {
if (fireTimer < getTimer()) {
Fire(clip._x + (Math.cos(angle) * startdist), clip._y + (Math.sin(angle) * startdist), Math.cos(angle) * speed, Math.sin(angle) * speed, type);
if (fireDelay > 40) {
fireDelay = fireDelay - 50;
}
fireTimer = getTimer() + (fireDelay - ((Math.random() * fireDelay) / 2));
}
}
function Think() {
}
function Fire(x, y, xvel, yvel, type) {
_root.makeBullet(x, y, xvel, yvel, type);
clip.play();
}
}
Symbol 58 MovieClip [__Packages.logic.Turret] Frame 0
class logic.Turret extends logic.ProjectileLauncher
{
var vx, clip, vy, hitx, hity, moveAxis, spawntime, x, y, FireThink, UpdateMC;
function Turret (clip) {
super(clip);
vx = Math.cos(this.clip._rotation / 57.3) * 4;
vy = Math.sin((this.clip._rotation + 90) / 57.3) * 4;
hitx = 0;
hity = 0;
moveAxis = 2;
spawntime = getTimer();
}
function Movement() {
if (((getTimer() - spawntime) > 6000) and (moveAxis == 2)) {
moveAxis = 0;
}
if (moveAxis == 0) {
x = x + vx;
if ((x < 40) or (x > 510)) {
vx = vx * -1;
x = x + vx;
hitx++;
}
if (hitx > 1) {
moveAxis = 1;
hitx = 0;
}
}
if (moveAxis == 1) {
y = y + vy;
if ((y < 40) or (y > 360)) {
vy = vy * -1;
y = y + vy;
hity++;
}
if (hity > 1) {
moveAxis = 0;
hity = 0;
}
}
}
function DoFireThink(angle, speed) {
FireThink(angle, speed, clip._width / 1.2, "missile");
}
function Think() {
var _local8 = 5;
var _local7 = _root.player._x;
var _local6 = _root.player._y;
var _local4 = _local7 - x;
var _local3 = _local6 - y;
var _local10 = Math.sqrt((_local4 * _local4) + (_local3 * _local3));
if (_local10 < 400) {
var _local5 = Math.atan2(_local3, _local4);
var _local9 = _local5 * 57.3;
clip._rotation = _local9;
DoFireThink(_local5, _local8);
}
Movement();
UpdateMC();
}
}
Symbol 59 MovieClip [__Packages.logic.TextWindow] Frame 0
class logic.TextWindow extends logic.Entity
{
var clip;
function TextWindow (clip, text) {
super(clip);
}
function SetText(text) {
thetext = text;
clip.txt.text = thetext;
}
var thetext = "";
}
Symbol 60 MovieClip [__Packages.logic.GrenadeTurret] Frame 0
class logic.GrenadeTurret extends logic.Turret
{
var FireThink, clip, x, vx, y, UpdateMC;
function GrenadeTurret (clip) {
super(clip);
}
function DoFireThink(angle, speed) {
FireThink(angle, speed, clip._width / 1.2, "grenade");
}
function Movement() {
x = x + vx;
if ((x < 40) or (x > 510)) {
vx = vx * -1;
x = x + vx;
}
}
function Think() {
var _local13 = _root.player._x;
var _local12 = _root.player._y;
var _local4 = _local13 - x;
var _local3 = _local12 - y;
var _local9 = Math.sqrt((_local3 * _local3) + (_local4 * _local4));
var _local10 = Math.atan2(_local3, _local4);
var _local14 = ((Math.cos(_local10) * _local9) / 2) + x;
var _local7 = ((Math.sin(_local10) * _local9) / 2) + y;
var _local15 = 0.28;
var _local5 = 5;
var _local6 = 40;
_local7 = _local7 - (_local5 * _local6);
_local4 = _local14 - x;
_local3 = _local7 - y;
var _local11 = Math.sqrt((_local3 * _local3) + (_local4 * _local4));
_local5 = ((_local11 * _local15) / _local6) * _local5;
var _local8 = Math.atan2(_local3, _local4);
var _local16 = _local8 * 57.3;
clip._rotation = _local16;
DoFireThink(_local8, _local5);
UpdateMC();
}
}
Symbol 38 MovieClip Frame 1
stop();
Symbol 38 MovieClip Frame 29
gotoAndPlay (2);
Symbol 45 Button
on (release) {
_root.game.Restart();
}
Symbol 50 Button
on (press) {
_root.game.Activate();
}