Frame 1
stop();
inGame = false;
loaded = false;
onEnterFrame = function () {
if (_currentframe == 1) {
procent = ("Loading: " + Math.round((getBytesLoaded() / getBytesTotal()) * 100)) + "%";
if ((procent == "Loading: 100%") and (!loaded)) {
loaded = true;
load_sign_mc.play();
}
if (loaded) {
procent = "Loaded";
}
}
};
Frame 2
stop();
stopAllSounds();
var B = new Sound();
B.attachSound("beat little heavy loop");
B.start(0.07, 9999);
_root.createEmptyMovieClip("grid", 19);
_root.createEmptyMovieClip("temp", 20);
_root.createEmptyMovieClip("turrets_mc", 18);
_root.createEmptyMovieClip("squares_mc", 17);
_root.createEmptyMovieClip("enemies", 14);
_root.createEmptyMovieClip("lasers", 15);
_root.createEmptyMovieClip("missiles", 16);
var errorSound = new Sound();
errorSound.attachSound("error");
var buildSound = new Sound();
buildSound.attachSound("build");
var maximise = new Sound();
maximise.attachSound("maximise");
var maximis = new Sound();
maximis.attachSound("menu_back_12");
building = false;
selling = false;
spotX = 0;
spotY = 0;
turret = 0;
tcnt = 1;
ecnt = 1;
money = 100;
wave = 0;
mcnt = 1;
lcnt = 1;
mmcnt = 1;
tid = 20;
time = 45;
var waves = new Array(["little troop"], ["little troop", "little troop", "little troop"], ["little troop", "little troop", "little troop", "little troop", "little troop", "little troop", "little troop"], ["little troop", "little troop", "little troop", "little troop", "little troop", "little troop", "little troop"], ["little troop", "little troop", "little troop", "little troop", "little troop", "little troop", "little troop"], ["little troop", "little troop", "little troop", "little troop", "little troop", "little troop", "little troop", "little troop", "little troop", "little troop", "little troop"], ["little troop", "little troop", "little troop", "little troop", "little troop", "little troop", "little troop", "little troop", "little troop", "little troop", "little troop"], ["little troop", "little troop", "little troop", "little troop", "little troop", "little troop", "little troop", "little troop", "little troop", "little troop", "little troop"], ["little troop", "little troop", "little troop", "little troop", "little troop", "little troop", "little troop", "little troop", "little troop", "little troop", "little troop"], ["little troop", "little troop", "little troop", "little troop", "little troop", "little troop", "little troop", "little troop", "little troop", "little troop", "little troop"], ["little troop", "little troop", "little troop", "little troop", "little troop", "little troop", "little troop", "little troop", "little troop", "little troop", "little troop"], ["little troop", "little troop", "little troop", "little troop", "little troop", "little troop", "little troop", "little troop", "little troop", "little troop", "little troop"], ["little troop", "little troop", "little troop", "little troop", "little troop", "little troop", "little troop", "little troop", "little troop", "little troop", "little troop"]);
var places = new Array([], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], []);
i = 0;
while (i <= 19) {
j = 0;
while (j <= 19) {
places[i][j] = "empty";
j++;
}
i++;
}
i = 0;
while (i < 15) {
places[2][i] = "taken";
places[3][i] = "taken";
places[16][i] = "taken";
places[17][i] = "taken";
i++;
}
i = 2;
while (i < 18) {
places[i][15] = "taken";
places[i][16] = "taken";
i++;
}
var turrets = new Array(["laser turret", 25], ["missile turret", 30]);
grid.lineStyle(1, 0, 25);
i = 0;
while (i <= 400) {
grid.moveTo(i, 0);
grid.lineTo(i, 400);
grid.moveTo(0, i);
grid.lineTo(400, i);
i = i + 20;
}
launchWave = function () {
u = 0;
while (u <= (waves[wave].length + 1)) {
_root.enemies.attachMovie(waves[wave][u], ecnt, ecnt);
_root.enemies[ecnt]._x = 60;
_root.enemies[ecnt]._y = -30 - (40 * u);
_root.enemies[ecnt]._rotation = 150 + random(60);
_root.enemies[ecnt].life = (wave * 30) + 100;
_root.enemies[ecnt].onEnterFrame = function () {
if ((this.life <= 0) and (this._currentframe == 1)) {
this.play();
_root.money = _root.money + 10;
}
if (this._currentframe == 9) {
this.removeMovieClip();
}
this._x = this._x + Math.sin(this._rotation * (Math.PI/180));
this._y = this._y + (Math.cos(this._rotation * (Math.PI/180)) * -1);
if (ib.hitTest(this._x + (Math.sin((this._rotation - 50) * (Math.PI/180)) * 30), this._y + (Math.cos((this._rotation - 50) * (Math.PI/180)) * -30), true)) {
this._rotation = this._rotation + 5;
}
if (ob.hitTest(this._x + (Math.sin((this._rotation + 50) * (Math.PI/180)) * 30), this._y + (Math.cos((this._rotation + 50) * (Math.PI/180)) * -30), true)) {
this._rotation = this._rotation - 5;
}
};
ecnt++;
u++;
}
if (wave < 10) {
wave++;
} else {
gotoAndStop (3);
_root.createEmptyMovieClip("grid", 19);
_root.createEmptyMovieClip("temp", 20);
_root.createEmptyMovieClip("turrets_mc", 18);
_root.createEmptyMovieClip("squares_mc", 17);
_root.createEmptyMovieClip("enemies", 14);
_root.createEmptyMovieClip("lasers", 15);
_root.createEmptyMovieClip("missiles", 16);
}
};
launchWave();
onEnterFrame = function () {
if (inGame) {
tid = tid - 0.0303030303030303;
time = Math.ceil(tid) + " sec";
if (tid <= 0) {
_root.launchWave();
tid = 20;
}
if (building) {
grid._visible = true;
} else {
grid._visible = false;
}
}
};
onMouseDown = function () {
if (inGame) {
if (building and (_xmouse < 400)) {
spotX = Math.floor(_xmouse / 20);
spotY = Math.floor(_ymouse / 20);
if (_root.places[spotX][spotY] == "empty") {
if (_root.money >= _root.turrets[turret][1]) {
_root.money = _root.money - _root.turrets[turret][1];
buildSound.start();
_root.squares_mc.attachMovie("square", _root.tcnt, _root.tcnt);
_root.squares_mc[tcnt]._x = (spotX * 20) + 10;
_root.squares_mc[tcnt]._y = (spotY * 20) + 10;
_root.turrets_mc.attachMovie(_root.turrets[turret][0], _root.tcnt, _root.tcnt);
_root.turrets_mc[tcnt]._x = (spotX * 20) + 10;
_root.turrets_mc[tcnt]._y = (spotY * 20) + 10;
_root.turrets_mc[tcnt].gotTarget = false;
_root.turrets_mc[tcnt].Target = undefined;
_root.turrets_mc[tcnt].fireTime = 0;
_root.turrets_mc[tcnt].tcnt = _root.tcnt;
_root.turrets_mc[tcnt].turret = _root.turrets[turret][0];
_root.turrets_mc[tcnt].onEnterFrame = function () {
if (inGame) {
if (this.turret == "laser turret") {
this.fireTime++;
if (!this.gotTarget) {
e = 1;
while (e <= _root.ecnt) {
if (this.hitTest(_root.enemies[e]._x, _root.enemies[e]._y, true)) {
this.Target = e;
this.gotTarget = true;
break;
}
e++;
}
} else {
this.diffX = _root.enemies[this.Target]._x - this._x;
this.diffY = _root.enemies[this.Target]._y - this._y;
this._rotation = ((Math.atan2(this.diffY, this.diffX) * 180) / Math.PI) + 90;
if ((this.fireTime > 25) and (enemies[this.Target].life > 0)) {
lasers.createEmptyMovieClip(lcnt, lcnt);
lasers[lcnt].lineStyle(2, 12845056, 80);
lasers[lcnt].moveTo(this._x, this._y);
lasers[lcnt].lineTo(enemies[this.Target]._x, enemies[this.Target]._y);
lasers[lcnt].onEnterFrame = function () {
this._alpha = this._alpha - 20;
if (this._alpha <= 0) {
this.removeMovieClip();
}
};
maximise.start(0.05);
enemies[this.Target].life = enemies[this.Target].life - 34;
this.fireTime = 0;
lcnt++;
}
if (!this.hitTest(_root.enemies[this.Target]._x, _root.enemies[this.Target]._y, true)) {
this.gotTarget = false;
this.Target = 0;
}
}
this.onMouseDown = function () {
if ((selling and (Math.abs(_xmouse - this._x) < 10)) and (Math.abs(_ymouse - this._y) < 10)) {
_root.money = _root.money + 10;
_root.places[(this._x - 10) / 20][(this._y - 10) / 20] = "empty";
removeMovieClip(_root.squares_mc[this.tcnt]);
this.removeMovieClip();
}
};
}
if (this.turret == "missile turret") {
this.fireTime++;
if (!this.gotTarget) {
e = 1;
while (e <= _root.ecnt) {
if (this.hitTest(_root.enemies[e]._x, _root.enemies[e]._y, true)) {
this.Target = e;
this.gotTarget = true;
break;
}
e++;
}
} else {
this.diffX = _root.enemies[this.Target]._x - this._x;
this.diffY = _root.enemies[this.Target]._y - this._y;
this._rotation = ((Math.atan2(this.diffY, this.diffX) * 180) / Math.PI) + 90;
if ((this.fireTime > 60) and (enemies[this.Target].life > 0)) {
missiles.attachMovie("missile", mmcnt, mmcnt);
missiles[mmcnt].Target = this.Target;
missiles[mmcnt].alive = true;
missiles[mmcnt]._x = this._x;
missiles[mmcnt]._y = this._y;
missiles[mmcnt]._rotation = this._rotation;
missiles[mmcnt].onEnterFrame = function () {
if (this.alive) {
this.diffX = enemies[this.Target]._x - this._x;
this.diffY = enemies[this.Target]._y - this._y;
this._rotation = (Math.atan2(this.diffY, this.diffX) * 180) / Math.PI;
this._x = this._x + (Math.sin((this._rotation + 90) * (Math.PI/180)) * 2);
this._y = this._y + (Math.cos((this._rotation + 90) * (Math.PI/180)) * -2);
this._rotation = this._rotation + 180;
if (enemies[this.Target]._x == undefined) {
this.play();
}
if (enemies[this.Target].hitTest(this._x, this._y, true)) {
enemies[this.Target].life = enemies[this.Target].life - 60;
this.play();
maximis.start(0.2);
this.alive = false;
}
}
if (this._currentframe == this._totalframes) {
this.removeMovieClip();
}
};
this.fireTime = 0;
mmcnt++;
}
if (!this.hitTest(_root.enemies[this.Target]._x, _root.enemies[this.Target]._y, true)) {
this.gotTarget = false;
this.Target = 0;
}
}
this.onMouseDown = function () {
if ((selling and (Math.abs(_xmouse - this._x) < 10)) and (Math.abs(_ymouse - this._y) < 10)) {
_root.money = _root.money + 10;
_root.places[(this._x - 10) / 20][(this._y - 10) / 20] = "empty";
removeMovieClip(_root.squares_mc[this.tcnt]);
this.removeMovieClip();
}
};
}
}
};
_root.tcnt++;
_root.places[spotX][spotY] = "taken";
} else {
errorSound.start();
}
} else {
errorSound.start();
}
}
}
};
laser_mc.onRelease = function () {
if (inGame) {
turret = 0;
if (this._currentframe == 1) {
missile_mc.gotoAndStop(1);
sell_mc.gotoAndStop(1);
temp["1"].removeMovieClip();
this.gotoAndStop(2);
_root.building = true;
_root.selling = false;
_root.temp.attachMovie("laser turret", "1", 1);
_root.temp["1"]._x = _xmouse;
_root.temp["1"]._y = _ymouse;
_root.temp["1"].onEnterFrame = function () {
if (inGame) {
spotX = Math.floor(_xmouse / 20);
spotY = Math.floor(_ymouse / 20);
this._x = (spotX * 20) + 10;
this._y = (spotY * 20) + 10;
this.gotoAndStop(2);
if (_xmouse < 400) {
this._alpha = 50;
} else {
this._alpha = 0;
}
}
};
} else {
this.gotoAndStop(1);
_root.building = false;
temp["1"].removeMovieClip();
}
}
};
missile_mc.onRelease = function () {
if (inGame) {
turret = 1;
if (this._currentframe == 1) {
laser_mc.gotoAndStop(1);
sell_mc.gotoAndStop(1);
temp["1"].removeMovieClip();
this.gotoAndStop(2);
_root.building = true;
_root.selling = false;
_root.temp.attachMovie("missile turret", "1", 1);
_root.temp["1"]._x = _xmouse;
_root.temp["1"]._y = _ymouse;
_root.temp["1"].onEnterFrame = function () {
if (inGame) {
spotX = Math.floor(_xmouse / 20);
spotY = Math.floor(_ymouse / 20);
this._x = (spotX * 20) + 10;
this._y = (spotY * 20) + 10;
this.gotoAndStop(2);
if (_xmouse < 400) {
this._alpha = 50;
} else {
this._alpha = 0;
}
}
};
} else {
this.gotoAndStop(1);
_root.building = false;
temp["1"].removeMovieClip();
}
}
};
sell_mc.onRelease = function () {
if (inGame) {
if (this._currentframe == 1) {
laser_mc.gotoAndStop(1);
missile_mc.gotoAndStop(1);
temp["1"].removeMovieClip();
this.gotoAndStop(2);
_root.building = false;
_root.selling = true;
_root.temp.attachMovie("sellSign", "1", 1);
_root.temp["1"]._x = _xmouse;
_root.temp["1"]._y = _ymouse;
_root.temp["1"].onEnterFrame = function () {
this._x = _xmouse;
this._y = _ymouse;
if (_xmouse < 400) {
this._alpha = 100;
} else {
this._alpha = 0;
}
};
} else {
this.gotoAndStop(1);
temp["1"].removeMovieClip();
_root.selling = false;
}
}
};
Symbol 11 MovieClip [laser turret] Frame 1
stop();
Symbol 16 MovieClip [missile turret] Frame 1
stop();
Symbol 30 MovieClip [little troop] Frame 1
stop();
Symbol 42 MovieClip [missile] Frame 1
stop();
Symbol 58 Button
on (release) {
_root.inGame = true;
_root.gotoAndStop(2);
}
Symbol 60 MovieClip Frame 1
stop();
Symbol 60 MovieClip Frame 30
stop();
Symbol 73 MovieClip Frame 1
stop();
Symbol 76 MovieClip Frame 1
stop();
Symbol 79 MovieClip Frame 1
stop();