Frame 1
stop();
_global.myMusicPlayer = new Music();
_global.SoundManager = new SoundPlayer();
_global.musicOn = true;
_global.soundOn = true;
_global.isClicked = 0;
_global.theLevel = "";
_global.currentLevel = 20;
_global.latestLevel = 0;
_global.levels = new Array(1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
var mySharedObject = SharedObject.getLocal("userData");
if (mySharedObject.data.levelsCompleted != undefined) {
_global.levels = mySharedObject.data.levelsCompleted;
}
trace(_global.levels);
Instance of Symbol 32 MovieClip in Frame 1
onClipEvent (load) {
myFlag = 0;
Counter = -1;
totalFileSize = _root.getBytesTotal();
startBytes = _root.getBytesLoaded();
_root.continueButton._visible = false;
_root.loadStar.gotoAndStop(1);
}
onClipEvent (enterFrame) {
if (Counter == -1) {
bytesLoaded = _root.getBytesLoaded();
amountLoaded = bytesLoaded / totalFileSize;
myPercentLoaded = int(100 * amountLoaded);
_root.load_txt.text = myPercentLoaded + "%";
_root.loadStar.gotoAndStop(myPercentLoaded);
if ((amountLoaded >= 1) && (myFlag == 0)) {
myFlag = 1;
Counter = 30;
if (_global.latestLevel != 0) {
Counter = 0;
}
}
} else if (Counter == 0) {
okToPlay = true;
siteURL = "http://www.herointeractive.com";
siteURL2 = "http://herointeractive.com";
if ((_url.substr(0, siteURL.length) == siteURL) || (_url.substr(0, siteURL2.length) == siteURL2)) {
okToPlay = true;
}
if (okToPlay) {
if (_global.latestLevel == 0) {
_root.gotoAndPlay("loadSounds");
} else {
_root.gotoAndPlay("level1");
}
}
} else {
Counter--;
}
}
Frame 5
function __com_mochibot__(swfid, mc, lv, trk) {
var x;
var g;
var s;
var fv;
var sb;
var u;
var res;
var mb;
var mbc;
mb = "__mochibot__";
mbc = "mochibot.com";
g = (_global ? (_global) : (_level0._root));
if (g[mb + swfid]) {
return(g[mb + swfid]);
}
s = System.security;
x = mc._root.getSWFVersion;
fv = (x ? (mc.getSWFVersion()) : ((_global ? 6 : 5)));
if (!s) {
s = {};
}
sb = s.sandboxType;
if (sb == "localWithFile") {
return(null);
}
x = s.allowDomain;
if (x) {
s.allowDomain(mbc);
}
x = s.allowInsecureDomain;
if (x) {
s.allowInsecureDomain(mbc);
}
u = (((((((((((("http://" + mbc) + "/my/core.swf?mv=7&fv=") + fv) + "&v=") + escape(getVersion())) + "&swfid=") + escape(swfid)) + "&l=") + lv) + "&f=") + mc) + (sb ? ("&sb=" + sb) : "")) + (trk ? "&t=1" : "");
lv = ((fv > 6) ? (mc.getNextHighestDepth()) : ((g[mb + "level"] ? (g[mb + "level"] + 1) : (lv))));
g[mb + "level"] = lv;
if (fv == 5) {
res = "_level" + lv;
if (!eval (res)) {
loadMovieNum (u, lv);
}
} else {
res = mc.createEmptyMovieClip(mb + swfid, lv);
res.loadMovie(u);
}
return(res);
}
__com_mochibot__("83eb5956", this, 10301, true);
if ((Stage.height > 550) || (Stage.width > 550)) {
_root.gotoAndPlay("broke");
}
stop();
Frame 6
stop();
Frame 10
stop();
Instance of Symbol 32 MovieClip in Frame 10
onClipEvent (load) {
if (_global.musicOn == true) {
_global.myMusicPlayer.SetTrack("title");
_global.myMusicPlayer.SetMaxVolume(100);
_global.myMusicPlayer.PlayWithCrossFade(4);
}
}
onClipEvent (enterFrame) {
_global.myMusicPlayer.RunPlayer();
}
Frame 12
stop();
Instance of Symbol 100 MovieClip "low" in Frame 12
onClipEvent (load) {
if (_quality == "LOW") {
this.gotoAndStop("on");
}
}
on (rollOver) {
this.gotoAndStop("on");
}
on (rollOut) {
if (_quality != "LOW") {
this.gotoAndStop("off");
}
}
on (release) {
_quality = "LOW";
this._parent.high.gotoAndStop("off");
this._parent.med.gotoAndStop("off");
}
Instance of Symbol 100 MovieClip "med" in Frame 12
onClipEvent (load) {
if (_quality == "MEDIUM") {
this.gotoAndStop("on");
}
}
on (rollOver) {
this.gotoAndStop("on");
}
on (rollOut) {
if (_quality != "MEDIUM") {
this.gotoAndStop("off");
}
}
on (release) {
_quality = "MEDIUM";
this._parent.high.gotoAndStop("off");
this._parent.low.gotoAndStop("off");
}
Instance of Symbol 100 MovieClip "high" in Frame 12
onClipEvent (load) {
if (_quality == "HIGH") {
this.gotoAndStop("on");
}
}
on (rollOver) {
this.gotoAndStop("on");
}
on (rollOut) {
if (_quality != "HIGH") {
this.gotoAndStop("off");
}
}
on (release) {
_quality = "HIGH";
this._parent.low.gotoAndStop("off");
this._parent.med.gotoAndStop("off");
}
Instance of Symbol 100 MovieClip "musicOn" in Frame 12
onClipEvent (load) {
if (_global.musicOn == true) {
this.gotoAndStop("on");
}
}
on (rollOver) {
this.gotoAndStop("on");
}
on (rollOut) {
if (_global.musicOn != true) {
this.gotoAndStop("off");
}
}
on (release) {
_global.musicOn = true;
this._parent.musicOff.gotoAndStop("off");
_global.myMusicPlayer.SetTrack("titleMusic");
_global.myMusicPlayer.SetMaxVolume(100);
_global.myMusicPlayer.Play();
}
Instance of Symbol 100 MovieClip "musicOff" in Frame 12
onClipEvent (load) {
if (_global.musicOn == false) {
this.gotoAndStop("on");
}
}
on (rollOver) {
this.gotoAndStop("on");
}
on (rollOut) {
if (_global.musicOn == true) {
this.gotoAndStop("off");
}
}
on (release) {
_global.musicOn = false;
this._parent.musicOn.gotoAndStop("off");
_global.myMusicPlayer.Stop();
}
Instance of Symbol 100 MovieClip "soundsOn" in Frame 12
onClipEvent (load) {
if (_global.soundOn == true) {
this.gotoAndStop("on");
}
}
on (rollOver) {
this.gotoAndStop("on");
}
on (rollOut) {
if (_global.soundOn != true) {
this.gotoAndStop("off");
}
}
on (release) {
_global.soundOn = true;
this._parent.soundsOff.gotoAndStop("off");
}
Instance of Symbol 100 MovieClip "soundsOff" in Frame 12
onClipEvent (load) {
if (_global.soundOn == false) {
this.gotoAndStop("on");
}
}
on (rollOver) {
this.gotoAndStop("on");
}
on (rollOut) {
if (_global.soundOn == true) {
this.gotoAndStop("off");
}
}
on (release) {
_global.soundOn = false;
this._parent.soundsOn.gotoAndStop("off");
}
Instance of Symbol 32 MovieClip in Frame 12
onClipEvent (load) {
if (_global.musicOn == true) {
_global.myMusicPlayer.SetTrack("title");
_global.myMusicPlayer.SetMaxVolume(100);
_global.myMusicPlayer.PlayWithCrossFade(4);
}
}
onClipEvent (enterFrame) {
_global.myMusicPlayer.RunPlayer();
}
Frame 14
stop();
Instance of Symbol 32 MovieClip in Frame 14
onClipEvent (load) {
if (_global.musicOn == true) {
_global.myMusicPlayer.SetTrack("title");
_global.myMusicPlayer.SetMaxVolume(100);
_global.myMusicPlayer.PlayWithCrossFade(4);
}
}
onClipEvent (enterFrame) {
_global.myMusicPlayer.RunPlayer();
}
Frame 16
function SelectLevel(strName) {
var _local3 = Number(strName.substr(1, 2));
trace(_local3);
_global.latestLevel = (_local3 * 5) + 15;
_root.gotoAndPlay("level1");
}
stop();
Instance of Symbol 32 MovieClip in Frame 16
onClipEvent (load) {
var movName;
var i = 1;
while (i < _global.levels.length) {
movName = "l" + i;
if (_global.levels[i] == 1) {
_root[movName].gotoAndStop("unlocked");
} else {
_root[movName].gotoAndStop("locked");
}
i++;
}
if (_global.musicOn == true) {
_global.myMusicPlayer.SetTrack("title");
_global.myMusicPlayer.SetMaxVolume(100);
_global.myMusicPlayer.PlayWithCrossFade(4);
}
}
onClipEvent (enterFrame) {
_global.myMusicPlayer.RunPlayer();
}
Frame 20
function GameSetup() {
trace("%%%%%%%%");
trace((_global.currentLevel + " ----- ") + _global.latestLevel);
if (_global.latestLevel == -1) {
_root.gotoAndPlay("splash");
} else if ((_global.latestLevel != 0) && (_global.latestLevel != 20)) {
_global.currentLevel = _global.latestLevel;
_root.gotoAndPlay(_global.latestLevel);
_global.latestLevel = 0;
trace("go here");
} else if ((_global.latestLevel != 0) && (_global.latestLevel == 20)) {
_global.currentLevel = _global.latestLevel;
_global.latestLevel = 0;
}
if (_root.messages_mc.getDepth() != 50000) {
saveDepth = _root.messages_mc.getDepth();
}
vecShootDir = new Vector();
if (_global.musicOn == true) {
_global.myMusicPlayer.SetTrack("game");
_global.myMusicPlayer.SetMaxVolume(40);
_global.myMusicPlayer.PlayWithCrossFade(4);
}
}
function Mediator() {
_global.myMusicPlayer.RunPlayer();
switch (intState) {
case 1 :
AimProjectile();
if (_root.messages_mc.getDepth() != 50000) {
_root.messages_mc.swapDepths(50000);
trace(_root.messages_mc.getDepth());
}
break;
case 2 :
if (projectileOver == false) {
MoveProjectile();
}
DetectParticleCollisions();
MoveProjectilesAndCollide();
break;
case 3 :
if (Key.isDown(32)) {
Reset();
}
break;
case 4 :
if (!Key.isDown(32)) {
break;
}
Next();
}
}
function Reset() {
projectileDepth = 5000;
arrParticles = arrParticlesReset.slice();
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].gotoAndStop(1);
trace(arrParticles[_local2]);
_local2++;
}
trace("-----");
_root.projectile.gotoAndStop(1);
_root.gameBackground.gotoAndStop(1);
_root.messages_mc.gotoAndStop("hide");
projectileOver = false;
projectileOnScreen = false;
intState = 1;
}
function ExitGame() {
CleanupGame();
Mouse.removeListener(mouseListener);
_root.messages_mc.swapDepths(saveDepth);
_global.latestLevel = -1;
_root.gotoAndPlay("level1");
}
function Next() {
_global.currentLevel = _global.currentLevel + 5;
CleanupGame();
_root.messages_mc.swapDepths(saveDepth);
_root.gotoAndPlay(_global.currentLevel);
}
function CleanupGame() {
Mouse.removeListener(mouseListener);
Reset();
var _local3 = 10;
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].swapDepths(_local3);
_local3++;
_root[arrParticles[_local2]].removeMovieClip();
_local2++;
}
delete arrParticles;
arrParticles = new Array();
}
function DetectParticleCollisions() {
var _local3 = new Array();
var _local2 = 0;
while (_local2 < arrParticles.length) {
var _local4 = (_root[arrParticles[_local2]]._width / 2) + 7.5;
if (GetDistance(arrParticles[_local2], "projectile") <= _local4) {
_root[arrParticles[_local2]].Collision(saveX, saveY);
_local3.push(arrParticles[_local2]);
}
_local2++;
}
_local2 = 0;
while (_local2 < _local3.length) {
RemoveParticle(_local3[_local2]);
_root[_local3[_local2]].gotoAndStop(2);
_local2++;
}
}
function RemoveParticle(strName) {
var _local1 = 0;
while (_local1 < arrParticles.length) {
if (strName == arrParticles[_local1]) {
arrParticles.splice(_local1, 1);
break;
}
_local1++;
}
}
function GetDistance(targetA, targetB) {
var _local3 = _root[targetB]._x - _root[targetA]._x;
var _local2 = _root[targetB]._y - _root[targetA]._y;
return(Math.sqrt((_local3 * _local3) + (_local2 * _local2)));
}
function RegisterParticle(particleName) {
arrParticles.push(particleName);
arrParticlesReset.push(particleName);
particleDepth++;
return(particleDepth);
}
function MoveProjectile() {
if (ProjectileOffScreen() == false) {
projectileOnScreen = true;
_root.projectile._x = _root.projectile._x + vecShootDir._x;
_root.projectile._y = _root.projectile._y + vecShootDir._y;
} else if (projectileOnScreen == true) {
projectileOver = true;
} else {
_root.projectile._x = _root.projectile._x + vecShootDir._x;
_root.projectile._y = _root.projectile._y + vecShootDir._y;
}
}
function AimProjectile() {
var _local11 = new Vector();
_local11._x = _xmouse - (Stage.width / 2);
_local11._y = _ymouse - (Stage.height / 2);
var _local12 = Math.atan2(_local11._y, _local11._x);
var _local15 = (360 * _local12) / (Math.PI*2);
var _local6 = _root.gameBackground._width / 2;
_root.projectile._x = (_local6 * Math.cos(_local12)) + (Stage.width / 2);
_root.projectile._y = (_local6 * Math.sin(_local12)) + (Stage.height / 2);
_local11._x = (Stage.width / 2) - _root.projectile._x;
_local11._y = (Stage.height / 2) - _root.projectile._y;
_local12 = Math.atan2(_local11._y, _local11._x);
var _local14 = Math.cos(_local12) * 11;
var _local13 = Math.sin(_local12) * 11;
var _local9 = _root.projectile._x;
var _local10 = _root.projectile._y;
var _local5 = new Array(arrParticles.length);
var _local4 = 0;
while (_local4 < _local5.length) {
_local5[_local4] = 0;
_local4++;
}
var _local8 = 0;
while (_local8 < 70) {
_local9 = _local9 + _local14;
_local10 = _local10 + _local13;
_local4 = 0;
while (_local4 < arrParticles.length) {
var _local7 = (_root[arrParticles[_local4]]._width / 2) + 7.5;
var _local3 = _root[arrParticles[_local4]]._x - _local9;
var _local2 = _root[arrParticles[_local4]]._y - _local10;
_local6 = Math.sqrt((_local3 * _local3) + (_local2 * _local2));
if (_local6 <= _local7) {
_local5[_local4] = 1;
}
_local4++;
}
_local8++;
}
_local4 = 0;
while (_local4 < _local5.length) {
if (_local5[_local4] == 1) {
_root[arrParticles[_local4]].ArrowsOn(arrowDepth, _root.projectile._x, _root.projectile._y);
} else {
_root[arrParticles[_local4]].ArrowsOff();
}
_local4++;
}
}
function TurnOffAllArrows() {
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].ArrowsOff();
_local2++;
}
}
function NextArrowDepth() {
arrowDepth++;
if (arrowDepth > 39999) {
arrowDepth = 15000;
}
}
function DrawLines() {
_root.clear();
_root.lineStyle(2, 16777215, 50);
var _local2 = new Object();
var _local3 = new Object();
_local2.x = _root.projectile._x;
_local2.y = _root.projectile._y;
_local3.x = _xmouse;
_local3.y = _ymouse;
_root.moveTo(_local2.x, _local2.y);
_root.lineTo(_local3.x, _local3.y);
}
function Shoot() {
if ((intState == 1) && (_global.latestLevel != -1)) {
trace("in");
_root.clear();
saveX = _root.projectile._x;
saveY = _root.projectile._y;
var _local4 = new Vector();
_local4._x = (Stage.width / 2) - _root.projectile._x;
_local4._y = (Stage.height / 2) - _root.projectile._y;
var _local5 = Math.atan2(_local4._y, _local4._x);
vecShootDir._x = Math.cos(_local5) * 11;
vecShootDir._y = Math.sin(_local5) * 11;
var _local3 = 100;
do {
if (ProjectileOffScreen() != false) {
break;
}
_root.projectile._x = _root.projectile._x - vecShootDir._x;
_root.projectile._y = _root.projectile._y - vecShootDir._y;
_local3--;
} while (_local3 != 0);
var _local6 = (360 * _local5) / (Math.PI*2);
_root.projectile.gotoAndStop(2);
_root.projectile._rotation = _local6;
_root.gameBackground.gotoAndPlay("hide");
TurnOffAllArrows();
intState = 2;
}
}
function ProjectileOffScreen() {
var _local2 = false;
if (((_root.projectile._x + _root.projectile._width) < 0) || ((_root.projectile._x - _root.projectile._width) > Stage.width)) {
_local2 = true;
}
if (((_root.projectile._y + _root.projectile._height) < 0) || ((_root.projectile._y - _root.projectile._height) > Stage.height)) {
_local2 = true;
}
return(_local2);
}
function MoveProjectilesAndCollide() {
var _local4 = 0;
while (_local4 < arrProjectiles.length) {
_root[arrProjectiles[_local4].name]._x = _root[arrProjectiles[_local4].name]._x + (arrProjectiles[_local4].dX / 2);
_root[arrProjectiles[_local4].name]._y = _root[arrProjectiles[_local4].name]._y + (arrProjectiles[_local4].dY / 2);
if (((_root[arrProjectiles[_local4].name]._x + _root[arrProjectiles[_local4].name]._width) < 0) || ((_root[arrProjectiles[_local4].name]._x - _root[arrProjectiles[_local4].name]._width) > Stage.width)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
if (((_root[arrProjectiles[_local4].name]._y + _root[arrProjectiles[_local4].name]._height) < 0) || ((_root[arrProjectiles[_local4].name]._y - _root[arrProjectiles[_local4].name]._height) > Stage.height)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
_local4++;
}
var _local5 = new Array();
var _local3 = 0;
while (_local3 < arrProjectiles.length) {
_local4 = 0;
while (_local4 < arrParticles.length) {
if (_root[arrParticles[_local4]].hitTest(_root[arrProjectiles[_local3].name]._x, _root[arrProjectiles[_local3].name]._y, true) == true) {
_local5.push({name:arrParticles[_local4], X:arrProjectiles[_local3].X, Y:arrProjectiles[_local3].Y});
arrParticles.splice(_local4, 1);
_local4--;
_root[arrProjectiles[_local3].name].removeMovieClip();
arrProjectiles.splice(_local3, 1);
_local3--;
}
_local4++;
}
_local3++;
}
_local4 = 0;
while (_local4 < _local5.length) {
_root[_local5[_local4].name].Collision(_local5[_local4].X, _local5[_local4].Y);
_root[_local5[_local4].name].gotoAndStop(2);
_local4++;
}
_local4 = 0;
while (_local4 < arrProjectiles.length) {
_root[arrProjectiles[_local4].name]._x = _root[arrProjectiles[_local4].name]._x + (arrProjectiles[_local4].dX / 2);
_root[arrProjectiles[_local4].name]._y = _root[arrProjectiles[_local4].name]._y + (arrProjectiles[_local4].dY / 2);
if (((_root[arrProjectiles[_local4].name]._x + _root[arrProjectiles[_local4].name]._width) < 0) || ((_root[arrProjectiles[_local4].name]._x - _root[arrProjectiles[_local4].name]._width) > Stage.width)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
if (((_root[arrProjectiles[_local4].name]._y + _root[arrProjectiles[_local4].name]._height) < 0) || ((_root[arrProjectiles[_local4].name]._y - _root[arrProjectiles[_local4].name]._height) > Stage.height)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
_local4++;
}
_local5 = new Array();
_local3 = 0;
while (_local3 < arrProjectiles.length) {
_local4 = 0;
while (_local4 < arrParticles.length) {
if (_root[arrParticles[_local4]].hitTest(_root[arrProjectiles[_local3].name]._x, _root[arrProjectiles[_local3].name]._y, true) == true) {
_local5.push({name:arrParticles[_local4], X:arrProjectiles[_local3].X, Y:arrProjectiles[_local3].Y});
arrParticles.splice(_local4, 1);
_local4--;
_root[arrProjectiles[_local3].name].removeMovieClip();
arrProjectiles.splice(_local3, 1);
_local3--;
}
_local4++;
}
_local3++;
}
_local4 = 0;
while (_local4 < _local5.length) {
_root[_local5[_local4].name].Collision(_local5[_local4].X, _local5[_local4].Y);
_root[_local5[_local4].name].gotoAndStop(2);
_local4++;
}
if ((arrProjectiles.length == 0) && (projectileOver == true)) {
if (arrParticles.length != 0) {
intState = 3;
_root.messages_mc.gotoAndPlay("retry");
} else {
intState = 4;
var _local10 = ((_global.currentLevel + 5) - 15) / 5;
_global.levels[_local10] = 1;
var _local9 = SharedObject.getLocal("userData");
_local9.data.levelsCompleted = _global.levels;
_global.SoundManager.PlaySound("all");
_root.messages_mc.gotoAndPlay("next");
}
}
}
function LaunchProjectile(deltaX, deltaY, startX, startY, rot) {
var _local2 = "projectile_" + projectileDepth;
arrProjectiles.push({name:_local2, dX:deltaX, dY:deltaY, X:startX, Y:startY});
_root.attachMovie("shootingStar", _local2, projectileDepth);
_root[_local2]._x = startX;
_root[_local2]._y = startY;
_root[_local2]._rotation = rot;
projectileDepth++;
if (projectileDepth > 9999) {
projectileDepth = 5000;
}
}
stop();
var intState = 1;
var vecShootDir;
var arrParticles = new Array();
var arrProjectiles = new Array();
var arrParticlesReset = new Array();
var particleDepth = 1000;
var projectileDepth = 5000;
var arrowDepth = 15000;
var saveX = 0;
var saveY = 0;
var projectileOnScreen = false;
var projectileOver = false;
var saveDepth;
mouseListener = new Object();
mouseListener.onMouseDown = function () {
_root.Shoot();
};
Mouse.addListener(mouseListener);
Instance of Symbol 32 MovieClip in Frame 20
onClipEvent (load) {
_root.GameSetup();
}
onClipEvent (enterFrame) {
_root.Mediator();
}
Frame 25
function GameSetup() {
trace("%%%%%%%%");
trace((_global.currentLevel + " ----- ") + _global.latestLevel);
if (_global.latestLevel == -1) {
_root.gotoAndPlay("splash");
} else if ((_global.latestLevel != 0) && (_global.latestLevel != 20)) {
_global.currentLevel = _global.latestLevel;
_root.gotoAndPlay(_global.latestLevel);
_global.latestLevel = 0;
trace("go here");
} else if ((_global.latestLevel != 0) && (_global.latestLevel == 20)) {
_global.currentLevel = _global.latestLevel;
_global.latestLevel = 0;
}
if (_root.messages_mc.getDepth() != 50000) {
saveDepth = _root.messages_mc.getDepth();
}
vecShootDir = new Vector();
if (_global.musicOn == true) {
_global.myMusicPlayer.SetTrack("game");
_global.myMusicPlayer.SetMaxVolume(40);
_global.myMusicPlayer.PlayWithCrossFade(4);
}
}
function Mediator() {
_global.myMusicPlayer.RunPlayer();
switch (intState) {
case 1 :
AimProjectile();
if (_root.messages_mc.getDepth() != 50000) {
_root.messages_mc.swapDepths(50000);
trace(_root.messages_mc.getDepth());
}
break;
case 2 :
if (projectileOver == false) {
MoveProjectile();
}
DetectParticleCollisions();
MoveProjectilesAndCollide();
break;
case 3 :
if (Key.isDown(32)) {
Reset();
}
break;
case 4 :
if (!Key.isDown(32)) {
break;
}
Next();
}
}
function Reset() {
projectileDepth = 5000;
arrParticles = arrParticlesReset.slice();
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].gotoAndStop(1);
trace(arrParticles[_local2]);
_local2++;
}
trace("-----");
_root.projectile.gotoAndStop(1);
_root.gameBackground.gotoAndStop(1);
_root.messages_mc.gotoAndStop("hide");
projectileOver = false;
projectileOnScreen = false;
intState = 1;
}
function ExitGame() {
CleanupGame();
Mouse.removeListener(mouseListener);
_root.messages_mc.swapDepths(saveDepth);
_global.latestLevel = -1;
_root.gotoAndPlay("level1");
}
function Next() {
_global.currentLevel = _global.currentLevel + 5;
CleanupGame();
_root.messages_mc.swapDepths(saveDepth);
_root.gotoAndPlay(_global.currentLevel);
}
function CleanupGame() {
Mouse.removeListener(mouseListener);
Reset();
var _local3 = 10;
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].swapDepths(_local3);
_local3++;
_root[arrParticles[_local2]].removeMovieClip();
_local2++;
}
delete arrParticles;
arrParticles = new Array();
}
function DetectParticleCollisions() {
var _local3 = new Array();
var _local2 = 0;
while (_local2 < arrParticles.length) {
var _local4 = (_root[arrParticles[_local2]]._width / 2) + 7.5;
if (GetDistance(arrParticles[_local2], "projectile") <= _local4) {
_root[arrParticles[_local2]].Collision(saveX, saveY);
_local3.push(arrParticles[_local2]);
}
_local2++;
}
_local2 = 0;
while (_local2 < _local3.length) {
RemoveParticle(_local3[_local2]);
_root[_local3[_local2]].gotoAndStop(2);
_local2++;
}
}
function RemoveParticle(strName) {
var _local1 = 0;
while (_local1 < arrParticles.length) {
if (strName == arrParticles[_local1]) {
arrParticles.splice(_local1, 1);
break;
}
_local1++;
}
}
function GetDistance(targetA, targetB) {
var _local3 = _root[targetB]._x - _root[targetA]._x;
var _local2 = _root[targetB]._y - _root[targetA]._y;
return(Math.sqrt((_local3 * _local3) + (_local2 * _local2)));
}
function RegisterParticle(particleName) {
arrParticles.push(particleName);
arrParticlesReset.push(particleName);
particleDepth++;
return(particleDepth);
}
function MoveProjectile() {
if (ProjectileOffScreen() == false) {
projectileOnScreen = true;
_root.projectile._x = _root.projectile._x + vecShootDir._x;
_root.projectile._y = _root.projectile._y + vecShootDir._y;
} else if (projectileOnScreen == true) {
projectileOver = true;
} else {
_root.projectile._x = _root.projectile._x + vecShootDir._x;
_root.projectile._y = _root.projectile._y + vecShootDir._y;
}
}
function AimProjectile() {
var _local11 = new Vector();
_local11._x = _xmouse - (Stage.width / 2);
_local11._y = _ymouse - (Stage.height / 2);
var _local12 = Math.atan2(_local11._y, _local11._x);
var _local15 = (360 * _local12) / (Math.PI*2);
var _local6 = _root.gameBackground._width / 2;
_root.projectile._x = (_local6 * Math.cos(_local12)) + (Stage.width / 2);
_root.projectile._y = (_local6 * Math.sin(_local12)) + (Stage.height / 2);
_local11._x = (Stage.width / 2) - _root.projectile._x;
_local11._y = (Stage.height / 2) - _root.projectile._y;
_local12 = Math.atan2(_local11._y, _local11._x);
var _local14 = Math.cos(_local12) * 11;
var _local13 = Math.sin(_local12) * 11;
var _local9 = _root.projectile._x;
var _local10 = _root.projectile._y;
var _local5 = new Array(arrParticles.length);
var _local4 = 0;
while (_local4 < _local5.length) {
_local5[_local4] = 0;
_local4++;
}
var _local8 = 0;
while (_local8 < 70) {
_local9 = _local9 + _local14;
_local10 = _local10 + _local13;
_local4 = 0;
while (_local4 < arrParticles.length) {
var _local7 = (_root[arrParticles[_local4]]._width / 2) + 7.5;
var _local3 = _root[arrParticles[_local4]]._x - _local9;
var _local2 = _root[arrParticles[_local4]]._y - _local10;
_local6 = Math.sqrt((_local3 * _local3) + (_local2 * _local2));
if (_local6 <= _local7) {
_local5[_local4] = 1;
}
_local4++;
}
_local8++;
}
_local4 = 0;
while (_local4 < _local5.length) {
if (_local5[_local4] == 1) {
_root[arrParticles[_local4]].ArrowsOn(arrowDepth, _root.projectile._x, _root.projectile._y);
} else {
_root[arrParticles[_local4]].ArrowsOff();
}
_local4++;
}
}
function TurnOffAllArrows() {
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].ArrowsOff();
_local2++;
}
}
function NextArrowDepth() {
arrowDepth++;
if (arrowDepth > 39999) {
arrowDepth = 15000;
}
}
function DrawLines() {
_root.clear();
_root.lineStyle(2, 16777215, 50);
var _local2 = new Object();
var _local3 = new Object();
_local2.x = _root.projectile._x;
_local2.y = _root.projectile._y;
_local3.x = _xmouse;
_local3.y = _ymouse;
_root.moveTo(_local2.x, _local2.y);
_root.lineTo(_local3.x, _local3.y);
}
function Shoot() {
if ((intState == 1) && (_global.latestLevel != -1)) {
trace("in");
_root.clear();
saveX = _root.projectile._x;
saveY = _root.projectile._y;
var _local4 = new Vector();
_local4._x = (Stage.width / 2) - _root.projectile._x;
_local4._y = (Stage.height / 2) - _root.projectile._y;
var _local5 = Math.atan2(_local4._y, _local4._x);
vecShootDir._x = Math.cos(_local5) * 11;
vecShootDir._y = Math.sin(_local5) * 11;
var _local3 = 100;
do {
if (ProjectileOffScreen() != false) {
break;
}
_root.projectile._x = _root.projectile._x - vecShootDir._x;
_root.projectile._y = _root.projectile._y - vecShootDir._y;
_local3--;
} while (_local3 != 0);
var _local6 = (360 * _local5) / (Math.PI*2);
_root.projectile.gotoAndStop(2);
_root.projectile._rotation = _local6;
_root.gameBackground.gotoAndPlay("hide");
TurnOffAllArrows();
intState = 2;
}
}
function ProjectileOffScreen() {
var _local2 = false;
if (((_root.projectile._x + _root.projectile._width) < 0) || ((_root.projectile._x - _root.projectile._width) > Stage.width)) {
_local2 = true;
}
if (((_root.projectile._y + _root.projectile._height) < 0) || ((_root.projectile._y - _root.projectile._height) > Stage.height)) {
_local2 = true;
}
return(_local2);
}
function MoveProjectilesAndCollide() {
var _local4 = 0;
while (_local4 < arrProjectiles.length) {
_root[arrProjectiles[_local4].name]._x = _root[arrProjectiles[_local4].name]._x + (arrProjectiles[_local4].dX / 2);
_root[arrProjectiles[_local4].name]._y = _root[arrProjectiles[_local4].name]._y + (arrProjectiles[_local4].dY / 2);
if (((_root[arrProjectiles[_local4].name]._x + _root[arrProjectiles[_local4].name]._width) < 0) || ((_root[arrProjectiles[_local4].name]._x - _root[arrProjectiles[_local4].name]._width) > Stage.width)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
if (((_root[arrProjectiles[_local4].name]._y + _root[arrProjectiles[_local4].name]._height) < 0) || ((_root[arrProjectiles[_local4].name]._y - _root[arrProjectiles[_local4].name]._height) > Stage.height)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
_local4++;
}
var _local5 = new Array();
var _local3 = 0;
while (_local3 < arrProjectiles.length) {
_local4 = 0;
while (_local4 < arrParticles.length) {
if (_root[arrParticles[_local4]].hitTest(_root[arrProjectiles[_local3].name]._x, _root[arrProjectiles[_local3].name]._y, true) == true) {
_local5.push({name:arrParticles[_local4], X:arrProjectiles[_local3].X, Y:arrProjectiles[_local3].Y});
arrParticles.splice(_local4, 1);
_local4--;
_root[arrProjectiles[_local3].name].removeMovieClip();
arrProjectiles.splice(_local3, 1);
_local3--;
}
_local4++;
}
_local3++;
}
_local4 = 0;
while (_local4 < _local5.length) {
_root[_local5[_local4].name].Collision(_local5[_local4].X, _local5[_local4].Y);
_root[_local5[_local4].name].gotoAndStop(2);
_local4++;
}
_local4 = 0;
while (_local4 < arrProjectiles.length) {
_root[arrProjectiles[_local4].name]._x = _root[arrProjectiles[_local4].name]._x + (arrProjectiles[_local4].dX / 2);
_root[arrProjectiles[_local4].name]._y = _root[arrProjectiles[_local4].name]._y + (arrProjectiles[_local4].dY / 2);
if (((_root[arrProjectiles[_local4].name]._x + _root[arrProjectiles[_local4].name]._width) < 0) || ((_root[arrProjectiles[_local4].name]._x - _root[arrProjectiles[_local4].name]._width) > Stage.width)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
if (((_root[arrProjectiles[_local4].name]._y + _root[arrProjectiles[_local4].name]._height) < 0) || ((_root[arrProjectiles[_local4].name]._y - _root[arrProjectiles[_local4].name]._height) > Stage.height)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
_local4++;
}
_local5 = new Array();
_local3 = 0;
while (_local3 < arrProjectiles.length) {
_local4 = 0;
while (_local4 < arrParticles.length) {
if (_root[arrParticles[_local4]].hitTest(_root[arrProjectiles[_local3].name]._x, _root[arrProjectiles[_local3].name]._y, true) == true) {
_local5.push({name:arrParticles[_local4], X:arrProjectiles[_local3].X, Y:arrProjectiles[_local3].Y});
arrParticles.splice(_local4, 1);
_local4--;
_root[arrProjectiles[_local3].name].removeMovieClip();
arrProjectiles.splice(_local3, 1);
_local3--;
}
_local4++;
}
_local3++;
}
_local4 = 0;
while (_local4 < _local5.length) {
_root[_local5[_local4].name].Collision(_local5[_local4].X, _local5[_local4].Y);
_root[_local5[_local4].name].gotoAndStop(2);
_local4++;
}
if ((arrProjectiles.length == 0) && (projectileOver == true)) {
if (arrParticles.length != 0) {
intState = 3;
_root.messages_mc.gotoAndPlay("retry");
} else {
intState = 4;
var _local10 = ((_global.currentLevel + 5) - 15) / 5;
_global.levels[_local10] = 1;
var _local9 = SharedObject.getLocal("userData");
_local9.data.levelsCompleted = _global.levels;
_global.SoundManager.PlaySound("all");
_root.messages_mc.gotoAndPlay("next");
}
}
}
function LaunchProjectile(deltaX, deltaY, startX, startY, rot) {
var _local2 = "projectile_" + projectileDepth;
arrProjectiles.push({name:_local2, dX:deltaX, dY:deltaY, X:startX, Y:startY});
_root.attachMovie("shootingStar", _local2, projectileDepth);
_root[_local2]._x = startX;
_root[_local2]._y = startY;
_root[_local2]._rotation = rot;
projectileDepth++;
if (projectileDepth > 9999) {
projectileDepth = 5000;
}
}
stop();
var intState = 1;
var vecShootDir;
var arrParticles = new Array();
var arrProjectiles = new Array();
var arrParticlesReset = new Array();
var particleDepth = 1000;
var projectileDepth = 5000;
var arrowDepth = 15000;
var saveX = 0;
var saveY = 0;
var projectileOnScreen = false;
var projectileOver = false;
var saveDepth;
mouseListener = new Object();
mouseListener.onMouseDown = function () {
_root.Shoot();
};
Mouse.addListener(mouseListener);
Instance of Symbol 32 MovieClip in Frame 25
onClipEvent (load) {
_root.GameSetup();
}
onClipEvent (enterFrame) {
_root.Mediator();
}
Frame 30
function GameSetup() {
trace("%%%%%%%%");
trace((_global.currentLevel + " ----- ") + _global.latestLevel);
if (_global.latestLevel == -1) {
_root.gotoAndPlay("splash");
} else if ((_global.latestLevel != 0) && (_global.latestLevel != 20)) {
_global.currentLevel = _global.latestLevel;
_root.gotoAndPlay(_global.latestLevel);
_global.latestLevel = 0;
trace("go here");
} else if ((_global.latestLevel != 0) && (_global.latestLevel == 20)) {
_global.currentLevel = _global.latestLevel;
_global.latestLevel = 0;
}
if (_root.messages_mc.getDepth() != 50000) {
saveDepth = _root.messages_mc.getDepth();
}
vecShootDir = new Vector();
if (_global.musicOn == true) {
_global.myMusicPlayer.SetTrack("game");
_global.myMusicPlayer.SetMaxVolume(40);
_global.myMusicPlayer.PlayWithCrossFade(4);
}
}
function Mediator() {
_global.myMusicPlayer.RunPlayer();
switch (intState) {
case 1 :
AimProjectile();
if (_root.messages_mc.getDepth() != 50000) {
_root.messages_mc.swapDepths(50000);
trace(_root.messages_mc.getDepth());
}
break;
case 2 :
if (projectileOver == false) {
MoveProjectile();
}
DetectParticleCollisions();
MoveProjectilesAndCollide();
break;
case 3 :
if (Key.isDown(32)) {
Reset();
}
break;
case 4 :
if (!Key.isDown(32)) {
break;
}
Next();
}
}
function Reset() {
projectileDepth = 5000;
arrParticles = arrParticlesReset.slice();
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].gotoAndStop(1);
trace(arrParticles[_local2]);
_local2++;
}
trace("-----");
_root.projectile.gotoAndStop(1);
_root.gameBackground.gotoAndStop(1);
_root.messages_mc.gotoAndStop("hide");
projectileOver = false;
projectileOnScreen = false;
intState = 1;
}
function ExitGame() {
CleanupGame();
Mouse.removeListener(mouseListener);
_root.messages_mc.swapDepths(saveDepth);
_global.latestLevel = -1;
_root.gotoAndPlay("level1");
}
function Next() {
_global.currentLevel = _global.currentLevel + 5;
CleanupGame();
_root.messages_mc.swapDepths(saveDepth);
_root.gotoAndPlay(_global.currentLevel);
}
function CleanupGame() {
Mouse.removeListener(mouseListener);
Reset();
var _local3 = 10;
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].swapDepths(_local3);
_local3++;
_root[arrParticles[_local2]].removeMovieClip();
_local2++;
}
delete arrParticles;
arrParticles = new Array();
}
function DetectParticleCollisions() {
var _local3 = new Array();
var _local2 = 0;
while (_local2 < arrParticles.length) {
var _local4 = (_root[arrParticles[_local2]]._width / 2) + 7.5;
if (GetDistance(arrParticles[_local2], "projectile") <= _local4) {
_root[arrParticles[_local2]].Collision(saveX, saveY);
_local3.push(arrParticles[_local2]);
}
_local2++;
}
_local2 = 0;
while (_local2 < _local3.length) {
RemoveParticle(_local3[_local2]);
_root[_local3[_local2]].gotoAndStop(2);
_local2++;
}
}
function RemoveParticle(strName) {
var _local1 = 0;
while (_local1 < arrParticles.length) {
if (strName == arrParticles[_local1]) {
arrParticles.splice(_local1, 1);
break;
}
_local1++;
}
}
function GetDistance(targetA, targetB) {
var _local3 = _root[targetB]._x - _root[targetA]._x;
var _local2 = _root[targetB]._y - _root[targetA]._y;
return(Math.sqrt((_local3 * _local3) + (_local2 * _local2)));
}
function RegisterParticle(particleName) {
arrParticles.push(particleName);
arrParticlesReset.push(particleName);
particleDepth++;
return(particleDepth);
}
function MoveProjectile() {
if (ProjectileOffScreen() == false) {
projectileOnScreen = true;
_root.projectile._x = _root.projectile._x + vecShootDir._x;
_root.projectile._y = _root.projectile._y + vecShootDir._y;
} else if (projectileOnScreen == true) {
projectileOver = true;
} else {
_root.projectile._x = _root.projectile._x + vecShootDir._x;
_root.projectile._y = _root.projectile._y + vecShootDir._y;
}
}
function AimProjectile() {
var _local11 = new Vector();
_local11._x = _xmouse - (Stage.width / 2);
_local11._y = _ymouse - (Stage.height / 2);
var _local12 = Math.atan2(_local11._y, _local11._x);
var _local15 = (360 * _local12) / (Math.PI*2);
var _local6 = _root.gameBackground._width / 2;
_root.projectile._x = (_local6 * Math.cos(_local12)) + (Stage.width / 2);
_root.projectile._y = (_local6 * Math.sin(_local12)) + (Stage.height / 2);
_local11._x = (Stage.width / 2) - _root.projectile._x;
_local11._y = (Stage.height / 2) - _root.projectile._y;
_local12 = Math.atan2(_local11._y, _local11._x);
var _local14 = Math.cos(_local12) * 11;
var _local13 = Math.sin(_local12) * 11;
var _local9 = _root.projectile._x;
var _local10 = _root.projectile._y;
var _local5 = new Array(arrParticles.length);
var _local4 = 0;
while (_local4 < _local5.length) {
_local5[_local4] = 0;
_local4++;
}
var _local8 = 0;
while (_local8 < 70) {
_local9 = _local9 + _local14;
_local10 = _local10 + _local13;
_local4 = 0;
while (_local4 < arrParticles.length) {
var _local7 = (_root[arrParticles[_local4]]._width / 2) + 7.5;
var _local3 = _root[arrParticles[_local4]]._x - _local9;
var _local2 = _root[arrParticles[_local4]]._y - _local10;
_local6 = Math.sqrt((_local3 * _local3) + (_local2 * _local2));
if (_local6 <= _local7) {
_local5[_local4] = 1;
}
_local4++;
}
_local8++;
}
_local4 = 0;
while (_local4 < _local5.length) {
if (_local5[_local4] == 1) {
_root[arrParticles[_local4]].ArrowsOn(arrowDepth, _root.projectile._x, _root.projectile._y);
} else {
_root[arrParticles[_local4]].ArrowsOff();
}
_local4++;
}
}
function TurnOffAllArrows() {
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].ArrowsOff();
_local2++;
}
}
function NextArrowDepth() {
arrowDepth++;
if (arrowDepth > 39999) {
arrowDepth = 15000;
}
}
function DrawLines() {
_root.clear();
_root.lineStyle(2, 16777215, 50);
var _local2 = new Object();
var _local3 = new Object();
_local2.x = _root.projectile._x;
_local2.y = _root.projectile._y;
_local3.x = _xmouse;
_local3.y = _ymouse;
_root.moveTo(_local2.x, _local2.y);
_root.lineTo(_local3.x, _local3.y);
}
function Shoot() {
if ((intState == 1) && (_global.latestLevel != -1)) {
trace("in");
_root.clear();
saveX = _root.projectile._x;
saveY = _root.projectile._y;
var _local4 = new Vector();
_local4._x = (Stage.width / 2) - _root.projectile._x;
_local4._y = (Stage.height / 2) - _root.projectile._y;
var _local5 = Math.atan2(_local4._y, _local4._x);
vecShootDir._x = Math.cos(_local5) * 11;
vecShootDir._y = Math.sin(_local5) * 11;
var _local3 = 100;
do {
if (ProjectileOffScreen() != false) {
break;
}
_root.projectile._x = _root.projectile._x - vecShootDir._x;
_root.projectile._y = _root.projectile._y - vecShootDir._y;
_local3--;
} while (_local3 != 0);
var _local6 = (360 * _local5) / (Math.PI*2);
_root.projectile.gotoAndStop(2);
_root.projectile._rotation = _local6;
_root.gameBackground.gotoAndPlay("hide");
TurnOffAllArrows();
intState = 2;
}
}
function ProjectileOffScreen() {
var _local2 = false;
if (((_root.projectile._x + _root.projectile._width) < 0) || ((_root.projectile._x - _root.projectile._width) > Stage.width)) {
_local2 = true;
}
if (((_root.projectile._y + _root.projectile._height) < 0) || ((_root.projectile._y - _root.projectile._height) > Stage.height)) {
_local2 = true;
}
return(_local2);
}
function MoveProjectilesAndCollide() {
var _local4 = 0;
while (_local4 < arrProjectiles.length) {
_root[arrProjectiles[_local4].name]._x = _root[arrProjectiles[_local4].name]._x + (arrProjectiles[_local4].dX / 2);
_root[arrProjectiles[_local4].name]._y = _root[arrProjectiles[_local4].name]._y + (arrProjectiles[_local4].dY / 2);
if (((_root[arrProjectiles[_local4].name]._x + _root[arrProjectiles[_local4].name]._width) < 0) || ((_root[arrProjectiles[_local4].name]._x - _root[arrProjectiles[_local4].name]._width) > Stage.width)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
if (((_root[arrProjectiles[_local4].name]._y + _root[arrProjectiles[_local4].name]._height) < 0) || ((_root[arrProjectiles[_local4].name]._y - _root[arrProjectiles[_local4].name]._height) > Stage.height)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
_local4++;
}
var _local5 = new Array();
var _local3 = 0;
while (_local3 < arrProjectiles.length) {
_local4 = 0;
while (_local4 < arrParticles.length) {
if (_root[arrParticles[_local4]].hitTest(_root[arrProjectiles[_local3].name]._x, _root[arrProjectiles[_local3].name]._y, true) == true) {
_local5.push({name:arrParticles[_local4], X:arrProjectiles[_local3].X, Y:arrProjectiles[_local3].Y});
arrParticles.splice(_local4, 1);
_local4--;
_root[arrProjectiles[_local3].name].removeMovieClip();
arrProjectiles.splice(_local3, 1);
_local3--;
}
_local4++;
}
_local3++;
}
_local4 = 0;
while (_local4 < _local5.length) {
_root[_local5[_local4].name].Collision(_local5[_local4].X, _local5[_local4].Y);
_root[_local5[_local4].name].gotoAndStop(2);
_local4++;
}
_local4 = 0;
while (_local4 < arrProjectiles.length) {
_root[arrProjectiles[_local4].name]._x = _root[arrProjectiles[_local4].name]._x + (arrProjectiles[_local4].dX / 2);
_root[arrProjectiles[_local4].name]._y = _root[arrProjectiles[_local4].name]._y + (arrProjectiles[_local4].dY / 2);
if (((_root[arrProjectiles[_local4].name]._x + _root[arrProjectiles[_local4].name]._width) < 0) || ((_root[arrProjectiles[_local4].name]._x - _root[arrProjectiles[_local4].name]._width) > Stage.width)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
if (((_root[arrProjectiles[_local4].name]._y + _root[arrProjectiles[_local4].name]._height) < 0) || ((_root[arrProjectiles[_local4].name]._y - _root[arrProjectiles[_local4].name]._height) > Stage.height)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
_local4++;
}
_local5 = new Array();
_local3 = 0;
while (_local3 < arrProjectiles.length) {
_local4 = 0;
while (_local4 < arrParticles.length) {
if (_root[arrParticles[_local4]].hitTest(_root[arrProjectiles[_local3].name]._x, _root[arrProjectiles[_local3].name]._y, true) == true) {
_local5.push({name:arrParticles[_local4], X:arrProjectiles[_local3].X, Y:arrProjectiles[_local3].Y});
arrParticles.splice(_local4, 1);
_local4--;
_root[arrProjectiles[_local3].name].removeMovieClip();
arrProjectiles.splice(_local3, 1);
_local3--;
}
_local4++;
}
_local3++;
}
_local4 = 0;
while (_local4 < _local5.length) {
_root[_local5[_local4].name].Collision(_local5[_local4].X, _local5[_local4].Y);
_root[_local5[_local4].name].gotoAndStop(2);
_local4++;
}
if ((arrProjectiles.length == 0) && (projectileOver == true)) {
if (arrParticles.length != 0) {
intState = 3;
_root.messages_mc.gotoAndPlay("retry");
} else {
intState = 4;
var _local10 = ((_global.currentLevel + 5) - 15) / 5;
_global.levels[_local10] = 1;
var _local9 = SharedObject.getLocal("userData");
_local9.data.levelsCompleted = _global.levels;
_global.SoundManager.PlaySound("all");
_root.messages_mc.gotoAndPlay("next");
}
}
}
function LaunchProjectile(deltaX, deltaY, startX, startY, rot) {
var _local2 = "projectile_" + projectileDepth;
arrProjectiles.push({name:_local2, dX:deltaX, dY:deltaY, X:startX, Y:startY});
_root.attachMovie("shootingStar", _local2, projectileDepth);
_root[_local2]._x = startX;
_root[_local2]._y = startY;
_root[_local2]._rotation = rot;
projectileDepth++;
if (projectileDepth > 9999) {
projectileDepth = 5000;
}
}
stop();
var intState = 1;
var vecShootDir;
var arrParticles = new Array();
var arrProjectiles = new Array();
var arrParticlesReset = new Array();
var particleDepth = 1000;
var projectileDepth = 5000;
var arrowDepth = 15000;
var saveX = 0;
var saveY = 0;
var projectileOnScreen = false;
var projectileOver = false;
var saveDepth;
mouseListener = new Object();
mouseListener.onMouseDown = function () {
_root.Shoot();
};
Mouse.addListener(mouseListener);
Instance of Symbol 32 MovieClip in Frame 30
onClipEvent (load) {
_root.GameSetup();
}
onClipEvent (enterFrame) {
_root.Mediator();
}
Frame 35
function GameSetup() {
trace("%%%%%%%%");
trace((_global.currentLevel + " ----- ") + _global.latestLevel);
if (_global.latestLevel == -1) {
_root.gotoAndPlay("splash");
} else if ((_global.latestLevel != 0) && (_global.latestLevel != 20)) {
_global.currentLevel = _global.latestLevel;
_root.gotoAndPlay(_global.latestLevel);
_global.latestLevel = 0;
trace("go here");
} else if ((_global.latestLevel != 0) && (_global.latestLevel == 20)) {
_global.currentLevel = _global.latestLevel;
_global.latestLevel = 0;
}
if (_root.messages_mc.getDepth() != 50000) {
saveDepth = _root.messages_mc.getDepth();
}
vecShootDir = new Vector();
if (_global.musicOn == true) {
_global.myMusicPlayer.SetTrack("game");
_global.myMusicPlayer.SetMaxVolume(40);
_global.myMusicPlayer.PlayWithCrossFade(4);
}
}
function Mediator() {
_global.myMusicPlayer.RunPlayer();
switch (intState) {
case 1 :
AimProjectile();
if (_root.messages_mc.getDepth() != 50000) {
_root.messages_mc.swapDepths(50000);
trace(_root.messages_mc.getDepth());
}
break;
case 2 :
if (projectileOver == false) {
MoveProjectile();
}
DetectParticleCollisions();
MoveProjectilesAndCollide();
break;
case 3 :
if (Key.isDown(32)) {
Reset();
}
break;
case 4 :
if (!Key.isDown(32)) {
break;
}
Next();
}
}
function Reset() {
projectileDepth = 5000;
arrParticles = arrParticlesReset.slice();
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].gotoAndStop(1);
trace(arrParticles[_local2]);
_local2++;
}
trace("-----");
_root.projectile.gotoAndStop(1);
_root.gameBackground.gotoAndStop(1);
_root.messages_mc.gotoAndStop("hide");
projectileOver = false;
projectileOnScreen = false;
intState = 1;
}
function ExitGame() {
CleanupGame();
Mouse.removeListener(mouseListener);
_root.messages_mc.swapDepths(saveDepth);
_global.latestLevel = -1;
_root.gotoAndPlay("level1");
}
function Next() {
_global.currentLevel = _global.currentLevel + 5;
CleanupGame();
_root.messages_mc.swapDepths(saveDepth);
_root.gotoAndPlay(_global.currentLevel);
}
function CleanupGame() {
Mouse.removeListener(mouseListener);
Reset();
var _local3 = 10;
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].swapDepths(_local3);
_local3++;
_root[arrParticles[_local2]].removeMovieClip();
_local2++;
}
delete arrParticles;
arrParticles = new Array();
}
function DetectParticleCollisions() {
var _local3 = new Array();
var _local2 = 0;
while (_local2 < arrParticles.length) {
var _local4 = (_root[arrParticles[_local2]]._width / 2) + 7.5;
if (GetDistance(arrParticles[_local2], "projectile") <= _local4) {
_root[arrParticles[_local2]].Collision(saveX, saveY);
_local3.push(arrParticles[_local2]);
}
_local2++;
}
_local2 = 0;
while (_local2 < _local3.length) {
RemoveParticle(_local3[_local2]);
_root[_local3[_local2]].gotoAndStop(2);
_local2++;
}
}
function RemoveParticle(strName) {
var _local1 = 0;
while (_local1 < arrParticles.length) {
if (strName == arrParticles[_local1]) {
arrParticles.splice(_local1, 1);
break;
}
_local1++;
}
}
function GetDistance(targetA, targetB) {
var _local3 = _root[targetB]._x - _root[targetA]._x;
var _local2 = _root[targetB]._y - _root[targetA]._y;
return(Math.sqrt((_local3 * _local3) + (_local2 * _local2)));
}
function RegisterParticle(particleName) {
arrParticles.push(particleName);
arrParticlesReset.push(particleName);
particleDepth++;
return(particleDepth);
}
function MoveProjectile() {
if (ProjectileOffScreen() == false) {
projectileOnScreen = true;
_root.projectile._x = _root.projectile._x + vecShootDir._x;
_root.projectile._y = _root.projectile._y + vecShootDir._y;
} else if (projectileOnScreen == true) {
projectileOver = true;
} else {
_root.projectile._x = _root.projectile._x + vecShootDir._x;
_root.projectile._y = _root.projectile._y + vecShootDir._y;
}
}
function AimProjectile() {
var _local11 = new Vector();
_local11._x = _xmouse - (Stage.width / 2);
_local11._y = _ymouse - (Stage.height / 2);
var _local12 = Math.atan2(_local11._y, _local11._x);
var _local15 = (360 * _local12) / (Math.PI*2);
var _local6 = _root.gameBackground._width / 2;
_root.projectile._x = (_local6 * Math.cos(_local12)) + (Stage.width / 2);
_root.projectile._y = (_local6 * Math.sin(_local12)) + (Stage.height / 2);
_local11._x = (Stage.width / 2) - _root.projectile._x;
_local11._y = (Stage.height / 2) - _root.projectile._y;
_local12 = Math.atan2(_local11._y, _local11._x);
var _local14 = Math.cos(_local12) * 11;
var _local13 = Math.sin(_local12) * 11;
var _local9 = _root.projectile._x;
var _local10 = _root.projectile._y;
var _local5 = new Array(arrParticles.length);
var _local4 = 0;
while (_local4 < _local5.length) {
_local5[_local4] = 0;
_local4++;
}
var _local8 = 0;
while (_local8 < 70) {
_local9 = _local9 + _local14;
_local10 = _local10 + _local13;
_local4 = 0;
while (_local4 < arrParticles.length) {
var _local7 = (_root[arrParticles[_local4]]._width / 2) + 7.5;
var _local3 = _root[arrParticles[_local4]]._x - _local9;
var _local2 = _root[arrParticles[_local4]]._y - _local10;
_local6 = Math.sqrt((_local3 * _local3) + (_local2 * _local2));
if (_local6 <= _local7) {
_local5[_local4] = 1;
}
_local4++;
}
_local8++;
}
_local4 = 0;
while (_local4 < _local5.length) {
if (_local5[_local4] == 1) {
_root[arrParticles[_local4]].ArrowsOn(arrowDepth, _root.projectile._x, _root.projectile._y);
} else {
_root[arrParticles[_local4]].ArrowsOff();
}
_local4++;
}
}
function TurnOffAllArrows() {
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].ArrowsOff();
_local2++;
}
}
function NextArrowDepth() {
arrowDepth++;
if (arrowDepth > 39999) {
arrowDepth = 15000;
}
}
function DrawLines() {
_root.clear();
_root.lineStyle(2, 16777215, 50);
var _local2 = new Object();
var _local3 = new Object();
_local2.x = _root.projectile._x;
_local2.y = _root.projectile._y;
_local3.x = _xmouse;
_local3.y = _ymouse;
_root.moveTo(_local2.x, _local2.y);
_root.lineTo(_local3.x, _local3.y);
}
function Shoot() {
if ((intState == 1) && (_global.latestLevel != -1)) {
trace("in");
_root.clear();
saveX = _root.projectile._x;
saveY = _root.projectile._y;
var _local4 = new Vector();
_local4._x = (Stage.width / 2) - _root.projectile._x;
_local4._y = (Stage.height / 2) - _root.projectile._y;
var _local5 = Math.atan2(_local4._y, _local4._x);
vecShootDir._x = Math.cos(_local5) * 11;
vecShootDir._y = Math.sin(_local5) * 11;
var _local3 = 100;
do {
if (ProjectileOffScreen() != false) {
break;
}
_root.projectile._x = _root.projectile._x - vecShootDir._x;
_root.projectile._y = _root.projectile._y - vecShootDir._y;
_local3--;
} while (_local3 != 0);
var _local6 = (360 * _local5) / (Math.PI*2);
_root.projectile.gotoAndStop(2);
_root.projectile._rotation = _local6;
_root.gameBackground.gotoAndPlay("hide");
TurnOffAllArrows();
intState = 2;
}
}
function ProjectileOffScreen() {
var _local2 = false;
if (((_root.projectile._x + _root.projectile._width) < 0) || ((_root.projectile._x - _root.projectile._width) > Stage.width)) {
_local2 = true;
}
if (((_root.projectile._y + _root.projectile._height) < 0) || ((_root.projectile._y - _root.projectile._height) > Stage.height)) {
_local2 = true;
}
return(_local2);
}
function MoveProjectilesAndCollide() {
var _local4 = 0;
while (_local4 < arrProjectiles.length) {
_root[arrProjectiles[_local4].name]._x = _root[arrProjectiles[_local4].name]._x + (arrProjectiles[_local4].dX / 2);
_root[arrProjectiles[_local4].name]._y = _root[arrProjectiles[_local4].name]._y + (arrProjectiles[_local4].dY / 2);
if (((_root[arrProjectiles[_local4].name]._x + _root[arrProjectiles[_local4].name]._width) < 0) || ((_root[arrProjectiles[_local4].name]._x - _root[arrProjectiles[_local4].name]._width) > Stage.width)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
if (((_root[arrProjectiles[_local4].name]._y + _root[arrProjectiles[_local4].name]._height) < 0) || ((_root[arrProjectiles[_local4].name]._y - _root[arrProjectiles[_local4].name]._height) > Stage.height)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
_local4++;
}
var _local5 = new Array();
var _local3 = 0;
while (_local3 < arrProjectiles.length) {
_local4 = 0;
while (_local4 < arrParticles.length) {
if (_root[arrParticles[_local4]].hitTest(_root[arrProjectiles[_local3].name]._x, _root[arrProjectiles[_local3].name]._y, true) == true) {
_local5.push({name:arrParticles[_local4], X:arrProjectiles[_local3].X, Y:arrProjectiles[_local3].Y});
arrParticles.splice(_local4, 1);
_local4--;
_root[arrProjectiles[_local3].name].removeMovieClip();
arrProjectiles.splice(_local3, 1);
_local3--;
}
_local4++;
}
_local3++;
}
_local4 = 0;
while (_local4 < _local5.length) {
_root[_local5[_local4].name].Collision(_local5[_local4].X, _local5[_local4].Y);
_root[_local5[_local4].name].gotoAndStop(2);
_local4++;
}
_local4 = 0;
while (_local4 < arrProjectiles.length) {
_root[arrProjectiles[_local4].name]._x = _root[arrProjectiles[_local4].name]._x + (arrProjectiles[_local4].dX / 2);
_root[arrProjectiles[_local4].name]._y = _root[arrProjectiles[_local4].name]._y + (arrProjectiles[_local4].dY / 2);
if (((_root[arrProjectiles[_local4].name]._x + _root[arrProjectiles[_local4].name]._width) < 0) || ((_root[arrProjectiles[_local4].name]._x - _root[arrProjectiles[_local4].name]._width) > Stage.width)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
if (((_root[arrProjectiles[_local4].name]._y + _root[arrProjectiles[_local4].name]._height) < 0) || ((_root[arrProjectiles[_local4].name]._y - _root[arrProjectiles[_local4].name]._height) > Stage.height)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
_local4++;
}
_local5 = new Array();
_local3 = 0;
while (_local3 < arrProjectiles.length) {
_local4 = 0;
while (_local4 < arrParticles.length) {
if (_root[arrParticles[_local4]].hitTest(_root[arrProjectiles[_local3].name]._x, _root[arrProjectiles[_local3].name]._y, true) == true) {
_local5.push({name:arrParticles[_local4], X:arrProjectiles[_local3].X, Y:arrProjectiles[_local3].Y});
arrParticles.splice(_local4, 1);
_local4--;
_root[arrProjectiles[_local3].name].removeMovieClip();
arrProjectiles.splice(_local3, 1);
_local3--;
}
_local4++;
}
_local3++;
}
_local4 = 0;
while (_local4 < _local5.length) {
_root[_local5[_local4].name].Collision(_local5[_local4].X, _local5[_local4].Y);
_root[_local5[_local4].name].gotoAndStop(2);
_local4++;
}
if ((arrProjectiles.length == 0) && (projectileOver == true)) {
if (arrParticles.length != 0) {
intState = 3;
_root.messages_mc.gotoAndPlay("retry");
} else {
intState = 4;
var _local10 = ((_global.currentLevel + 5) - 15) / 5;
_global.levels[_local10] = 1;
var _local9 = SharedObject.getLocal("userData");
_local9.data.levelsCompleted = _global.levels;
_global.SoundManager.PlaySound("all");
_root.messages_mc.gotoAndPlay("next");
}
}
}
function LaunchProjectile(deltaX, deltaY, startX, startY, rot) {
var _local2 = "projectile_" + projectileDepth;
arrProjectiles.push({name:_local2, dX:deltaX, dY:deltaY, X:startX, Y:startY});
_root.attachMovie("shootingStar", _local2, projectileDepth);
_root[_local2]._x = startX;
_root[_local2]._y = startY;
_root[_local2]._rotation = rot;
projectileDepth++;
if (projectileDepth > 9999) {
projectileDepth = 5000;
}
}
stop();
var intState = 1;
var vecShootDir;
var arrParticles = new Array();
var arrProjectiles = new Array();
var arrParticlesReset = new Array();
var particleDepth = 1000;
var projectileDepth = 5000;
var arrowDepth = 15000;
var saveX = 0;
var saveY = 0;
var projectileOnScreen = false;
var projectileOver = false;
var saveDepth;
mouseListener = new Object();
mouseListener.onMouseDown = function () {
_root.Shoot();
};
Mouse.addListener(mouseListener);
Instance of Symbol 32 MovieClip in Frame 35
onClipEvent (load) {
_root.GameSetup();
}
onClipEvent (enterFrame) {
_root.Mediator();
}
Frame 40
function GameSetup() {
trace("%%%%%%%%");
trace((_global.currentLevel + " ----- ") + _global.latestLevel);
if (_global.latestLevel == -1) {
_root.gotoAndPlay("splash");
} else if ((_global.latestLevel != 0) && (_global.latestLevel != 20)) {
_global.currentLevel = _global.latestLevel;
_root.gotoAndPlay(_global.latestLevel);
_global.latestLevel = 0;
trace("go here");
} else if ((_global.latestLevel != 0) && (_global.latestLevel == 20)) {
_global.currentLevel = _global.latestLevel;
_global.latestLevel = 0;
}
if (_root.messages_mc.getDepth() != 50000) {
saveDepth = _root.messages_mc.getDepth();
}
vecShootDir = new Vector();
if (_global.musicOn == true) {
_global.myMusicPlayer.SetTrack("game");
_global.myMusicPlayer.SetMaxVolume(40);
_global.myMusicPlayer.PlayWithCrossFade(4);
}
}
function Mediator() {
_global.myMusicPlayer.RunPlayer();
switch (intState) {
case 1 :
AimProjectile();
if (_root.messages_mc.getDepth() != 50000) {
_root.messages_mc.swapDepths(50000);
trace(_root.messages_mc.getDepth());
}
break;
case 2 :
if (projectileOver == false) {
MoveProjectile();
}
DetectParticleCollisions();
MoveProjectilesAndCollide();
break;
case 3 :
if (Key.isDown(32)) {
Reset();
}
break;
case 4 :
if (!Key.isDown(32)) {
break;
}
Next();
}
}
function Reset() {
projectileDepth = 5000;
arrParticles = arrParticlesReset.slice();
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].gotoAndStop(1);
trace(arrParticles[_local2]);
_local2++;
}
trace("-----");
_root.projectile.gotoAndStop(1);
_root.gameBackground.gotoAndStop(1);
_root.messages_mc.gotoAndStop("hide");
projectileOver = false;
projectileOnScreen = false;
intState = 1;
}
function ExitGame() {
CleanupGame();
Mouse.removeListener(mouseListener);
_root.messages_mc.swapDepths(saveDepth);
_global.latestLevel = -1;
_root.gotoAndPlay("level1");
}
function Next() {
_global.currentLevel = _global.currentLevel + 5;
CleanupGame();
_root.messages_mc.swapDepths(saveDepth);
_root.gotoAndPlay(_global.currentLevel);
}
function CleanupGame() {
Mouse.removeListener(mouseListener);
Reset();
var _local3 = 10;
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].swapDepths(_local3);
_local3++;
_root[arrParticles[_local2]].removeMovieClip();
_local2++;
}
delete arrParticles;
arrParticles = new Array();
}
function DetectParticleCollisions() {
var _local3 = new Array();
var _local2 = 0;
while (_local2 < arrParticles.length) {
var _local4 = (_root[arrParticles[_local2]]._width / 2) + 7.5;
if (GetDistance(arrParticles[_local2], "projectile") <= _local4) {
_root[arrParticles[_local2]].Collision(saveX, saveY);
_local3.push(arrParticles[_local2]);
}
_local2++;
}
_local2 = 0;
while (_local2 < _local3.length) {
RemoveParticle(_local3[_local2]);
_root[_local3[_local2]].gotoAndStop(2);
_local2++;
}
}
function RemoveParticle(strName) {
var _local1 = 0;
while (_local1 < arrParticles.length) {
if (strName == arrParticles[_local1]) {
arrParticles.splice(_local1, 1);
break;
}
_local1++;
}
}
function GetDistance(targetA, targetB) {
var _local3 = _root[targetB]._x - _root[targetA]._x;
var _local2 = _root[targetB]._y - _root[targetA]._y;
return(Math.sqrt((_local3 * _local3) + (_local2 * _local2)));
}
function RegisterParticle(particleName) {
arrParticles.push(particleName);
arrParticlesReset.push(particleName);
particleDepth++;
return(particleDepth);
}
function MoveProjectile() {
if (ProjectileOffScreen() == false) {
projectileOnScreen = true;
_root.projectile._x = _root.projectile._x + vecShootDir._x;
_root.projectile._y = _root.projectile._y + vecShootDir._y;
} else if (projectileOnScreen == true) {
projectileOver = true;
} else {
_root.projectile._x = _root.projectile._x + vecShootDir._x;
_root.projectile._y = _root.projectile._y + vecShootDir._y;
}
}
function AimProjectile() {
var _local11 = new Vector();
_local11._x = _xmouse - (Stage.width / 2);
_local11._y = _ymouse - (Stage.height / 2);
var _local12 = Math.atan2(_local11._y, _local11._x);
var _local15 = (360 * _local12) / (Math.PI*2);
var _local6 = _root.gameBackground._width / 2;
_root.projectile._x = (_local6 * Math.cos(_local12)) + (Stage.width / 2);
_root.projectile._y = (_local6 * Math.sin(_local12)) + (Stage.height / 2);
_local11._x = (Stage.width / 2) - _root.projectile._x;
_local11._y = (Stage.height / 2) - _root.projectile._y;
_local12 = Math.atan2(_local11._y, _local11._x);
var _local14 = Math.cos(_local12) * 11;
var _local13 = Math.sin(_local12) * 11;
var _local9 = _root.projectile._x;
var _local10 = _root.projectile._y;
var _local5 = new Array(arrParticles.length);
var _local4 = 0;
while (_local4 < _local5.length) {
_local5[_local4] = 0;
_local4++;
}
var _local8 = 0;
while (_local8 < 70) {
_local9 = _local9 + _local14;
_local10 = _local10 + _local13;
_local4 = 0;
while (_local4 < arrParticles.length) {
var _local7 = (_root[arrParticles[_local4]]._width / 2) + 7.5;
var _local3 = _root[arrParticles[_local4]]._x - _local9;
var _local2 = _root[arrParticles[_local4]]._y - _local10;
_local6 = Math.sqrt((_local3 * _local3) + (_local2 * _local2));
if (_local6 <= _local7) {
_local5[_local4] = 1;
}
_local4++;
}
_local8++;
}
_local4 = 0;
while (_local4 < _local5.length) {
if (_local5[_local4] == 1) {
_root[arrParticles[_local4]].ArrowsOn(arrowDepth, _root.projectile._x, _root.projectile._y);
} else {
_root[arrParticles[_local4]].ArrowsOff();
}
_local4++;
}
}
function TurnOffAllArrows() {
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].ArrowsOff();
_local2++;
}
}
function NextArrowDepth() {
arrowDepth++;
if (arrowDepth > 39999) {
arrowDepth = 15000;
}
}
function DrawLines() {
_root.clear();
_root.lineStyle(2, 16777215, 50);
var _local2 = new Object();
var _local3 = new Object();
_local2.x = _root.projectile._x;
_local2.y = _root.projectile._y;
_local3.x = _xmouse;
_local3.y = _ymouse;
_root.moveTo(_local2.x, _local2.y);
_root.lineTo(_local3.x, _local3.y);
}
function Shoot() {
if ((intState == 1) && (_global.latestLevel != -1)) {
trace("in");
_root.clear();
saveX = _root.projectile._x;
saveY = _root.projectile._y;
var _local4 = new Vector();
_local4._x = (Stage.width / 2) - _root.projectile._x;
_local4._y = (Stage.height / 2) - _root.projectile._y;
var _local5 = Math.atan2(_local4._y, _local4._x);
vecShootDir._x = Math.cos(_local5) * 11;
vecShootDir._y = Math.sin(_local5) * 11;
var _local3 = 100;
do {
if (ProjectileOffScreen() != false) {
break;
}
_root.projectile._x = _root.projectile._x - vecShootDir._x;
_root.projectile._y = _root.projectile._y - vecShootDir._y;
_local3--;
} while (_local3 != 0);
var _local6 = (360 * _local5) / (Math.PI*2);
_root.projectile.gotoAndStop(2);
_root.projectile._rotation = _local6;
_root.gameBackground.gotoAndPlay("hide");
TurnOffAllArrows();
intState = 2;
}
}
function ProjectileOffScreen() {
var _local2 = false;
if (((_root.projectile._x + _root.projectile._width) < 0) || ((_root.projectile._x - _root.projectile._width) > Stage.width)) {
_local2 = true;
}
if (((_root.projectile._y + _root.projectile._height) < 0) || ((_root.projectile._y - _root.projectile._height) > Stage.height)) {
_local2 = true;
}
return(_local2);
}
function MoveProjectilesAndCollide() {
var _local4 = 0;
while (_local4 < arrProjectiles.length) {
_root[arrProjectiles[_local4].name]._x = _root[arrProjectiles[_local4].name]._x + (arrProjectiles[_local4].dX / 2);
_root[arrProjectiles[_local4].name]._y = _root[arrProjectiles[_local4].name]._y + (arrProjectiles[_local4].dY / 2);
if (((_root[arrProjectiles[_local4].name]._x + _root[arrProjectiles[_local4].name]._width) < 0) || ((_root[arrProjectiles[_local4].name]._x - _root[arrProjectiles[_local4].name]._width) > Stage.width)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
if (((_root[arrProjectiles[_local4].name]._y + _root[arrProjectiles[_local4].name]._height) < 0) || ((_root[arrProjectiles[_local4].name]._y - _root[arrProjectiles[_local4].name]._height) > Stage.height)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
_local4++;
}
var _local5 = new Array();
var _local3 = 0;
while (_local3 < arrProjectiles.length) {
_local4 = 0;
while (_local4 < arrParticles.length) {
if (_root[arrParticles[_local4]].hitTest(_root[arrProjectiles[_local3].name]._x, _root[arrProjectiles[_local3].name]._y, true) == true) {
_local5.push({name:arrParticles[_local4], X:arrProjectiles[_local3].X, Y:arrProjectiles[_local3].Y});
arrParticles.splice(_local4, 1);
_local4--;
_root[arrProjectiles[_local3].name].removeMovieClip();
arrProjectiles.splice(_local3, 1);
_local3--;
}
_local4++;
}
_local3++;
}
_local4 = 0;
while (_local4 < _local5.length) {
_root[_local5[_local4].name].Collision(_local5[_local4].X, _local5[_local4].Y);
_root[_local5[_local4].name].gotoAndStop(2);
_local4++;
}
_local4 = 0;
while (_local4 < arrProjectiles.length) {
_root[arrProjectiles[_local4].name]._x = _root[arrProjectiles[_local4].name]._x + (arrProjectiles[_local4].dX / 2);
_root[arrProjectiles[_local4].name]._y = _root[arrProjectiles[_local4].name]._y + (arrProjectiles[_local4].dY / 2);
if (((_root[arrProjectiles[_local4].name]._x + _root[arrProjectiles[_local4].name]._width) < 0) || ((_root[arrProjectiles[_local4].name]._x - _root[arrProjectiles[_local4].name]._width) > Stage.width)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
if (((_root[arrProjectiles[_local4].name]._y + _root[arrProjectiles[_local4].name]._height) < 0) || ((_root[arrProjectiles[_local4].name]._y - _root[arrProjectiles[_local4].name]._height) > Stage.height)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
_local4++;
}
_local5 = new Array();
_local3 = 0;
while (_local3 < arrProjectiles.length) {
_local4 = 0;
while (_local4 < arrParticles.length) {
if (_root[arrParticles[_local4]].hitTest(_root[arrProjectiles[_local3].name]._x, _root[arrProjectiles[_local3].name]._y, true) == true) {
_local5.push({name:arrParticles[_local4], X:arrProjectiles[_local3].X, Y:arrProjectiles[_local3].Y});
arrParticles.splice(_local4, 1);
_local4--;
_root[arrProjectiles[_local3].name].removeMovieClip();
arrProjectiles.splice(_local3, 1);
_local3--;
}
_local4++;
}
_local3++;
}
_local4 = 0;
while (_local4 < _local5.length) {
_root[_local5[_local4].name].Collision(_local5[_local4].X, _local5[_local4].Y);
_root[_local5[_local4].name].gotoAndStop(2);
_local4++;
}
if ((arrProjectiles.length == 0) && (projectileOver == true)) {
if (arrParticles.length != 0) {
intState = 3;
_root.messages_mc.gotoAndPlay("retry");
} else {
intState = 4;
var _local10 = ((_global.currentLevel + 5) - 15) / 5;
_global.levels[_local10] = 1;
var _local9 = SharedObject.getLocal("userData");
_local9.data.levelsCompleted = _global.levels;
_global.SoundManager.PlaySound("all");
_root.messages_mc.gotoAndPlay("next");
}
}
}
function LaunchProjectile(deltaX, deltaY, startX, startY, rot) {
var _local2 = "projectile_" + projectileDepth;
arrProjectiles.push({name:_local2, dX:deltaX, dY:deltaY, X:startX, Y:startY});
_root.attachMovie("shootingStar", _local2, projectileDepth);
_root[_local2]._x = startX;
_root[_local2]._y = startY;
_root[_local2]._rotation = rot;
projectileDepth++;
if (projectileDepth > 9999) {
projectileDepth = 5000;
}
}
stop();
var intState = 1;
var vecShootDir;
var arrParticles = new Array();
var arrProjectiles = new Array();
var arrParticlesReset = new Array();
var particleDepth = 1000;
var projectileDepth = 5000;
var arrowDepth = 15000;
var saveX = 0;
var saveY = 0;
var projectileOnScreen = false;
var projectileOver = false;
var saveDepth;
mouseListener = new Object();
mouseListener.onMouseDown = function () {
_root.Shoot();
};
Mouse.addListener(mouseListener);
Instance of Symbol 32 MovieClip in Frame 40
onClipEvent (load) {
_root.GameSetup();
}
onClipEvent (enterFrame) {
_root.Mediator();
}
Frame 45
function GameSetup() {
trace("%%%%%%%%");
trace((_global.currentLevel + " ----- ") + _global.latestLevel);
if (_global.latestLevel == -1) {
_root.gotoAndPlay("splash");
} else if ((_global.latestLevel != 0) && (_global.latestLevel != 20)) {
_global.currentLevel = _global.latestLevel;
_root.gotoAndPlay(_global.latestLevel);
_global.latestLevel = 0;
trace("go here");
} else if ((_global.latestLevel != 0) && (_global.latestLevel == 20)) {
_global.currentLevel = _global.latestLevel;
_global.latestLevel = 0;
}
if (_root.messages_mc.getDepth() != 50000) {
saveDepth = _root.messages_mc.getDepth();
}
vecShootDir = new Vector();
if (_global.musicOn == true) {
_global.myMusicPlayer.SetTrack("game");
_global.myMusicPlayer.SetMaxVolume(40);
_global.myMusicPlayer.PlayWithCrossFade(4);
}
}
function Mediator() {
_global.myMusicPlayer.RunPlayer();
switch (intState) {
case 1 :
AimProjectile();
if (_root.messages_mc.getDepth() != 50000) {
_root.messages_mc.swapDepths(50000);
trace(_root.messages_mc.getDepth());
}
break;
case 2 :
if (projectileOver == false) {
MoveProjectile();
}
DetectParticleCollisions();
MoveProjectilesAndCollide();
break;
case 3 :
if (Key.isDown(32)) {
Reset();
}
break;
case 4 :
if (!Key.isDown(32)) {
break;
}
Next();
}
}
function Reset() {
projectileDepth = 5000;
arrParticles = arrParticlesReset.slice();
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].gotoAndStop(1);
trace(arrParticles[_local2]);
_local2++;
}
trace("-----");
_root.projectile.gotoAndStop(1);
_root.gameBackground.gotoAndStop(1);
_root.messages_mc.gotoAndStop("hide");
projectileOver = false;
projectileOnScreen = false;
intState = 1;
}
function ExitGame() {
CleanupGame();
Mouse.removeListener(mouseListener);
_root.messages_mc.swapDepths(saveDepth);
_global.latestLevel = -1;
_root.gotoAndPlay("level1");
}
function Next() {
_global.currentLevel = _global.currentLevel + 5;
CleanupGame();
_root.messages_mc.swapDepths(saveDepth);
_root.gotoAndPlay(_global.currentLevel);
}
function CleanupGame() {
Mouse.removeListener(mouseListener);
Reset();
var _local3 = 10;
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].swapDepths(_local3);
_local3++;
_root[arrParticles[_local2]].removeMovieClip();
_local2++;
}
delete arrParticles;
arrParticles = new Array();
}
function DetectParticleCollisions() {
var _local3 = new Array();
var _local2 = 0;
while (_local2 < arrParticles.length) {
var _local4 = (_root[arrParticles[_local2]]._width / 2) + 7.5;
if (GetDistance(arrParticles[_local2], "projectile") <= _local4) {
_root[arrParticles[_local2]].Collision(saveX, saveY);
_local3.push(arrParticles[_local2]);
}
_local2++;
}
_local2 = 0;
while (_local2 < _local3.length) {
RemoveParticle(_local3[_local2]);
_root[_local3[_local2]].gotoAndStop(2);
_local2++;
}
}
function RemoveParticle(strName) {
var _local1 = 0;
while (_local1 < arrParticles.length) {
if (strName == arrParticles[_local1]) {
arrParticles.splice(_local1, 1);
break;
}
_local1++;
}
}
function GetDistance(targetA, targetB) {
var _local3 = _root[targetB]._x - _root[targetA]._x;
var _local2 = _root[targetB]._y - _root[targetA]._y;
return(Math.sqrt((_local3 * _local3) + (_local2 * _local2)));
}
function RegisterParticle(particleName) {
arrParticles.push(particleName);
arrParticlesReset.push(particleName);
particleDepth++;
return(particleDepth);
}
function MoveProjectile() {
if (ProjectileOffScreen() == false) {
projectileOnScreen = true;
_root.projectile._x = _root.projectile._x + vecShootDir._x;
_root.projectile._y = _root.projectile._y + vecShootDir._y;
} else if (projectileOnScreen == true) {
projectileOver = true;
} else {
_root.projectile._x = _root.projectile._x + vecShootDir._x;
_root.projectile._y = _root.projectile._y + vecShootDir._y;
}
}
function AimProjectile() {
var _local11 = new Vector();
_local11._x = _xmouse - (Stage.width / 2);
_local11._y = _ymouse - (Stage.height / 2);
var _local12 = Math.atan2(_local11._y, _local11._x);
var _local15 = (360 * _local12) / (Math.PI*2);
var _local6 = _root.gameBackground._width / 2;
_root.projectile._x = (_local6 * Math.cos(_local12)) + (Stage.width / 2);
_root.projectile._y = (_local6 * Math.sin(_local12)) + (Stage.height / 2);
_local11._x = (Stage.width / 2) - _root.projectile._x;
_local11._y = (Stage.height / 2) - _root.projectile._y;
_local12 = Math.atan2(_local11._y, _local11._x);
var _local14 = Math.cos(_local12) * 11;
var _local13 = Math.sin(_local12) * 11;
var _local9 = _root.projectile._x;
var _local10 = _root.projectile._y;
var _local5 = new Array(arrParticles.length);
var _local4 = 0;
while (_local4 < _local5.length) {
_local5[_local4] = 0;
_local4++;
}
var _local8 = 0;
while (_local8 < 70) {
_local9 = _local9 + _local14;
_local10 = _local10 + _local13;
_local4 = 0;
while (_local4 < arrParticles.length) {
var _local7 = (_root[arrParticles[_local4]]._width / 2) + 7.5;
var _local3 = _root[arrParticles[_local4]]._x - _local9;
var _local2 = _root[arrParticles[_local4]]._y - _local10;
_local6 = Math.sqrt((_local3 * _local3) + (_local2 * _local2));
if (_local6 <= _local7) {
_local5[_local4] = 1;
}
_local4++;
}
_local8++;
}
_local4 = 0;
while (_local4 < _local5.length) {
if (_local5[_local4] == 1) {
_root[arrParticles[_local4]].ArrowsOn(arrowDepth, _root.projectile._x, _root.projectile._y);
} else {
_root[arrParticles[_local4]].ArrowsOff();
}
_local4++;
}
}
function TurnOffAllArrows() {
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].ArrowsOff();
_local2++;
}
}
function NextArrowDepth() {
arrowDepth++;
if (arrowDepth > 39999) {
arrowDepth = 15000;
}
}
function DrawLines() {
_root.clear();
_root.lineStyle(2, 16777215, 50);
var _local2 = new Object();
var _local3 = new Object();
_local2.x = _root.projectile._x;
_local2.y = _root.projectile._y;
_local3.x = _xmouse;
_local3.y = _ymouse;
_root.moveTo(_local2.x, _local2.y);
_root.lineTo(_local3.x, _local3.y);
}
function Shoot() {
if ((intState == 1) && (_global.latestLevel != -1)) {
trace("in");
_root.clear();
saveX = _root.projectile._x;
saveY = _root.projectile._y;
var _local4 = new Vector();
_local4._x = (Stage.width / 2) - _root.projectile._x;
_local4._y = (Stage.height / 2) - _root.projectile._y;
var _local5 = Math.atan2(_local4._y, _local4._x);
vecShootDir._x = Math.cos(_local5) * 11;
vecShootDir._y = Math.sin(_local5) * 11;
var _local3 = 100;
do {
if (ProjectileOffScreen() != false) {
break;
}
_root.projectile._x = _root.projectile._x - vecShootDir._x;
_root.projectile._y = _root.projectile._y - vecShootDir._y;
_local3--;
} while (_local3 != 0);
var _local6 = (360 * _local5) / (Math.PI*2);
_root.projectile.gotoAndStop(2);
_root.projectile._rotation = _local6;
_root.gameBackground.gotoAndPlay("hide");
TurnOffAllArrows();
intState = 2;
}
}
function ProjectileOffScreen() {
var _local2 = false;
if (((_root.projectile._x + _root.projectile._width) < 0) || ((_root.projectile._x - _root.projectile._width) > Stage.width)) {
_local2 = true;
}
if (((_root.projectile._y + _root.projectile._height) < 0) || ((_root.projectile._y - _root.projectile._height) > Stage.height)) {
_local2 = true;
}
return(_local2);
}
function MoveProjectilesAndCollide() {
var _local4 = 0;
while (_local4 < arrProjectiles.length) {
_root[arrProjectiles[_local4].name]._x = _root[arrProjectiles[_local4].name]._x + (arrProjectiles[_local4].dX / 2);
_root[arrProjectiles[_local4].name]._y = _root[arrProjectiles[_local4].name]._y + (arrProjectiles[_local4].dY / 2);
if (((_root[arrProjectiles[_local4].name]._x + _root[arrProjectiles[_local4].name]._width) < 0) || ((_root[arrProjectiles[_local4].name]._x - _root[arrProjectiles[_local4].name]._width) > Stage.width)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
if (((_root[arrProjectiles[_local4].name]._y + _root[arrProjectiles[_local4].name]._height) < 0) || ((_root[arrProjectiles[_local4].name]._y - _root[arrProjectiles[_local4].name]._height) > Stage.height)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
_local4++;
}
var _local5 = new Array();
var _local3 = 0;
while (_local3 < arrProjectiles.length) {
_local4 = 0;
while (_local4 < arrParticles.length) {
if (_root[arrParticles[_local4]].hitTest(_root[arrProjectiles[_local3].name]._x, _root[arrProjectiles[_local3].name]._y, true) == true) {
_local5.push({name:arrParticles[_local4], X:arrProjectiles[_local3].X, Y:arrProjectiles[_local3].Y});
arrParticles.splice(_local4, 1);
_local4--;
_root[arrProjectiles[_local3].name].removeMovieClip();
arrProjectiles.splice(_local3, 1);
_local3--;
}
_local4++;
}
_local3++;
}
_local4 = 0;
while (_local4 < _local5.length) {
_root[_local5[_local4].name].Collision(_local5[_local4].X, _local5[_local4].Y);
_root[_local5[_local4].name].gotoAndStop(2);
_local4++;
}
_local4 = 0;
while (_local4 < arrProjectiles.length) {
_root[arrProjectiles[_local4].name]._x = _root[arrProjectiles[_local4].name]._x + (arrProjectiles[_local4].dX / 2);
_root[arrProjectiles[_local4].name]._y = _root[arrProjectiles[_local4].name]._y + (arrProjectiles[_local4].dY / 2);
if (((_root[arrProjectiles[_local4].name]._x + _root[arrProjectiles[_local4].name]._width) < 0) || ((_root[arrProjectiles[_local4].name]._x - _root[arrProjectiles[_local4].name]._width) > Stage.width)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
if (((_root[arrProjectiles[_local4].name]._y + _root[arrProjectiles[_local4].name]._height) < 0) || ((_root[arrProjectiles[_local4].name]._y - _root[arrProjectiles[_local4].name]._height) > Stage.height)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
_local4++;
}
_local5 = new Array();
_local3 = 0;
while (_local3 < arrProjectiles.length) {
_local4 = 0;
while (_local4 < arrParticles.length) {
if (_root[arrParticles[_local4]].hitTest(_root[arrProjectiles[_local3].name]._x, _root[arrProjectiles[_local3].name]._y, true) == true) {
_local5.push({name:arrParticles[_local4], X:arrProjectiles[_local3].X, Y:arrProjectiles[_local3].Y});
arrParticles.splice(_local4, 1);
_local4--;
_root[arrProjectiles[_local3].name].removeMovieClip();
arrProjectiles.splice(_local3, 1);
_local3--;
}
_local4++;
}
_local3++;
}
_local4 = 0;
while (_local4 < _local5.length) {
_root[_local5[_local4].name].Collision(_local5[_local4].X, _local5[_local4].Y);
_root[_local5[_local4].name].gotoAndStop(2);
_local4++;
}
if ((arrProjectiles.length == 0) && (projectileOver == true)) {
if (arrParticles.length != 0) {
intState = 3;
_root.messages_mc.gotoAndPlay("retry");
} else {
intState = 4;
var _local10 = ((_global.currentLevel + 5) - 15) / 5;
_global.levels[_local10] = 1;
var _local9 = SharedObject.getLocal("userData");
_local9.data.levelsCompleted = _global.levels;
_global.SoundManager.PlaySound("all");
_root.messages_mc.gotoAndPlay("next");
}
}
}
function LaunchProjectile(deltaX, deltaY, startX, startY, rot) {
var _local2 = "projectile_" + projectileDepth;
arrProjectiles.push({name:_local2, dX:deltaX, dY:deltaY, X:startX, Y:startY});
_root.attachMovie("shootingStar", _local2, projectileDepth);
_root[_local2]._x = startX;
_root[_local2]._y = startY;
_root[_local2]._rotation = rot;
projectileDepth++;
if (projectileDepth > 9999) {
projectileDepth = 5000;
}
}
stop();
var intState = 1;
var vecShootDir;
var arrParticles = new Array();
var arrProjectiles = new Array();
var arrParticlesReset = new Array();
var particleDepth = 1000;
var projectileDepth = 5000;
var arrowDepth = 15000;
var saveX = 0;
var saveY = 0;
var projectileOnScreen = false;
var projectileOver = false;
var saveDepth;
mouseListener = new Object();
mouseListener.onMouseDown = function () {
_root.Shoot();
};
Mouse.addListener(mouseListener);
Instance of Symbol 32 MovieClip in Frame 45
onClipEvent (load) {
_root.GameSetup();
}
onClipEvent (enterFrame) {
_root.Mediator();
}
Frame 50
function GameSetup() {
trace("%%%%%%%%");
trace((_global.currentLevel + " ----- ") + _global.latestLevel);
if (_global.latestLevel == -1) {
_root.gotoAndPlay("splash");
} else if ((_global.latestLevel != 0) && (_global.latestLevel != 20)) {
_global.currentLevel = _global.latestLevel;
_root.gotoAndPlay(_global.latestLevel);
_global.latestLevel = 0;
trace("go here");
} else if ((_global.latestLevel != 0) && (_global.latestLevel == 20)) {
_global.currentLevel = _global.latestLevel;
_global.latestLevel = 0;
}
if (_root.messages_mc.getDepth() != 50000) {
saveDepth = _root.messages_mc.getDepth();
}
vecShootDir = new Vector();
if (_global.musicOn == true) {
_global.myMusicPlayer.SetTrack("game");
_global.myMusicPlayer.SetMaxVolume(40);
_global.myMusicPlayer.PlayWithCrossFade(4);
}
}
function Mediator() {
_global.myMusicPlayer.RunPlayer();
switch (intState) {
case 1 :
AimProjectile();
if (_root.messages_mc.getDepth() != 50000) {
_root.messages_mc.swapDepths(50000);
trace(_root.messages_mc.getDepth());
}
break;
case 2 :
if (projectileOver == false) {
MoveProjectile();
}
DetectParticleCollisions();
MoveProjectilesAndCollide();
break;
case 3 :
if (Key.isDown(32)) {
Reset();
}
break;
case 4 :
if (!Key.isDown(32)) {
break;
}
Next();
}
}
function Reset() {
projectileDepth = 5000;
arrParticles = arrParticlesReset.slice();
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].gotoAndStop(1);
trace(arrParticles[_local2]);
_local2++;
}
trace("-----");
_root.projectile.gotoAndStop(1);
_root.gameBackground.gotoAndStop(1);
_root.messages_mc.gotoAndStop("hide");
projectileOver = false;
projectileOnScreen = false;
intState = 1;
}
function ExitGame() {
CleanupGame();
Mouse.removeListener(mouseListener);
_root.messages_mc.swapDepths(saveDepth);
_global.latestLevel = -1;
_root.gotoAndPlay("level1");
}
function Next() {
_global.currentLevel = _global.currentLevel + 5;
CleanupGame();
_root.messages_mc.swapDepths(saveDepth);
_root.gotoAndPlay(_global.currentLevel);
}
function CleanupGame() {
Mouse.removeListener(mouseListener);
Reset();
var _local3 = 10;
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].swapDepths(_local3);
_local3++;
_root[arrParticles[_local2]].removeMovieClip();
_local2++;
}
delete arrParticles;
arrParticles = new Array();
}
function DetectParticleCollisions() {
var _local3 = new Array();
var _local2 = 0;
while (_local2 < arrParticles.length) {
var _local4 = (_root[arrParticles[_local2]]._width / 2) + 7.5;
if (GetDistance(arrParticles[_local2], "projectile") <= _local4) {
_root[arrParticles[_local2]].Collision(saveX, saveY);
_local3.push(arrParticles[_local2]);
}
_local2++;
}
_local2 = 0;
while (_local2 < _local3.length) {
RemoveParticle(_local3[_local2]);
_root[_local3[_local2]].gotoAndStop(2);
_local2++;
}
}
function RemoveParticle(strName) {
var _local1 = 0;
while (_local1 < arrParticles.length) {
if (strName == arrParticles[_local1]) {
arrParticles.splice(_local1, 1);
break;
}
_local1++;
}
}
function GetDistance(targetA, targetB) {
var _local3 = _root[targetB]._x - _root[targetA]._x;
var _local2 = _root[targetB]._y - _root[targetA]._y;
return(Math.sqrt((_local3 * _local3) + (_local2 * _local2)));
}
function RegisterParticle(particleName) {
arrParticles.push(particleName);
arrParticlesReset.push(particleName);
particleDepth++;
return(particleDepth);
}
function MoveProjectile() {
if (ProjectileOffScreen() == false) {
projectileOnScreen = true;
_root.projectile._x = _root.projectile._x + vecShootDir._x;
_root.projectile._y = _root.projectile._y + vecShootDir._y;
} else if (projectileOnScreen == true) {
projectileOver = true;
} else {
_root.projectile._x = _root.projectile._x + vecShootDir._x;
_root.projectile._y = _root.projectile._y + vecShootDir._y;
}
}
function AimProjectile() {
var _local11 = new Vector();
_local11._x = _xmouse - (Stage.width / 2);
_local11._y = _ymouse - (Stage.height / 2);
var _local12 = Math.atan2(_local11._y, _local11._x);
var _local15 = (360 * _local12) / (Math.PI*2);
var _local6 = _root.gameBackground._width / 2;
_root.projectile._x = (_local6 * Math.cos(_local12)) + (Stage.width / 2);
_root.projectile._y = (_local6 * Math.sin(_local12)) + (Stage.height / 2);
_local11._x = (Stage.width / 2) - _root.projectile._x;
_local11._y = (Stage.height / 2) - _root.projectile._y;
_local12 = Math.atan2(_local11._y, _local11._x);
var _local14 = Math.cos(_local12) * 11;
var _local13 = Math.sin(_local12) * 11;
var _local9 = _root.projectile._x;
var _local10 = _root.projectile._y;
var _local5 = new Array(arrParticles.length);
var _local4 = 0;
while (_local4 < _local5.length) {
_local5[_local4] = 0;
_local4++;
}
var _local8 = 0;
while (_local8 < 70) {
_local9 = _local9 + _local14;
_local10 = _local10 + _local13;
_local4 = 0;
while (_local4 < arrParticles.length) {
var _local7 = (_root[arrParticles[_local4]]._width / 2) + 7.5;
var _local3 = _root[arrParticles[_local4]]._x - _local9;
var _local2 = _root[arrParticles[_local4]]._y - _local10;
_local6 = Math.sqrt((_local3 * _local3) + (_local2 * _local2));
if (_local6 <= _local7) {
_local5[_local4] = 1;
}
_local4++;
}
_local8++;
}
_local4 = 0;
while (_local4 < _local5.length) {
if (_local5[_local4] == 1) {
_root[arrParticles[_local4]].ArrowsOn(arrowDepth, _root.projectile._x, _root.projectile._y);
} else {
_root[arrParticles[_local4]].ArrowsOff();
}
_local4++;
}
}
function TurnOffAllArrows() {
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].ArrowsOff();
_local2++;
}
}
function NextArrowDepth() {
arrowDepth++;
if (arrowDepth > 39999) {
arrowDepth = 15000;
}
}
function DrawLines() {
_root.clear();
_root.lineStyle(2, 16777215, 50);
var _local2 = new Object();
var _local3 = new Object();
_local2.x = _root.projectile._x;
_local2.y = _root.projectile._y;
_local3.x = _xmouse;
_local3.y = _ymouse;
_root.moveTo(_local2.x, _local2.y);
_root.lineTo(_local3.x, _local3.y);
}
function Shoot() {
if ((intState == 1) && (_global.latestLevel != -1)) {
trace("in");
_root.clear();
saveX = _root.projectile._x;
saveY = _root.projectile._y;
var _local4 = new Vector();
_local4._x = (Stage.width / 2) - _root.projectile._x;
_local4._y = (Stage.height / 2) - _root.projectile._y;
var _local5 = Math.atan2(_local4._y, _local4._x);
vecShootDir._x = Math.cos(_local5) * 11;
vecShootDir._y = Math.sin(_local5) * 11;
var _local3 = 100;
do {
if (ProjectileOffScreen() != false) {
break;
}
_root.projectile._x = _root.projectile._x - vecShootDir._x;
_root.projectile._y = _root.projectile._y - vecShootDir._y;
_local3--;
} while (_local3 != 0);
var _local6 = (360 * _local5) / (Math.PI*2);
_root.projectile.gotoAndStop(2);
_root.projectile._rotation = _local6;
_root.gameBackground.gotoAndPlay("hide");
TurnOffAllArrows();
intState = 2;
}
}
function ProjectileOffScreen() {
var _local2 = false;
if (((_root.projectile._x + _root.projectile._width) < 0) || ((_root.projectile._x - _root.projectile._width) > Stage.width)) {
_local2 = true;
}
if (((_root.projectile._y + _root.projectile._height) < 0) || ((_root.projectile._y - _root.projectile._height) > Stage.height)) {
_local2 = true;
}
return(_local2);
}
function MoveProjectilesAndCollide() {
var _local4 = 0;
while (_local4 < arrProjectiles.length) {
_root[arrProjectiles[_local4].name]._x = _root[arrProjectiles[_local4].name]._x + (arrProjectiles[_local4].dX / 2);
_root[arrProjectiles[_local4].name]._y = _root[arrProjectiles[_local4].name]._y + (arrProjectiles[_local4].dY / 2);
if (((_root[arrProjectiles[_local4].name]._x + _root[arrProjectiles[_local4].name]._width) < 0) || ((_root[arrProjectiles[_local4].name]._x - _root[arrProjectiles[_local4].name]._width) > Stage.width)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
if (((_root[arrProjectiles[_local4].name]._y + _root[arrProjectiles[_local4].name]._height) < 0) || ((_root[arrProjectiles[_local4].name]._y - _root[arrProjectiles[_local4].name]._height) > Stage.height)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
_local4++;
}
var _local5 = new Array();
var _local3 = 0;
while (_local3 < arrProjectiles.length) {
_local4 = 0;
while (_local4 < arrParticles.length) {
if (_root[arrParticles[_local4]].hitTest(_root[arrProjectiles[_local3].name]._x, _root[arrProjectiles[_local3].name]._y, true) == true) {
_local5.push({name:arrParticles[_local4], X:arrProjectiles[_local3].X, Y:arrProjectiles[_local3].Y});
arrParticles.splice(_local4, 1);
_local4--;
_root[arrProjectiles[_local3].name].removeMovieClip();
arrProjectiles.splice(_local3, 1);
_local3--;
}
_local4++;
}
_local3++;
}
_local4 = 0;
while (_local4 < _local5.length) {
_root[_local5[_local4].name].Collision(_local5[_local4].X, _local5[_local4].Y);
_root[_local5[_local4].name].gotoAndStop(2);
_local4++;
}
_local4 = 0;
while (_local4 < arrProjectiles.length) {
_root[arrProjectiles[_local4].name]._x = _root[arrProjectiles[_local4].name]._x + (arrProjectiles[_local4].dX / 2);
_root[arrProjectiles[_local4].name]._y = _root[arrProjectiles[_local4].name]._y + (arrProjectiles[_local4].dY / 2);
if (((_root[arrProjectiles[_local4].name]._x + _root[arrProjectiles[_local4].name]._width) < 0) || ((_root[arrProjectiles[_local4].name]._x - _root[arrProjectiles[_local4].name]._width) > Stage.width)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
if (((_root[arrProjectiles[_local4].name]._y + _root[arrProjectiles[_local4].name]._height) < 0) || ((_root[arrProjectiles[_local4].name]._y - _root[arrProjectiles[_local4].name]._height) > Stage.height)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
_local4++;
}
_local5 = new Array();
_local3 = 0;
while (_local3 < arrProjectiles.length) {
_local4 = 0;
while (_local4 < arrParticles.length) {
if (_root[arrParticles[_local4]].hitTest(_root[arrProjectiles[_local3].name]._x, _root[arrProjectiles[_local3].name]._y, true) == true) {
_local5.push({name:arrParticles[_local4], X:arrProjectiles[_local3].X, Y:arrProjectiles[_local3].Y});
arrParticles.splice(_local4, 1);
_local4--;
_root[arrProjectiles[_local3].name].removeMovieClip();
arrProjectiles.splice(_local3, 1);
_local3--;
}
_local4++;
}
_local3++;
}
_local4 = 0;
while (_local4 < _local5.length) {
_root[_local5[_local4].name].Collision(_local5[_local4].X, _local5[_local4].Y);
_root[_local5[_local4].name].gotoAndStop(2);
_local4++;
}
if ((arrProjectiles.length == 0) && (projectileOver == true)) {
if (arrParticles.length != 0) {
intState = 3;
_root.messages_mc.gotoAndPlay("retry");
} else {
intState = 4;
var _local10 = ((_global.currentLevel + 5) - 15) / 5;
_global.levels[_local10] = 1;
var _local9 = SharedObject.getLocal("userData");
_local9.data.levelsCompleted = _global.levels;
_global.SoundManager.PlaySound("all");
_root.messages_mc.gotoAndPlay("next");
}
}
}
function LaunchProjectile(deltaX, deltaY, startX, startY, rot) {
var _local2 = "projectile_" + projectileDepth;
arrProjectiles.push({name:_local2, dX:deltaX, dY:deltaY, X:startX, Y:startY});
_root.attachMovie("shootingStar", _local2, projectileDepth);
_root[_local2]._x = startX;
_root[_local2]._y = startY;
_root[_local2]._rotation = rot;
projectileDepth++;
if (projectileDepth > 9999) {
projectileDepth = 5000;
}
}
stop();
var intState = 1;
var vecShootDir;
var arrParticles = new Array();
var arrProjectiles = new Array();
var arrParticlesReset = new Array();
var particleDepth = 1000;
var projectileDepth = 5000;
var arrowDepth = 15000;
var saveX = 0;
var saveY = 0;
var projectileOnScreen = false;
var projectileOver = false;
var saveDepth;
mouseListener = new Object();
mouseListener.onMouseDown = function () {
_root.Shoot();
};
Mouse.addListener(mouseListener);
Instance of Symbol 32 MovieClip in Frame 50
onClipEvent (load) {
_root.GameSetup();
}
onClipEvent (enterFrame) {
_root.Mediator();
}
Frame 55
function GameSetup() {
trace("%%%%%%%%");
trace((_global.currentLevel + " ----- ") + _global.latestLevel);
if (_global.latestLevel == -1) {
_root.gotoAndPlay("splash");
} else if ((_global.latestLevel != 0) && (_global.latestLevel != 20)) {
_global.currentLevel = _global.latestLevel;
_root.gotoAndPlay(_global.latestLevel);
_global.latestLevel = 0;
trace("go here");
} else if ((_global.latestLevel != 0) && (_global.latestLevel == 20)) {
_global.currentLevel = _global.latestLevel;
_global.latestLevel = 0;
}
if (_root.messages_mc.getDepth() != 50000) {
saveDepth = _root.messages_mc.getDepth();
}
vecShootDir = new Vector();
if (_global.musicOn == true) {
_global.myMusicPlayer.SetTrack("game");
_global.myMusicPlayer.SetMaxVolume(40);
_global.myMusicPlayer.PlayWithCrossFade(4);
}
}
function Mediator() {
_global.myMusicPlayer.RunPlayer();
switch (intState) {
case 1 :
AimProjectile();
if (_root.messages_mc.getDepth() != 50000) {
_root.messages_mc.swapDepths(50000);
trace(_root.messages_mc.getDepth());
}
break;
case 2 :
if (projectileOver == false) {
MoveProjectile();
}
DetectParticleCollisions();
MoveProjectilesAndCollide();
break;
case 3 :
if (Key.isDown(32)) {
Reset();
}
break;
case 4 :
if (!Key.isDown(32)) {
break;
}
Next();
}
}
function Reset() {
projectileDepth = 5000;
arrParticles = arrParticlesReset.slice();
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].gotoAndStop(1);
trace(arrParticles[_local2]);
_local2++;
}
trace("-----");
_root.projectile.gotoAndStop(1);
_root.gameBackground.gotoAndStop(1);
_root.messages_mc.gotoAndStop("hide");
projectileOver = false;
projectileOnScreen = false;
intState = 1;
}
function ExitGame() {
CleanupGame();
Mouse.removeListener(mouseListener);
_root.messages_mc.swapDepths(saveDepth);
_global.latestLevel = -1;
_root.gotoAndPlay("level1");
}
function Next() {
_global.currentLevel = _global.currentLevel + 5;
CleanupGame();
_root.messages_mc.swapDepths(saveDepth);
_root.gotoAndPlay(_global.currentLevel);
}
function CleanupGame() {
Mouse.removeListener(mouseListener);
Reset();
var _local3 = 10;
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].swapDepths(_local3);
_local3++;
_root[arrParticles[_local2]].removeMovieClip();
_local2++;
}
delete arrParticles;
arrParticles = new Array();
}
function DetectParticleCollisions() {
var _local3 = new Array();
var _local2 = 0;
while (_local2 < arrParticles.length) {
var _local4 = (_root[arrParticles[_local2]]._width / 2) + 7.5;
if (GetDistance(arrParticles[_local2], "projectile") <= _local4) {
_root[arrParticles[_local2]].Collision(saveX, saveY);
_local3.push(arrParticles[_local2]);
}
_local2++;
}
_local2 = 0;
while (_local2 < _local3.length) {
RemoveParticle(_local3[_local2]);
_root[_local3[_local2]].gotoAndStop(2);
_local2++;
}
}
function RemoveParticle(strName) {
var _local1 = 0;
while (_local1 < arrParticles.length) {
if (strName == arrParticles[_local1]) {
arrParticles.splice(_local1, 1);
break;
}
_local1++;
}
}
function GetDistance(targetA, targetB) {
var _local3 = _root[targetB]._x - _root[targetA]._x;
var _local2 = _root[targetB]._y - _root[targetA]._y;
return(Math.sqrt((_local3 * _local3) + (_local2 * _local2)));
}
function RegisterParticle(particleName) {
arrParticles.push(particleName);
arrParticlesReset.push(particleName);
particleDepth++;
return(particleDepth);
}
function MoveProjectile() {
if (ProjectileOffScreen() == false) {
projectileOnScreen = true;
_root.projectile._x = _root.projectile._x + vecShootDir._x;
_root.projectile._y = _root.projectile._y + vecShootDir._y;
} else if (projectileOnScreen == true) {
projectileOver = true;
} else {
_root.projectile._x = _root.projectile._x + vecShootDir._x;
_root.projectile._y = _root.projectile._y + vecShootDir._y;
}
}
function AimProjectile() {
var _local11 = new Vector();
_local11._x = _xmouse - (Stage.width / 2);
_local11._y = _ymouse - (Stage.height / 2);
var _local12 = Math.atan2(_local11._y, _local11._x);
var _local15 = (360 * _local12) / (Math.PI*2);
var _local6 = _root.gameBackground._width / 2;
_root.projectile._x = (_local6 * Math.cos(_local12)) + (Stage.width / 2);
_root.projectile._y = (_local6 * Math.sin(_local12)) + (Stage.height / 2);
_local11._x = (Stage.width / 2) - _root.projectile._x;
_local11._y = (Stage.height / 2) - _root.projectile._y;
_local12 = Math.atan2(_local11._y, _local11._x);
var _local14 = Math.cos(_local12) * 11;
var _local13 = Math.sin(_local12) * 11;
var _local9 = _root.projectile._x;
var _local10 = _root.projectile._y;
var _local5 = new Array(arrParticles.length);
var _local4 = 0;
while (_local4 < _local5.length) {
_local5[_local4] = 0;
_local4++;
}
var _local8 = 0;
while (_local8 < 70) {
_local9 = _local9 + _local14;
_local10 = _local10 + _local13;
_local4 = 0;
while (_local4 < arrParticles.length) {
var _local7 = (_root[arrParticles[_local4]]._width / 2) + 7.5;
var _local3 = _root[arrParticles[_local4]]._x - _local9;
var _local2 = _root[arrParticles[_local4]]._y - _local10;
_local6 = Math.sqrt((_local3 * _local3) + (_local2 * _local2));
if (_local6 <= _local7) {
_local5[_local4] = 1;
}
_local4++;
}
_local8++;
}
_local4 = 0;
while (_local4 < _local5.length) {
if (_local5[_local4] == 1) {
_root[arrParticles[_local4]].ArrowsOn(arrowDepth, _root.projectile._x, _root.projectile._y);
} else {
_root[arrParticles[_local4]].ArrowsOff();
}
_local4++;
}
}
function TurnOffAllArrows() {
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].ArrowsOff();
_local2++;
}
}
function NextArrowDepth() {
arrowDepth++;
if (arrowDepth > 39999) {
arrowDepth = 15000;
}
}
function DrawLines() {
_root.clear();
_root.lineStyle(2, 16777215, 50);
var _local2 = new Object();
var _local3 = new Object();
_local2.x = _root.projectile._x;
_local2.y = _root.projectile._y;
_local3.x = _xmouse;
_local3.y = _ymouse;
_root.moveTo(_local2.x, _local2.y);
_root.lineTo(_local3.x, _local3.y);
}
function Shoot() {
if ((intState == 1) && (_global.latestLevel != -1)) {
trace("in");
_root.clear();
saveX = _root.projectile._x;
saveY = _root.projectile._y;
var _local4 = new Vector();
_local4._x = (Stage.width / 2) - _root.projectile._x;
_local4._y = (Stage.height / 2) - _root.projectile._y;
var _local5 = Math.atan2(_local4._y, _local4._x);
vecShootDir._x = Math.cos(_local5) * 11;
vecShootDir._y = Math.sin(_local5) * 11;
var _local3 = 100;
do {
if (ProjectileOffScreen() != false) {
break;
}
_root.projectile._x = _root.projectile._x - vecShootDir._x;
_root.projectile._y = _root.projectile._y - vecShootDir._y;
_local3--;
} while (_local3 != 0);
var _local6 = (360 * _local5) / (Math.PI*2);
_root.projectile.gotoAndStop(2);
_root.projectile._rotation = _local6;
_root.gameBackground.gotoAndPlay("hide");
TurnOffAllArrows();
intState = 2;
}
}
function ProjectileOffScreen() {
var _local2 = false;
if (((_root.projectile._x + _root.projectile._width) < 0) || ((_root.projectile._x - _root.projectile._width) > Stage.width)) {
_local2 = true;
}
if (((_root.projectile._y + _root.projectile._height) < 0) || ((_root.projectile._y - _root.projectile._height) > Stage.height)) {
_local2 = true;
}
return(_local2);
}
function MoveProjectilesAndCollide() {
var _local4 = 0;
while (_local4 < arrProjectiles.length) {
_root[arrProjectiles[_local4].name]._x = _root[arrProjectiles[_local4].name]._x + (arrProjectiles[_local4].dX / 2);
_root[arrProjectiles[_local4].name]._y = _root[arrProjectiles[_local4].name]._y + (arrProjectiles[_local4].dY / 2);
if (((_root[arrProjectiles[_local4].name]._x + _root[arrProjectiles[_local4].name]._width) < 0) || ((_root[arrProjectiles[_local4].name]._x - _root[arrProjectiles[_local4].name]._width) > Stage.width)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
if (((_root[arrProjectiles[_local4].name]._y + _root[arrProjectiles[_local4].name]._height) < 0) || ((_root[arrProjectiles[_local4].name]._y - _root[arrProjectiles[_local4].name]._height) > Stage.height)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
_local4++;
}
var _local5 = new Array();
var _local3 = 0;
while (_local3 < arrProjectiles.length) {
_local4 = 0;
while (_local4 < arrParticles.length) {
if (_root[arrParticles[_local4]].hitTest(_root[arrProjectiles[_local3].name]._x, _root[arrProjectiles[_local3].name]._y, true) == true) {
_local5.push({name:arrParticles[_local4], X:arrProjectiles[_local3].X, Y:arrProjectiles[_local3].Y});
arrParticles.splice(_local4, 1);
_local4--;
_root[arrProjectiles[_local3].name].removeMovieClip();
arrProjectiles.splice(_local3, 1);
_local3--;
}
_local4++;
}
_local3++;
}
_local4 = 0;
while (_local4 < _local5.length) {
_root[_local5[_local4].name].Collision(_local5[_local4].X, _local5[_local4].Y);
_root[_local5[_local4].name].gotoAndStop(2);
_local4++;
}
_local4 = 0;
while (_local4 < arrProjectiles.length) {
_root[arrProjectiles[_local4].name]._x = _root[arrProjectiles[_local4].name]._x + (arrProjectiles[_local4].dX / 2);
_root[arrProjectiles[_local4].name]._y = _root[arrProjectiles[_local4].name]._y + (arrProjectiles[_local4].dY / 2);
if (((_root[arrProjectiles[_local4].name]._x + _root[arrProjectiles[_local4].name]._width) < 0) || ((_root[arrProjectiles[_local4].name]._x - _root[arrProjectiles[_local4].name]._width) > Stage.width)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
if (((_root[arrProjectiles[_local4].name]._y + _root[arrProjectiles[_local4].name]._height) < 0) || ((_root[arrProjectiles[_local4].name]._y - _root[arrProjectiles[_local4].name]._height) > Stage.height)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
_local4++;
}
_local5 = new Array();
_local3 = 0;
while (_local3 < arrProjectiles.length) {
_local4 = 0;
while (_local4 < arrParticles.length) {
if (_root[arrParticles[_local4]].hitTest(_root[arrProjectiles[_local3].name]._x, _root[arrProjectiles[_local3].name]._y, true) == true) {
_local5.push({name:arrParticles[_local4], X:arrProjectiles[_local3].X, Y:arrProjectiles[_local3].Y});
arrParticles.splice(_local4, 1);
_local4--;
_root[arrProjectiles[_local3].name].removeMovieClip();
arrProjectiles.splice(_local3, 1);
_local3--;
}
_local4++;
}
_local3++;
}
_local4 = 0;
while (_local4 < _local5.length) {
_root[_local5[_local4].name].Collision(_local5[_local4].X, _local5[_local4].Y);
_root[_local5[_local4].name].gotoAndStop(2);
_local4++;
}
if ((arrProjectiles.length == 0) && (projectileOver == true)) {
if (arrParticles.length != 0) {
intState = 3;
_root.messages_mc.gotoAndPlay("retry");
} else {
intState = 4;
var _local10 = ((_global.currentLevel + 5) - 15) / 5;
_global.levels[_local10] = 1;
var _local9 = SharedObject.getLocal("userData");
_local9.data.levelsCompleted = _global.levels;
_global.SoundManager.PlaySound("all");
_root.messages_mc.gotoAndPlay("next");
}
}
}
function LaunchProjectile(deltaX, deltaY, startX, startY, rot) {
var _local2 = "projectile_" + projectileDepth;
arrProjectiles.push({name:_local2, dX:deltaX, dY:deltaY, X:startX, Y:startY});
_root.attachMovie("shootingStar", _local2, projectileDepth);
_root[_local2]._x = startX;
_root[_local2]._y = startY;
_root[_local2]._rotation = rot;
projectileDepth++;
if (projectileDepth > 9999) {
projectileDepth = 5000;
}
}
stop();
var intState = 1;
var vecShootDir;
var arrParticles = new Array();
var arrProjectiles = new Array();
var arrParticlesReset = new Array();
var particleDepth = 1000;
var projectileDepth = 5000;
var arrowDepth = 15000;
var saveX = 0;
var saveY = 0;
var projectileOnScreen = false;
var projectileOver = false;
var saveDepth;
mouseListener = new Object();
mouseListener.onMouseDown = function () {
_root.Shoot();
};
Mouse.addListener(mouseListener);
Instance of Symbol 32 MovieClip in Frame 55
onClipEvent (load) {
_root.GameSetup();
}
onClipEvent (enterFrame) {
_root.Mediator();
}
Frame 60
function GameSetup() {
trace("%%%%%%%%");
trace((_global.currentLevel + " ----- ") + _global.latestLevel);
if (_global.latestLevel == -1) {
_root.gotoAndPlay("splash");
} else if ((_global.latestLevel != 0) && (_global.latestLevel != 20)) {
_global.currentLevel = _global.latestLevel;
_root.gotoAndPlay(_global.latestLevel);
_global.latestLevel = 0;
trace("go here");
} else if ((_global.latestLevel != 0) && (_global.latestLevel == 20)) {
_global.currentLevel = _global.latestLevel;
_global.latestLevel = 0;
}
if (_root.messages_mc.getDepth() != 50000) {
saveDepth = _root.messages_mc.getDepth();
}
vecShootDir = new Vector();
if (_global.musicOn == true) {
_global.myMusicPlayer.SetTrack("game");
_global.myMusicPlayer.SetMaxVolume(40);
_global.myMusicPlayer.PlayWithCrossFade(4);
}
}
function Mediator() {
_global.myMusicPlayer.RunPlayer();
switch (intState) {
case 1 :
AimProjectile();
if (_root.messages_mc.getDepth() != 50000) {
_root.messages_mc.swapDepths(50000);
trace(_root.messages_mc.getDepth());
}
break;
case 2 :
if (projectileOver == false) {
MoveProjectile();
}
DetectParticleCollisions();
MoveProjectilesAndCollide();
break;
case 3 :
if (Key.isDown(32)) {
Reset();
}
break;
case 4 :
if (!Key.isDown(32)) {
break;
}
Next();
}
}
function Reset() {
projectileDepth = 5000;
arrParticles = arrParticlesReset.slice();
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].gotoAndStop(1);
trace(arrParticles[_local2]);
_local2++;
}
trace("-----");
_root.projectile.gotoAndStop(1);
_root.gameBackground.gotoAndStop(1);
_root.messages_mc.gotoAndStop("hide");
projectileOver = false;
projectileOnScreen = false;
intState = 1;
}
function ExitGame() {
CleanupGame();
Mouse.removeListener(mouseListener);
_root.messages_mc.swapDepths(saveDepth);
_global.latestLevel = -1;
_root.gotoAndPlay("level1");
}
function Next() {
_global.currentLevel = _global.currentLevel + 5;
CleanupGame();
_root.messages_mc.swapDepths(saveDepth);
_root.gotoAndPlay(_global.currentLevel);
}
function CleanupGame() {
Mouse.removeListener(mouseListener);
Reset();
var _local3 = 10;
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].swapDepths(_local3);
_local3++;
_root[arrParticles[_local2]].removeMovieClip();
_local2++;
}
delete arrParticles;
arrParticles = new Array();
}
function DetectParticleCollisions() {
var _local3 = new Array();
var _local2 = 0;
while (_local2 < arrParticles.length) {
var _local4 = (_root[arrParticles[_local2]]._width / 2) + 7.5;
if (GetDistance(arrParticles[_local2], "projectile") <= _local4) {
_root[arrParticles[_local2]].Collision(saveX, saveY);
_local3.push(arrParticles[_local2]);
}
_local2++;
}
_local2 = 0;
while (_local2 < _local3.length) {
RemoveParticle(_local3[_local2]);
_root[_local3[_local2]].gotoAndStop(2);
_local2++;
}
}
function RemoveParticle(strName) {
var _local1 = 0;
while (_local1 < arrParticles.length) {
if (strName == arrParticles[_local1]) {
arrParticles.splice(_local1, 1);
break;
}
_local1++;
}
}
function GetDistance(targetA, targetB) {
var _local3 = _root[targetB]._x - _root[targetA]._x;
var _local2 = _root[targetB]._y - _root[targetA]._y;
return(Math.sqrt((_local3 * _local3) + (_local2 * _local2)));
}
function RegisterParticle(particleName) {
arrParticles.push(particleName);
arrParticlesReset.push(particleName);
particleDepth++;
return(particleDepth);
}
function MoveProjectile() {
if (ProjectileOffScreen() == false) {
projectileOnScreen = true;
_root.projectile._x = _root.projectile._x + vecShootDir._x;
_root.projectile._y = _root.projectile._y + vecShootDir._y;
} else if (projectileOnScreen == true) {
projectileOver = true;
} else {
_root.projectile._x = _root.projectile._x + vecShootDir._x;
_root.projectile._y = _root.projectile._y + vecShootDir._y;
}
}
function AimProjectile() {
var _local11 = new Vector();
_local11._x = _xmouse - (Stage.width / 2);
_local11._y = _ymouse - (Stage.height / 2);
var _local12 = Math.atan2(_local11._y, _local11._x);
var _local15 = (360 * _local12) / (Math.PI*2);
var _local6 = _root.gameBackground._width / 2;
_root.projectile._x = (_local6 * Math.cos(_local12)) + (Stage.width / 2);
_root.projectile._y = (_local6 * Math.sin(_local12)) + (Stage.height / 2);
_local11._x = (Stage.width / 2) - _root.projectile._x;
_local11._y = (Stage.height / 2) - _root.projectile._y;
_local12 = Math.atan2(_local11._y, _local11._x);
var _local14 = Math.cos(_local12) * 11;
var _local13 = Math.sin(_local12) * 11;
var _local9 = _root.projectile._x;
var _local10 = _root.projectile._y;
var _local5 = new Array(arrParticles.length);
var _local4 = 0;
while (_local4 < _local5.length) {
_local5[_local4] = 0;
_local4++;
}
var _local8 = 0;
while (_local8 < 70) {
_local9 = _local9 + _local14;
_local10 = _local10 + _local13;
_local4 = 0;
while (_local4 < arrParticles.length) {
var _local7 = (_root[arrParticles[_local4]]._width / 2) + 7.5;
var _local3 = _root[arrParticles[_local4]]._x - _local9;
var _local2 = _root[arrParticles[_local4]]._y - _local10;
_local6 = Math.sqrt((_local3 * _local3) + (_local2 * _local2));
if (_local6 <= _local7) {
_local5[_local4] = 1;
}
_local4++;
}
_local8++;
}
_local4 = 0;
while (_local4 < _local5.length) {
if (_local5[_local4] == 1) {
_root[arrParticles[_local4]].ArrowsOn(arrowDepth, _root.projectile._x, _root.projectile._y);
} else {
_root[arrParticles[_local4]].ArrowsOff();
}
_local4++;
}
}
function TurnOffAllArrows() {
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].ArrowsOff();
_local2++;
}
}
function NextArrowDepth() {
arrowDepth++;
if (arrowDepth > 39999) {
arrowDepth = 15000;
}
}
function DrawLines() {
_root.clear();
_root.lineStyle(2, 16777215, 50);
var _local2 = new Object();
var _local3 = new Object();
_local2.x = _root.projectile._x;
_local2.y = _root.projectile._y;
_local3.x = _xmouse;
_local3.y = _ymouse;
_root.moveTo(_local2.x, _local2.y);
_root.lineTo(_local3.x, _local3.y);
}
function Shoot() {
if ((intState == 1) && (_global.latestLevel != -1)) {
trace("in");
_root.clear();
saveX = _root.projectile._x;
saveY = _root.projectile._y;
var _local4 = new Vector();
_local4._x = (Stage.width / 2) - _root.projectile._x;
_local4._y = (Stage.height / 2) - _root.projectile._y;
var _local5 = Math.atan2(_local4._y, _local4._x);
vecShootDir._x = Math.cos(_local5) * 11;
vecShootDir._y = Math.sin(_local5) * 11;
var _local3 = 100;
do {
if (ProjectileOffScreen() != false) {
break;
}
_root.projectile._x = _root.projectile._x - vecShootDir._x;
_root.projectile._y = _root.projectile._y - vecShootDir._y;
_local3--;
} while (_local3 != 0);
var _local6 = (360 * _local5) / (Math.PI*2);
_root.projectile.gotoAndStop(2);
_root.projectile._rotation = _local6;
_root.gameBackground.gotoAndPlay("hide");
TurnOffAllArrows();
intState = 2;
}
}
function ProjectileOffScreen() {
var _local2 = false;
if (((_root.projectile._x + _root.projectile._width) < 0) || ((_root.projectile._x - _root.projectile._width) > Stage.width)) {
_local2 = true;
}
if (((_root.projectile._y + _root.projectile._height) < 0) || ((_root.projectile._y - _root.projectile._height) > Stage.height)) {
_local2 = true;
}
return(_local2);
}
function MoveProjectilesAndCollide() {
var _local4 = 0;
while (_local4 < arrProjectiles.length) {
_root[arrProjectiles[_local4].name]._x = _root[arrProjectiles[_local4].name]._x + (arrProjectiles[_local4].dX / 2);
_root[arrProjectiles[_local4].name]._y = _root[arrProjectiles[_local4].name]._y + (arrProjectiles[_local4].dY / 2);
if (((_root[arrProjectiles[_local4].name]._x + _root[arrProjectiles[_local4].name]._width) < 0) || ((_root[arrProjectiles[_local4].name]._x - _root[arrProjectiles[_local4].name]._width) > Stage.width)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
if (((_root[arrProjectiles[_local4].name]._y + _root[arrProjectiles[_local4].name]._height) < 0) || ((_root[arrProjectiles[_local4].name]._y - _root[arrProjectiles[_local4].name]._height) > Stage.height)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
_local4++;
}
var _local5 = new Array();
var _local3 = 0;
while (_local3 < arrProjectiles.length) {
_local4 = 0;
while (_local4 < arrParticles.length) {
if (_root[arrParticles[_local4]].hitTest(_root[arrProjectiles[_local3].name]._x, _root[arrProjectiles[_local3].name]._y, true) == true) {
_local5.push({name:arrParticles[_local4], X:arrProjectiles[_local3].X, Y:arrProjectiles[_local3].Y});
arrParticles.splice(_local4, 1);
_local4--;
_root[arrProjectiles[_local3].name].removeMovieClip();
arrProjectiles.splice(_local3, 1);
_local3--;
}
_local4++;
}
_local3++;
}
_local4 = 0;
while (_local4 < _local5.length) {
_root[_local5[_local4].name].Collision(_local5[_local4].X, _local5[_local4].Y);
_root[_local5[_local4].name].gotoAndStop(2);
_local4++;
}
_local4 = 0;
while (_local4 < arrProjectiles.length) {
_root[arrProjectiles[_local4].name]._x = _root[arrProjectiles[_local4].name]._x + (arrProjectiles[_local4].dX / 2);
_root[arrProjectiles[_local4].name]._y = _root[arrProjectiles[_local4].name]._y + (arrProjectiles[_local4].dY / 2);
if (((_root[arrProjectiles[_local4].name]._x + _root[arrProjectiles[_local4].name]._width) < 0) || ((_root[arrProjectiles[_local4].name]._x - _root[arrProjectiles[_local4].name]._width) > Stage.width)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
if (((_root[arrProjectiles[_local4].name]._y + _root[arrProjectiles[_local4].name]._height) < 0) || ((_root[arrProjectiles[_local4].name]._y - _root[arrProjectiles[_local4].name]._height) > Stage.height)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
_local4++;
}
_local5 = new Array();
_local3 = 0;
while (_local3 < arrProjectiles.length) {
_local4 = 0;
while (_local4 < arrParticles.length) {
if (_root[arrParticles[_local4]].hitTest(_root[arrProjectiles[_local3].name]._x, _root[arrProjectiles[_local3].name]._y, true) == true) {
_local5.push({name:arrParticles[_local4], X:arrProjectiles[_local3].X, Y:arrProjectiles[_local3].Y});
arrParticles.splice(_local4, 1);
_local4--;
_root[arrProjectiles[_local3].name].removeMovieClip();
arrProjectiles.splice(_local3, 1);
_local3--;
}
_local4++;
}
_local3++;
}
_local4 = 0;
while (_local4 < _local5.length) {
_root[_local5[_local4].name].Collision(_local5[_local4].X, _local5[_local4].Y);
_root[_local5[_local4].name].gotoAndStop(2);
_local4++;
}
if ((arrProjectiles.length == 0) && (projectileOver == true)) {
if (arrParticles.length != 0) {
intState = 3;
_root.messages_mc.gotoAndPlay("retry");
} else {
intState = 4;
var _local10 = ((_global.currentLevel + 5) - 15) / 5;
_global.levels[_local10] = 1;
var _local9 = SharedObject.getLocal("userData");
_local9.data.levelsCompleted = _global.levels;
_global.SoundManager.PlaySound("all");
_root.messages_mc.gotoAndPlay("next");
}
}
}
function LaunchProjectile(deltaX, deltaY, startX, startY, rot) {
var _local2 = "projectile_" + projectileDepth;
arrProjectiles.push({name:_local2, dX:deltaX, dY:deltaY, X:startX, Y:startY});
_root.attachMovie("shootingStar", _local2, projectileDepth);
_root[_local2]._x = startX;
_root[_local2]._y = startY;
_root[_local2]._rotation = rot;
projectileDepth++;
if (projectileDepth > 9999) {
projectileDepth = 5000;
}
}
stop();
var intState = 1;
var vecShootDir;
var arrParticles = new Array();
var arrProjectiles = new Array();
var arrParticlesReset = new Array();
var particleDepth = 1000;
var projectileDepth = 5000;
var arrowDepth = 15000;
var saveX = 0;
var saveY = 0;
var projectileOnScreen = false;
var projectileOver = false;
var saveDepth;
mouseListener = new Object();
mouseListener.onMouseDown = function () {
_root.Shoot();
};
Mouse.addListener(mouseListener);
Frame 65
function GameSetup() {
trace("%%%%%%%%");
trace((_global.currentLevel + " ----- ") + _global.latestLevel);
if (_global.latestLevel == -1) {
_root.gotoAndPlay("splash");
} else if ((_global.latestLevel != 0) && (_global.latestLevel != 20)) {
_global.currentLevel = _global.latestLevel;
_root.gotoAndPlay(_global.latestLevel);
_global.latestLevel = 0;
trace("go here");
} else if ((_global.latestLevel != 0) && (_global.latestLevel == 20)) {
_global.currentLevel = _global.latestLevel;
_global.latestLevel = 0;
}
if (_root.messages_mc.getDepth() != 50000) {
saveDepth = _root.messages_mc.getDepth();
}
vecShootDir = new Vector();
if (_global.musicOn == true) {
_global.myMusicPlayer.SetTrack("game");
_global.myMusicPlayer.SetMaxVolume(40);
_global.myMusicPlayer.PlayWithCrossFade(4);
}
}
function Mediator() {
_global.myMusicPlayer.RunPlayer();
switch (intState) {
case 1 :
AimProjectile();
if (_root.messages_mc.getDepth() != 50000) {
_root.messages_mc.swapDepths(50000);
trace(_root.messages_mc.getDepth());
}
break;
case 2 :
if (projectileOver == false) {
MoveProjectile();
}
DetectParticleCollisions();
MoveProjectilesAndCollide();
break;
case 3 :
if (Key.isDown(32)) {
Reset();
}
break;
case 4 :
if (!Key.isDown(32)) {
break;
}
Next();
}
}
function Reset() {
projectileDepth = 5000;
arrParticles = arrParticlesReset.slice();
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].gotoAndStop(1);
trace(arrParticles[_local2]);
_local2++;
}
trace("-----");
_root.projectile.gotoAndStop(1);
_root.gameBackground.gotoAndStop(1);
_root.messages_mc.gotoAndStop("hide");
projectileOver = false;
projectileOnScreen = false;
intState = 1;
}
function ExitGame() {
CleanupGame();
Mouse.removeListener(mouseListener);
_root.messages_mc.swapDepths(saveDepth);
_global.latestLevel = -1;
_root.gotoAndPlay("level1");
}
function Next() {
_global.currentLevel = _global.currentLevel + 5;
CleanupGame();
_root.messages_mc.swapDepths(saveDepth);
_root.gotoAndPlay(_global.currentLevel);
}
function CleanupGame() {
Mouse.removeListener(mouseListener);
Reset();
var _local3 = 10;
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].swapDepths(_local3);
_local3++;
_root[arrParticles[_local2]].removeMovieClip();
_local2++;
}
delete arrParticles;
arrParticles = new Array();
}
function DetectParticleCollisions() {
var _local3 = new Array();
var _local2 = 0;
while (_local2 < arrParticles.length) {
var _local4 = (_root[arrParticles[_local2]]._width / 2) + 7.5;
if (GetDistance(arrParticles[_local2], "projectile") <= _local4) {
_root[arrParticles[_local2]].Collision(saveX, saveY);
_local3.push(arrParticles[_local2]);
}
_local2++;
}
_local2 = 0;
while (_local2 < _local3.length) {
RemoveParticle(_local3[_local2]);
_root[_local3[_local2]].gotoAndStop(2);
_local2++;
}
}
function RemoveParticle(strName) {
var _local1 = 0;
while (_local1 < arrParticles.length) {
if (strName == arrParticles[_local1]) {
arrParticles.splice(_local1, 1);
break;
}
_local1++;
}
}
function GetDistance(targetA, targetB) {
var _local3 = _root[targetB]._x - _root[targetA]._x;
var _local2 = _root[targetB]._y - _root[targetA]._y;
return(Math.sqrt((_local3 * _local3) + (_local2 * _local2)));
}
function RegisterParticle(particleName) {
arrParticles.push(particleName);
arrParticlesReset.push(particleName);
particleDepth++;
return(particleDepth);
}
function MoveProjectile() {
if (ProjectileOffScreen() == false) {
projectileOnScreen = true;
_root.projectile._x = _root.projectile._x + vecShootDir._x;
_root.projectile._y = _root.projectile._y + vecShootDir._y;
} else if (projectileOnScreen == true) {
projectileOver = true;
} else {
_root.projectile._x = _root.projectile._x + vecShootDir._x;
_root.projectile._y = _root.projectile._y + vecShootDir._y;
}
}
function AimProjectile() {
var _local11 = new Vector();
_local11._x = _xmouse - (Stage.width / 2);
_local11._y = _ymouse - (Stage.height / 2);
var _local12 = Math.atan2(_local11._y, _local11._x);
var _local15 = (360 * _local12) / (Math.PI*2);
var _local6 = _root.gameBackground._width / 2;
_root.projectile._x = (_local6 * Math.cos(_local12)) + (Stage.width / 2);
_root.projectile._y = (_local6 * Math.sin(_local12)) + (Stage.height / 2);
_local11._x = (Stage.width / 2) - _root.projectile._x;
_local11._y = (Stage.height / 2) - _root.projectile._y;
_local12 = Math.atan2(_local11._y, _local11._x);
var _local14 = Math.cos(_local12) * 11;
var _local13 = Math.sin(_local12) * 11;
var _local9 = _root.projectile._x;
var _local10 = _root.projectile._y;
var _local5 = new Array(arrParticles.length);
var _local4 = 0;
while (_local4 < _local5.length) {
_local5[_local4] = 0;
_local4++;
}
var _local8 = 0;
while (_local8 < 70) {
_local9 = _local9 + _local14;
_local10 = _local10 + _local13;
_local4 = 0;
while (_local4 < arrParticles.length) {
var _local7 = (_root[arrParticles[_local4]]._width / 2) + 7.5;
var _local3 = _root[arrParticles[_local4]]._x - _local9;
var _local2 = _root[arrParticles[_local4]]._y - _local10;
_local6 = Math.sqrt((_local3 * _local3) + (_local2 * _local2));
if (_local6 <= _local7) {
_local5[_local4] = 1;
}
_local4++;
}
_local8++;
}
_local4 = 0;
while (_local4 < _local5.length) {
if (_local5[_local4] == 1) {
_root[arrParticles[_local4]].ArrowsOn(arrowDepth, _root.projectile._x, _root.projectile._y);
} else {
_root[arrParticles[_local4]].ArrowsOff();
}
_local4++;
}
}
function TurnOffAllArrows() {
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].ArrowsOff();
_local2++;
}
}
function NextArrowDepth() {
arrowDepth++;
if (arrowDepth > 39999) {
arrowDepth = 15000;
}
}
function DrawLines() {
_root.clear();
_root.lineStyle(2, 16777215, 50);
var _local2 = new Object();
var _local3 = new Object();
_local2.x = _root.projectile._x;
_local2.y = _root.projectile._y;
_local3.x = _xmouse;
_local3.y = _ymouse;
_root.moveTo(_local2.x, _local2.y);
_root.lineTo(_local3.x, _local3.y);
}
function Shoot() {
if ((intState == 1) && (_global.latestLevel != -1)) {
trace("in");
_root.clear();
saveX = _root.projectile._x;
saveY = _root.projectile._y;
var _local4 = new Vector();
_local4._x = (Stage.width / 2) - _root.projectile._x;
_local4._y = (Stage.height / 2) - _root.projectile._y;
var _local5 = Math.atan2(_local4._y, _local4._x);
vecShootDir._x = Math.cos(_local5) * 11;
vecShootDir._y = Math.sin(_local5) * 11;
var _local3 = 100;
do {
if (ProjectileOffScreen() != false) {
break;
}
_root.projectile._x = _root.projectile._x - vecShootDir._x;
_root.projectile._y = _root.projectile._y - vecShootDir._y;
_local3--;
} while (_local3 != 0);
var _local6 = (360 * _local5) / (Math.PI*2);
_root.projectile.gotoAndStop(2);
_root.projectile._rotation = _local6;
_root.gameBackground.gotoAndPlay("hide");
TurnOffAllArrows();
intState = 2;
}
}
function ProjectileOffScreen() {
var _local2 = false;
if (((_root.projectile._x + _root.projectile._width) < 0) || ((_root.projectile._x - _root.projectile._width) > Stage.width)) {
_local2 = true;
}
if (((_root.projectile._y + _root.projectile._height) < 0) || ((_root.projectile._y - _root.projectile._height) > Stage.height)) {
_local2 = true;
}
return(_local2);
}
function MoveProjectilesAndCollide() {
var _local4 = 0;
while (_local4 < arrProjectiles.length) {
_root[arrProjectiles[_local4].name]._x = _root[arrProjectiles[_local4].name]._x + (arrProjectiles[_local4].dX / 2);
_root[arrProjectiles[_local4].name]._y = _root[arrProjectiles[_local4].name]._y + (arrProjectiles[_local4].dY / 2);
if (((_root[arrProjectiles[_local4].name]._x + _root[arrProjectiles[_local4].name]._width) < 0) || ((_root[arrProjectiles[_local4].name]._x - _root[arrProjectiles[_local4].name]._width) > Stage.width)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
if (((_root[arrProjectiles[_local4].name]._y + _root[arrProjectiles[_local4].name]._height) < 0) || ((_root[arrProjectiles[_local4].name]._y - _root[arrProjectiles[_local4].name]._height) > Stage.height)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
_local4++;
}
var _local5 = new Array();
var _local3 = 0;
while (_local3 < arrProjectiles.length) {
_local4 = 0;
while (_local4 < arrParticles.length) {
if (_root[arrParticles[_local4]].hitTest(_root[arrProjectiles[_local3].name]._x, _root[arrProjectiles[_local3].name]._y, true) == true) {
_local5.push({name:arrParticles[_local4], X:arrProjectiles[_local3].X, Y:arrProjectiles[_local3].Y});
arrParticles.splice(_local4, 1);
_local4--;
_root[arrProjectiles[_local3].name].removeMovieClip();
arrProjectiles.splice(_local3, 1);
_local3--;
}
_local4++;
}
_local3++;
}
_local4 = 0;
while (_local4 < _local5.length) {
_root[_local5[_local4].name].Collision(_local5[_local4].X, _local5[_local4].Y);
_root[_local5[_local4].name].gotoAndStop(2);
_local4++;
}
_local4 = 0;
while (_local4 < arrProjectiles.length) {
_root[arrProjectiles[_local4].name]._x = _root[arrProjectiles[_local4].name]._x + (arrProjectiles[_local4].dX / 2);
_root[arrProjectiles[_local4].name]._y = _root[arrProjectiles[_local4].name]._y + (arrProjectiles[_local4].dY / 2);
if (((_root[arrProjectiles[_local4].name]._x + _root[arrProjectiles[_local4].name]._width) < 0) || ((_root[arrProjectiles[_local4].name]._x - _root[arrProjectiles[_local4].name]._width) > Stage.width)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
if (((_root[arrProjectiles[_local4].name]._y + _root[arrProjectiles[_local4].name]._height) < 0) || ((_root[arrProjectiles[_local4].name]._y - _root[arrProjectiles[_local4].name]._height) > Stage.height)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
_local4++;
}
_local5 = new Array();
_local3 = 0;
while (_local3 < arrProjectiles.length) {
_local4 = 0;
while (_local4 < arrParticles.length) {
if (_root[arrParticles[_local4]].hitTest(_root[arrProjectiles[_local3].name]._x, _root[arrProjectiles[_local3].name]._y, true) == true) {
_local5.push({name:arrParticles[_local4], X:arrProjectiles[_local3].X, Y:arrProjectiles[_local3].Y});
arrParticles.splice(_local4, 1);
_local4--;
_root[arrProjectiles[_local3].name].removeMovieClip();
arrProjectiles.splice(_local3, 1);
_local3--;
}
_local4++;
}
_local3++;
}
_local4 = 0;
while (_local4 < _local5.length) {
_root[_local5[_local4].name].Collision(_local5[_local4].X, _local5[_local4].Y);
_root[_local5[_local4].name].gotoAndStop(2);
_local4++;
}
if ((arrProjectiles.length == 0) && (projectileOver == true)) {
if (arrParticles.length != 0) {
intState = 3;
_root.messages_mc.gotoAndPlay("retry");
} else {
intState = 4;
var _local10 = ((_global.currentLevel + 5) - 15) / 5;
_global.levels[_local10] = 1;
var _local9 = SharedObject.getLocal("userData");
_local9.data.levelsCompleted = _global.levels;
_global.SoundManager.PlaySound("all");
_root.messages_mc.gotoAndPlay("next");
}
}
}
function LaunchProjectile(deltaX, deltaY, startX, startY, rot) {
var _local2 = "projectile_" + projectileDepth;
arrProjectiles.push({name:_local2, dX:deltaX, dY:deltaY, X:startX, Y:startY});
_root.attachMovie("shootingStar", _local2, projectileDepth);
_root[_local2]._x = startX;
_root[_local2]._y = startY;
_root[_local2]._rotation = rot;
projectileDepth++;
if (projectileDepth > 9999) {
projectileDepth = 5000;
}
}
stop();
var intState = 1;
var vecShootDir;
var arrParticles = new Array();
var arrProjectiles = new Array();
var arrParticlesReset = new Array();
var particleDepth = 1000;
var projectileDepth = 5000;
var arrowDepth = 15000;
var saveX = 0;
var saveY = 0;
var projectileOnScreen = false;
var projectileOver = false;
var saveDepth;
mouseListener = new Object();
mouseListener.onMouseDown = function () {
_root.Shoot();
};
Mouse.addListener(mouseListener);
Frame 70
function GameSetup() {
trace("%%%%%%%%");
trace((_global.currentLevel + " ----- ") + _global.latestLevel);
if (_global.latestLevel == -1) {
_root.gotoAndPlay("splash");
} else if ((_global.latestLevel != 0) && (_global.latestLevel != 20)) {
_global.currentLevel = _global.latestLevel;
_root.gotoAndPlay(_global.latestLevel);
_global.latestLevel = 0;
trace("go here");
} else if ((_global.latestLevel != 0) && (_global.latestLevel == 20)) {
_global.currentLevel = _global.latestLevel;
_global.latestLevel = 0;
}
if (_root.messages_mc.getDepth() != 50000) {
saveDepth = _root.messages_mc.getDepth();
}
vecShootDir = new Vector();
if (_global.musicOn == true) {
_global.myMusicPlayer.SetTrack("game");
_global.myMusicPlayer.SetMaxVolume(40);
_global.myMusicPlayer.PlayWithCrossFade(4);
}
}
function Mediator() {
_global.myMusicPlayer.RunPlayer();
switch (intState) {
case 1 :
AimProjectile();
if (_root.messages_mc.getDepth() != 50000) {
_root.messages_mc.swapDepths(50000);
trace(_root.messages_mc.getDepth());
}
break;
case 2 :
if (projectileOver == false) {
MoveProjectile();
}
DetectParticleCollisions();
MoveProjectilesAndCollide();
break;
case 3 :
if (Key.isDown(32)) {
Reset();
}
break;
case 4 :
if (!Key.isDown(32)) {
break;
}
Next();
}
}
function Reset() {
projectileDepth = 5000;
arrParticles = arrParticlesReset.slice();
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].gotoAndStop(1);
trace(arrParticles[_local2]);
_local2++;
}
trace("-----");
_root.projectile.gotoAndStop(1);
_root.gameBackground.gotoAndStop(1);
_root.messages_mc.gotoAndStop("hide");
projectileOver = false;
projectileOnScreen = false;
intState = 1;
}
function ExitGame() {
CleanupGame();
Mouse.removeListener(mouseListener);
_root.messages_mc.swapDepths(saveDepth);
_global.latestLevel = -1;
_root.gotoAndPlay("level1");
}
function Next() {
_global.currentLevel = _global.currentLevel + 5;
CleanupGame();
_root.messages_mc.swapDepths(saveDepth);
_root.gotoAndPlay(_global.currentLevel);
}
function CleanupGame() {
Mouse.removeListener(mouseListener);
Reset();
var _local3 = 10;
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].swapDepths(_local3);
_local3++;
_root[arrParticles[_local2]].removeMovieClip();
_local2++;
}
delete arrParticles;
arrParticles = new Array();
}
function DetectParticleCollisions() {
var _local3 = new Array();
var _local2 = 0;
while (_local2 < arrParticles.length) {
var _local4 = (_root[arrParticles[_local2]]._width / 2) + 7.5;
if (GetDistance(arrParticles[_local2], "projectile") <= _local4) {
_root[arrParticles[_local2]].Collision(saveX, saveY);
_local3.push(arrParticles[_local2]);
}
_local2++;
}
_local2 = 0;
while (_local2 < _local3.length) {
RemoveParticle(_local3[_local2]);
_root[_local3[_local2]].gotoAndStop(2);
_local2++;
}
}
function RemoveParticle(strName) {
var _local1 = 0;
while (_local1 < arrParticles.length) {
if (strName == arrParticles[_local1]) {
arrParticles.splice(_local1, 1);
break;
}
_local1++;
}
}
function GetDistance(targetA, targetB) {
var _local3 = _root[targetB]._x - _root[targetA]._x;
var _local2 = _root[targetB]._y - _root[targetA]._y;
return(Math.sqrt((_local3 * _local3) + (_local2 * _local2)));
}
function RegisterParticle(particleName) {
arrParticles.push(particleName);
arrParticlesReset.push(particleName);
particleDepth++;
return(particleDepth);
}
function MoveProjectile() {
if (ProjectileOffScreen() == false) {
projectileOnScreen = true;
_root.projectile._x = _root.projectile._x + vecShootDir._x;
_root.projectile._y = _root.projectile._y + vecShootDir._y;
} else if (projectileOnScreen == true) {
projectileOver = true;
} else {
_root.projectile._x = _root.projectile._x + vecShootDir._x;
_root.projectile._y = _root.projectile._y + vecShootDir._y;
}
}
function AimProjectile() {
var _local11 = new Vector();
_local11._x = _xmouse - (Stage.width / 2);
_local11._y = _ymouse - (Stage.height / 2);
var _local12 = Math.atan2(_local11._y, _local11._x);
var _local15 = (360 * _local12) / (Math.PI*2);
var _local6 = _root.gameBackground._width / 2;
_root.projectile._x = (_local6 * Math.cos(_local12)) + (Stage.width / 2);
_root.projectile._y = (_local6 * Math.sin(_local12)) + (Stage.height / 2);
_local11._x = (Stage.width / 2) - _root.projectile._x;
_local11._y = (Stage.height / 2) - _root.projectile._y;
_local12 = Math.atan2(_local11._y, _local11._x);
var _local14 = Math.cos(_local12) * 11;
var _local13 = Math.sin(_local12) * 11;
var _local9 = _root.projectile._x;
var _local10 = _root.projectile._y;
var _local5 = new Array(arrParticles.length);
var _local4 = 0;
while (_local4 < _local5.length) {
_local5[_local4] = 0;
_local4++;
}
var _local8 = 0;
while (_local8 < 70) {
_local9 = _local9 + _local14;
_local10 = _local10 + _local13;
_local4 = 0;
while (_local4 < arrParticles.length) {
var _local7 = (_root[arrParticles[_local4]]._width / 2) + 7.5;
var _local3 = _root[arrParticles[_local4]]._x - _local9;
var _local2 = _root[arrParticles[_local4]]._y - _local10;
_local6 = Math.sqrt((_local3 * _local3) + (_local2 * _local2));
if (_local6 <= _local7) {
_local5[_local4] = 1;
}
_local4++;
}
_local8++;
}
_local4 = 0;
while (_local4 < _local5.length) {
if (_local5[_local4] == 1) {
_root[arrParticles[_local4]].ArrowsOn(arrowDepth, _root.projectile._x, _root.projectile._y);
} else {
_root[arrParticles[_local4]].ArrowsOff();
}
_local4++;
}
}
function TurnOffAllArrows() {
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].ArrowsOff();
_local2++;
}
}
function NextArrowDepth() {
arrowDepth++;
if (arrowDepth > 39999) {
arrowDepth = 15000;
}
}
function DrawLines() {
_root.clear();
_root.lineStyle(2, 16777215, 50);
var _local2 = new Object();
var _local3 = new Object();
_local2.x = _root.projectile._x;
_local2.y = _root.projectile._y;
_local3.x = _xmouse;
_local3.y = _ymouse;
_root.moveTo(_local2.x, _local2.y);
_root.lineTo(_local3.x, _local3.y);
}
function Shoot() {
if ((intState == 1) && (_global.latestLevel != -1)) {
trace("in");
_root.clear();
saveX = _root.projectile._x;
saveY = _root.projectile._y;
var _local4 = new Vector();
_local4._x = (Stage.width / 2) - _root.projectile._x;
_local4._y = (Stage.height / 2) - _root.projectile._y;
var _local5 = Math.atan2(_local4._y, _local4._x);
vecShootDir._x = Math.cos(_local5) * 11;
vecShootDir._y = Math.sin(_local5) * 11;
var _local3 = 100;
do {
if (ProjectileOffScreen() != false) {
break;
}
_root.projectile._x = _root.projectile._x - vecShootDir._x;
_root.projectile._y = _root.projectile._y - vecShootDir._y;
_local3--;
} while (_local3 != 0);
var _local6 = (360 * _local5) / (Math.PI*2);
_root.projectile.gotoAndStop(2);
_root.projectile._rotation = _local6;
_root.gameBackground.gotoAndPlay("hide");
TurnOffAllArrows();
intState = 2;
}
}
function ProjectileOffScreen() {
var _local2 = false;
if (((_root.projectile._x + _root.projectile._width) < 0) || ((_root.projectile._x - _root.projectile._width) > Stage.width)) {
_local2 = true;
}
if (((_root.projectile._y + _root.projectile._height) < 0) || ((_root.projectile._y - _root.projectile._height) > Stage.height)) {
_local2 = true;
}
return(_local2);
}
function MoveProjectilesAndCollide() {
var _local4 = 0;
while (_local4 < arrProjectiles.length) {
_root[arrProjectiles[_local4].name]._x = _root[arrProjectiles[_local4].name]._x + (arrProjectiles[_local4].dX / 2);
_root[arrProjectiles[_local4].name]._y = _root[arrProjectiles[_local4].name]._y + (arrProjectiles[_local4].dY / 2);
if (((_root[arrProjectiles[_local4].name]._x + _root[arrProjectiles[_local4].name]._width) < 0) || ((_root[arrProjectiles[_local4].name]._x - _root[arrProjectiles[_local4].name]._width) > Stage.width)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
if (((_root[arrProjectiles[_local4].name]._y + _root[arrProjectiles[_local4].name]._height) < 0) || ((_root[arrProjectiles[_local4].name]._y - _root[arrProjectiles[_local4].name]._height) > Stage.height)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
_local4++;
}
var _local5 = new Array();
var _local3 = 0;
while (_local3 < arrProjectiles.length) {
_local4 = 0;
while (_local4 < arrParticles.length) {
if (_root[arrParticles[_local4]].hitTest(_root[arrProjectiles[_local3].name]._x, _root[arrProjectiles[_local3].name]._y, true) == true) {
_local5.push({name:arrParticles[_local4], X:arrProjectiles[_local3].X, Y:arrProjectiles[_local3].Y});
arrParticles.splice(_local4, 1);
_local4--;
_root[arrProjectiles[_local3].name].removeMovieClip();
arrProjectiles.splice(_local3, 1);
_local3--;
}
_local4++;
}
_local3++;
}
_local4 = 0;
while (_local4 < _local5.length) {
_root[_local5[_local4].name].Collision(_local5[_local4].X, _local5[_local4].Y);
_root[_local5[_local4].name].gotoAndStop(2);
_local4++;
}
_local4 = 0;
while (_local4 < arrProjectiles.length) {
_root[arrProjectiles[_local4].name]._x = _root[arrProjectiles[_local4].name]._x + (arrProjectiles[_local4].dX / 2);
_root[arrProjectiles[_local4].name]._y = _root[arrProjectiles[_local4].name]._y + (arrProjectiles[_local4].dY / 2);
if (((_root[arrProjectiles[_local4].name]._x + _root[arrProjectiles[_local4].name]._width) < 0) || ((_root[arrProjectiles[_local4].name]._x - _root[arrProjectiles[_local4].name]._width) > Stage.width)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
if (((_root[arrProjectiles[_local4].name]._y + _root[arrProjectiles[_local4].name]._height) < 0) || ((_root[arrProjectiles[_local4].name]._y - _root[arrProjectiles[_local4].name]._height) > Stage.height)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
_local4++;
}
_local5 = new Array();
_local3 = 0;
while (_local3 < arrProjectiles.length) {
_local4 = 0;
while (_local4 < arrParticles.length) {
if (_root[arrParticles[_local4]].hitTest(_root[arrProjectiles[_local3].name]._x, _root[arrProjectiles[_local3].name]._y, true) == true) {
_local5.push({name:arrParticles[_local4], X:arrProjectiles[_local3].X, Y:arrProjectiles[_local3].Y});
arrParticles.splice(_local4, 1);
_local4--;
_root[arrProjectiles[_local3].name].removeMovieClip();
arrProjectiles.splice(_local3, 1);
_local3--;
}
_local4++;
}
_local3++;
}
_local4 = 0;
while (_local4 < _local5.length) {
_root[_local5[_local4].name].Collision(_local5[_local4].X, _local5[_local4].Y);
_root[_local5[_local4].name].gotoAndStop(2);
_local4++;
}
if ((arrProjectiles.length == 0) && (projectileOver == true)) {
if (arrParticles.length != 0) {
intState = 3;
_root.messages_mc.gotoAndPlay("retry");
} else {
intState = 4;
var _local10 = ((_global.currentLevel + 5) - 15) / 5;
_global.levels[_local10] = 1;
var _local9 = SharedObject.getLocal("userData");
_local9.data.levelsCompleted = _global.levels;
_global.SoundManager.PlaySound("all");
_root.messages_mc.gotoAndPlay("next");
}
}
}
function LaunchProjectile(deltaX, deltaY, startX, startY, rot) {
var _local2 = "projectile_" + projectileDepth;
arrProjectiles.push({name:_local2, dX:deltaX, dY:deltaY, X:startX, Y:startY});
_root.attachMovie("shootingStar", _local2, projectileDepth);
_root[_local2]._x = startX;
_root[_local2]._y = startY;
_root[_local2]._rotation = rot;
projectileDepth++;
if (projectileDepth > 9999) {
projectileDepth = 5000;
}
}
stop();
var intState = 1;
var vecShootDir;
var arrParticles = new Array();
var arrProjectiles = new Array();
var arrParticlesReset = new Array();
var particleDepth = 1000;
var projectileDepth = 5000;
var arrowDepth = 15000;
var saveX = 0;
var saveY = 0;
var projectileOnScreen = false;
var projectileOver = false;
var saveDepth;
mouseListener = new Object();
mouseListener.onMouseDown = function () {
_root.Shoot();
};
Mouse.addListener(mouseListener);
Frame 75
function GameSetup() {
trace("%%%%%%%%");
trace((_global.currentLevel + " ----- ") + _global.latestLevel);
if (_global.latestLevel == -1) {
_root.gotoAndPlay("splash");
} else if ((_global.latestLevel != 0) && (_global.latestLevel != 20)) {
_global.currentLevel = _global.latestLevel;
_root.gotoAndPlay(_global.latestLevel);
_global.latestLevel = 0;
trace("go here");
} else if ((_global.latestLevel != 0) && (_global.latestLevel == 20)) {
_global.currentLevel = _global.latestLevel;
_global.latestLevel = 0;
}
if (_root.messages_mc.getDepth() != 50000) {
saveDepth = _root.messages_mc.getDepth();
}
vecShootDir = new Vector();
if (_global.musicOn == true) {
_global.myMusicPlayer.SetTrack("game");
_global.myMusicPlayer.SetMaxVolume(40);
_global.myMusicPlayer.PlayWithCrossFade(4);
}
}
function Mediator() {
_global.myMusicPlayer.RunPlayer();
switch (intState) {
case 1 :
AimProjectile();
if (_root.messages_mc.getDepth() != 50000) {
_root.messages_mc.swapDepths(50000);
trace(_root.messages_mc.getDepth());
}
break;
case 2 :
if (projectileOver == false) {
MoveProjectile();
}
DetectParticleCollisions();
MoveProjectilesAndCollide();
break;
case 3 :
if (Key.isDown(32)) {
Reset();
}
break;
case 4 :
if (!Key.isDown(32)) {
break;
}
Next();
}
}
function Reset() {
projectileDepth = 5000;
arrParticles = arrParticlesReset.slice();
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].gotoAndStop(1);
trace(arrParticles[_local2]);
_local2++;
}
trace("-----");
_root.projectile.gotoAndStop(1);
_root.gameBackground.gotoAndStop(1);
_root.messages_mc.gotoAndStop("hide");
projectileOver = false;
projectileOnScreen = false;
intState = 1;
}
function ExitGame() {
CleanupGame();
Mouse.removeListener(mouseListener);
_root.messages_mc.swapDepths(saveDepth);
_global.latestLevel = -1;
_root.gotoAndPlay("level1");
}
function Next() {
_global.currentLevel = _global.currentLevel + 5;
CleanupGame();
_root.messages_mc.swapDepths(saveDepth);
_root.gotoAndPlay(_global.currentLevel);
}
function CleanupGame() {
Mouse.removeListener(mouseListener);
Reset();
var _local3 = 10;
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].swapDepths(_local3);
_local3++;
_root[arrParticles[_local2]].removeMovieClip();
_local2++;
}
delete arrParticles;
arrParticles = new Array();
}
function DetectParticleCollisions() {
var _local3 = new Array();
var _local2 = 0;
while (_local2 < arrParticles.length) {
var _local4 = (_root[arrParticles[_local2]]._width / 2) + 7.5;
if (GetDistance(arrParticles[_local2], "projectile") <= _local4) {
_root[arrParticles[_local2]].Collision(saveX, saveY);
_local3.push(arrParticles[_local2]);
}
_local2++;
}
_local2 = 0;
while (_local2 < _local3.length) {
RemoveParticle(_local3[_local2]);
_root[_local3[_local2]].gotoAndStop(2);
_local2++;
}
}
function RemoveParticle(strName) {
var _local1 = 0;
while (_local1 < arrParticles.length) {
if (strName == arrParticles[_local1]) {
arrParticles.splice(_local1, 1);
break;
}
_local1++;
}
}
function GetDistance(targetA, targetB) {
var _local3 = _root[targetB]._x - _root[targetA]._x;
var _local2 = _root[targetB]._y - _root[targetA]._y;
return(Math.sqrt((_local3 * _local3) + (_local2 * _local2)));
}
function RegisterParticle(particleName) {
arrParticles.push(particleName);
arrParticlesReset.push(particleName);
particleDepth++;
return(particleDepth);
}
function MoveProjectile() {
if (ProjectileOffScreen() == false) {
projectileOnScreen = true;
_root.projectile._x = _root.projectile._x + vecShootDir._x;
_root.projectile._y = _root.projectile._y + vecShootDir._y;
} else if (projectileOnScreen == true) {
projectileOver = true;
} else {
_root.projectile._x = _root.projectile._x + vecShootDir._x;
_root.projectile._y = _root.projectile._y + vecShootDir._y;
}
}
function AimProjectile() {
var _local11 = new Vector();
_local11._x = _xmouse - (Stage.width / 2);
_local11._y = _ymouse - (Stage.height / 2);
var _local12 = Math.atan2(_local11._y, _local11._x);
var _local15 = (360 * _local12) / (Math.PI*2);
var _local6 = _root.gameBackground._width / 2;
_root.projectile._x = (_local6 * Math.cos(_local12)) + (Stage.width / 2);
_root.projectile._y = (_local6 * Math.sin(_local12)) + (Stage.height / 2);
_local11._x = (Stage.width / 2) - _root.projectile._x;
_local11._y = (Stage.height / 2) - _root.projectile._y;
_local12 = Math.atan2(_local11._y, _local11._x);
var _local14 = Math.cos(_local12) * 11;
var _local13 = Math.sin(_local12) * 11;
var _local9 = _root.projectile._x;
var _local10 = _root.projectile._y;
var _local5 = new Array(arrParticles.length);
var _local4 = 0;
while (_local4 < _local5.length) {
_local5[_local4] = 0;
_local4++;
}
var _local8 = 0;
while (_local8 < 70) {
_local9 = _local9 + _local14;
_local10 = _local10 + _local13;
_local4 = 0;
while (_local4 < arrParticles.length) {
var _local7 = (_root[arrParticles[_local4]]._width / 2) + 7.5;
var _local3 = _root[arrParticles[_local4]]._x - _local9;
var _local2 = _root[arrParticles[_local4]]._y - _local10;
_local6 = Math.sqrt((_local3 * _local3) + (_local2 * _local2));
if (_local6 <= _local7) {
_local5[_local4] = 1;
}
_local4++;
}
_local8++;
}
_local4 = 0;
while (_local4 < _local5.length) {
if (_local5[_local4] == 1) {
_root[arrParticles[_local4]].ArrowsOn(arrowDepth, _root.projectile._x, _root.projectile._y);
} else {
_root[arrParticles[_local4]].ArrowsOff();
}
_local4++;
}
}
function TurnOffAllArrows() {
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].ArrowsOff();
_local2++;
}
}
function NextArrowDepth() {
arrowDepth++;
if (arrowDepth > 39999) {
arrowDepth = 15000;
}
}
function DrawLines() {
_root.clear();
_root.lineStyle(2, 16777215, 50);
var _local2 = new Object();
var _local3 = new Object();
_local2.x = _root.projectile._x;
_local2.y = _root.projectile._y;
_local3.x = _xmouse;
_local3.y = _ymouse;
_root.moveTo(_local2.x, _local2.y);
_root.lineTo(_local3.x, _local3.y);
}
function Shoot() {
if ((intState == 1) && (_global.latestLevel != -1)) {
trace("in");
_root.clear();
saveX = _root.projectile._x;
saveY = _root.projectile._y;
var _local4 = new Vector();
_local4._x = (Stage.width / 2) - _root.projectile._x;
_local4._y = (Stage.height / 2) - _root.projectile._y;
var _local5 = Math.atan2(_local4._y, _local4._x);
vecShootDir._x = Math.cos(_local5) * 11;
vecShootDir._y = Math.sin(_local5) * 11;
var _local3 = 100;
do {
if (ProjectileOffScreen() != false) {
break;
}
_root.projectile._x = _root.projectile._x - vecShootDir._x;
_root.projectile._y = _root.projectile._y - vecShootDir._y;
_local3--;
} while (_local3 != 0);
var _local6 = (360 * _local5) / (Math.PI*2);
_root.projectile.gotoAndStop(2);
_root.projectile._rotation = _local6;
_root.gameBackground.gotoAndPlay("hide");
TurnOffAllArrows();
intState = 2;
}
}
function ProjectileOffScreen() {
var _local2 = false;
if (((_root.projectile._x + _root.projectile._width) < 0) || ((_root.projectile._x - _root.projectile._width) > Stage.width)) {
_local2 = true;
}
if (((_root.projectile._y + _root.projectile._height) < 0) || ((_root.projectile._y - _root.projectile._height) > Stage.height)) {
_local2 = true;
}
return(_local2);
}
function MoveProjectilesAndCollide() {
var _local4 = 0;
while (_local4 < arrProjectiles.length) {
_root[arrProjectiles[_local4].name]._x = _root[arrProjectiles[_local4].name]._x + (arrProjectiles[_local4].dX / 2);
_root[arrProjectiles[_local4].name]._y = _root[arrProjectiles[_local4].name]._y + (arrProjectiles[_local4].dY / 2);
if (((_root[arrProjectiles[_local4].name]._x + _root[arrProjectiles[_local4].name]._width) < 0) || ((_root[arrProjectiles[_local4].name]._x - _root[arrProjectiles[_local4].name]._width) > Stage.width)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
if (((_root[arrProjectiles[_local4].name]._y + _root[arrProjectiles[_local4].name]._height) < 0) || ((_root[arrProjectiles[_local4].name]._y - _root[arrProjectiles[_local4].name]._height) > Stage.height)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
_local4++;
}
var _local5 = new Array();
var _local3 = 0;
while (_local3 < arrProjectiles.length) {
_local4 = 0;
while (_local4 < arrParticles.length) {
if (_root[arrParticles[_local4]].hitTest(_root[arrProjectiles[_local3].name]._x, _root[arrProjectiles[_local3].name]._y, true) == true) {
_local5.push({name:arrParticles[_local4], X:arrProjectiles[_local3].X, Y:arrProjectiles[_local3].Y});
arrParticles.splice(_local4, 1);
_local4--;
_root[arrProjectiles[_local3].name].removeMovieClip();
arrProjectiles.splice(_local3, 1);
_local3--;
}
_local4++;
}
_local3++;
}
_local4 = 0;
while (_local4 < _local5.length) {
_root[_local5[_local4].name].Collision(_local5[_local4].X, _local5[_local4].Y);
_root[_local5[_local4].name].gotoAndStop(2);
_local4++;
}
_local4 = 0;
while (_local4 < arrProjectiles.length) {
_root[arrProjectiles[_local4].name]._x = _root[arrProjectiles[_local4].name]._x + (arrProjectiles[_local4].dX / 2);
_root[arrProjectiles[_local4].name]._y = _root[arrProjectiles[_local4].name]._y + (arrProjectiles[_local4].dY / 2);
if (((_root[arrProjectiles[_local4].name]._x + _root[arrProjectiles[_local4].name]._width) < 0) || ((_root[arrProjectiles[_local4].name]._x - _root[arrProjectiles[_local4].name]._width) > Stage.width)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
if (((_root[arrProjectiles[_local4].name]._y + _root[arrProjectiles[_local4].name]._height) < 0) || ((_root[arrProjectiles[_local4].name]._y - _root[arrProjectiles[_local4].name]._height) > Stage.height)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
_local4++;
}
_local5 = new Array();
_local3 = 0;
while (_local3 < arrProjectiles.length) {
_local4 = 0;
while (_local4 < arrParticles.length) {
if (_root[arrParticles[_local4]].hitTest(_root[arrProjectiles[_local3].name]._x, _root[arrProjectiles[_local3].name]._y, true) == true) {
_local5.push({name:arrParticles[_local4], X:arrProjectiles[_local3].X, Y:arrProjectiles[_local3].Y});
arrParticles.splice(_local4, 1);
_local4--;
_root[arrProjectiles[_local3].name].removeMovieClip();
arrProjectiles.splice(_local3, 1);
_local3--;
}
_local4++;
}
_local3++;
}
_local4 = 0;
while (_local4 < _local5.length) {
_root[_local5[_local4].name].Collision(_local5[_local4].X, _local5[_local4].Y);
_root[_local5[_local4].name].gotoAndStop(2);
_local4++;
}
if ((arrProjectiles.length == 0) && (projectileOver == true)) {
if (arrParticles.length != 0) {
intState = 3;
_root.messages_mc.gotoAndPlay("retry");
} else {
intState = 4;
var _local10 = ((_global.currentLevel + 5) - 15) / 5;
_global.levels[_local10] = 1;
var _local9 = SharedObject.getLocal("userData");
_local9.data.levelsCompleted = _global.levels;
_global.SoundManager.PlaySound("all");
_root.messages_mc.gotoAndPlay("next");
}
}
}
function LaunchProjectile(deltaX, deltaY, startX, startY, rot) {
var _local2 = "projectile_" + projectileDepth;
arrProjectiles.push({name:_local2, dX:deltaX, dY:deltaY, X:startX, Y:startY});
_root.attachMovie("shootingStar", _local2, projectileDepth);
_root[_local2]._x = startX;
_root[_local2]._y = startY;
_root[_local2]._rotation = rot;
projectileDepth++;
if (projectileDepth > 9999) {
projectileDepth = 5000;
}
}
stop();
var intState = 1;
var vecShootDir;
var arrParticles = new Array();
var arrProjectiles = new Array();
var arrParticlesReset = new Array();
var particleDepth = 1000;
var projectileDepth = 5000;
var arrowDepth = 15000;
var saveX = 0;
var saveY = 0;
var projectileOnScreen = false;
var projectileOver = false;
var saveDepth;
mouseListener = new Object();
mouseListener.onMouseDown = function () {
_root.Shoot();
};
Mouse.addListener(mouseListener);
Frame 80
function GameSetup() {
trace("%%%%%%%%");
trace((_global.currentLevel + " ----- ") + _global.latestLevel);
if (_global.latestLevel == -1) {
_root.gotoAndPlay("splash");
} else if ((_global.latestLevel != 0) && (_global.latestLevel != 20)) {
_global.currentLevel = _global.latestLevel;
_root.gotoAndPlay(_global.latestLevel);
_global.latestLevel = 0;
trace("go here");
} else if ((_global.latestLevel != 0) && (_global.latestLevel == 20)) {
_global.currentLevel = _global.latestLevel;
_global.latestLevel = 0;
}
if (_root.messages_mc.getDepth() != 50000) {
saveDepth = _root.messages_mc.getDepth();
}
vecShootDir = new Vector();
if (_global.musicOn == true) {
_global.myMusicPlayer.SetTrack("game");
_global.myMusicPlayer.SetMaxVolume(40);
_global.myMusicPlayer.PlayWithCrossFade(4);
}
}
function Mediator() {
_global.myMusicPlayer.RunPlayer();
switch (intState) {
case 1 :
AimProjectile();
if (_root.messages_mc.getDepth() != 50000) {
_root.messages_mc.swapDepths(50000);
trace(_root.messages_mc.getDepth());
}
break;
case 2 :
if (projectileOver == false) {
MoveProjectile();
}
DetectParticleCollisions();
MoveProjectilesAndCollide();
break;
case 3 :
if (Key.isDown(32)) {
Reset();
}
break;
case 4 :
if (!Key.isDown(32)) {
break;
}
Next();
}
}
function Reset() {
projectileDepth = 5000;
arrParticles = arrParticlesReset.slice();
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].gotoAndStop(1);
trace(arrParticles[_local2]);
_local2++;
}
trace("-----");
_root.projectile.gotoAndStop(1);
_root.gameBackground.gotoAndStop(1);
_root.messages_mc.gotoAndStop("hide");
projectileOver = false;
projectileOnScreen = false;
intState = 1;
}
function ExitGame() {
CleanupGame();
Mouse.removeListener(mouseListener);
_root.messages_mc.swapDepths(saveDepth);
_global.latestLevel = -1;
_root.gotoAndPlay("level1");
}
function Next() {
_global.currentLevel = _global.currentLevel + 5;
CleanupGame();
_root.messages_mc.swapDepths(saveDepth);
_root.gotoAndPlay(_global.currentLevel);
}
function CleanupGame() {
Mouse.removeListener(mouseListener);
Reset();
var _local3 = 10;
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].swapDepths(_local3);
_local3++;
_root[arrParticles[_local2]].removeMovieClip();
_local2++;
}
delete arrParticles;
arrParticles = new Array();
}
function DetectParticleCollisions() {
var _local3 = new Array();
var _local2 = 0;
while (_local2 < arrParticles.length) {
var _local4 = (_root[arrParticles[_local2]]._width / 2) + 7.5;
if (GetDistance(arrParticles[_local2], "projectile") <= _local4) {
_root[arrParticles[_local2]].Collision(saveX, saveY);
_local3.push(arrParticles[_local2]);
}
_local2++;
}
_local2 = 0;
while (_local2 < _local3.length) {
RemoveParticle(_local3[_local2]);
_root[_local3[_local2]].gotoAndStop(2);
_local2++;
}
}
function RemoveParticle(strName) {
var _local1 = 0;
while (_local1 < arrParticles.length) {
if (strName == arrParticles[_local1]) {
arrParticles.splice(_local1, 1);
break;
}
_local1++;
}
}
function GetDistance(targetA, targetB) {
var _local3 = _root[targetB]._x - _root[targetA]._x;
var _local2 = _root[targetB]._y - _root[targetA]._y;
return(Math.sqrt((_local3 * _local3) + (_local2 * _local2)));
}
function RegisterParticle(particleName) {
arrParticles.push(particleName);
arrParticlesReset.push(particleName);
particleDepth++;
return(particleDepth);
}
function MoveProjectile() {
if (ProjectileOffScreen() == false) {
projectileOnScreen = true;
_root.projectile._x = _root.projectile._x + vecShootDir._x;
_root.projectile._y = _root.projectile._y + vecShootDir._y;
} else if (projectileOnScreen == true) {
projectileOver = true;
} else {
_root.projectile._x = _root.projectile._x + vecShootDir._x;
_root.projectile._y = _root.projectile._y + vecShootDir._y;
}
}
function AimProjectile() {
var _local11 = new Vector();
_local11._x = _xmouse - (Stage.width / 2);
_local11._y = _ymouse - (Stage.height / 2);
var _local12 = Math.atan2(_local11._y, _local11._x);
var _local15 = (360 * _local12) / (Math.PI*2);
var _local6 = _root.gameBackground._width / 2;
_root.projectile._x = (_local6 * Math.cos(_local12)) + (Stage.width / 2);
_root.projectile._y = (_local6 * Math.sin(_local12)) + (Stage.height / 2);
_local11._x = (Stage.width / 2) - _root.projectile._x;
_local11._y = (Stage.height / 2) - _root.projectile._y;
_local12 = Math.atan2(_local11._y, _local11._x);
var _local14 = Math.cos(_local12) * 11;
var _local13 = Math.sin(_local12) * 11;
var _local9 = _root.projectile._x;
var _local10 = _root.projectile._y;
var _local5 = new Array(arrParticles.length);
var _local4 = 0;
while (_local4 < _local5.length) {
_local5[_local4] = 0;
_local4++;
}
var _local8 = 0;
while (_local8 < 70) {
_local9 = _local9 + _local14;
_local10 = _local10 + _local13;
_local4 = 0;
while (_local4 < arrParticles.length) {
var _local7 = (_root[arrParticles[_local4]]._width / 2) + 7.5;
var _local3 = _root[arrParticles[_local4]]._x - _local9;
var _local2 = _root[arrParticles[_local4]]._y - _local10;
_local6 = Math.sqrt((_local3 * _local3) + (_local2 * _local2));
if (_local6 <= _local7) {
_local5[_local4] = 1;
}
_local4++;
}
_local8++;
}
_local4 = 0;
while (_local4 < _local5.length) {
if (_local5[_local4] == 1) {
_root[arrParticles[_local4]].ArrowsOn(arrowDepth, _root.projectile._x, _root.projectile._y);
} else {
_root[arrParticles[_local4]].ArrowsOff();
}
_local4++;
}
}
function TurnOffAllArrows() {
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].ArrowsOff();
_local2++;
}
}
function NextArrowDepth() {
arrowDepth++;
if (arrowDepth > 39999) {
arrowDepth = 15000;
}
}
function DrawLines() {
_root.clear();
_root.lineStyle(2, 16777215, 50);
var _local2 = new Object();
var _local3 = new Object();
_local2.x = _root.projectile._x;
_local2.y = _root.projectile._y;
_local3.x = _xmouse;
_local3.y = _ymouse;
_root.moveTo(_local2.x, _local2.y);
_root.lineTo(_local3.x, _local3.y);
}
function Shoot() {
if ((intState == 1) && (_global.latestLevel != -1)) {
trace("in");
_root.clear();
saveX = _root.projectile._x;
saveY = _root.projectile._y;
var _local4 = new Vector();
_local4._x = (Stage.width / 2) - _root.projectile._x;
_local4._y = (Stage.height / 2) - _root.projectile._y;
var _local5 = Math.atan2(_local4._y, _local4._x);
vecShootDir._x = Math.cos(_local5) * 11;
vecShootDir._y = Math.sin(_local5) * 11;
var _local3 = 100;
do {
if (ProjectileOffScreen() != false) {
break;
}
_root.projectile._x = _root.projectile._x - vecShootDir._x;
_root.projectile._y = _root.projectile._y - vecShootDir._y;
_local3--;
} while (_local3 != 0);
var _local6 = (360 * _local5) / (Math.PI*2);
_root.projectile.gotoAndStop(2);
_root.projectile._rotation = _local6;
_root.gameBackground.gotoAndPlay("hide");
TurnOffAllArrows();
intState = 2;
}
}
function ProjectileOffScreen() {
var _local2 = false;
if (((_root.projectile._x + _root.projectile._width) < 0) || ((_root.projectile._x - _root.projectile._width) > Stage.width)) {
_local2 = true;
}
if (((_root.projectile._y + _root.projectile._height) < 0) || ((_root.projectile._y - _root.projectile._height) > Stage.height)) {
_local2 = true;
}
return(_local2);
}
function MoveProjectilesAndCollide() {
var _local4 = 0;
while (_local4 < arrProjectiles.length) {
_root[arrProjectiles[_local4].name]._x = _root[arrProjectiles[_local4].name]._x + (arrProjectiles[_local4].dX / 2);
_root[arrProjectiles[_local4].name]._y = _root[arrProjectiles[_local4].name]._y + (arrProjectiles[_local4].dY / 2);
if (((_root[arrProjectiles[_local4].name]._x + _root[arrProjectiles[_local4].name]._width) < 0) || ((_root[arrProjectiles[_local4].name]._x - _root[arrProjectiles[_local4].name]._width) > Stage.width)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
if (((_root[arrProjectiles[_local4].name]._y + _root[arrProjectiles[_local4].name]._height) < 0) || ((_root[arrProjectiles[_local4].name]._y - _root[arrProjectiles[_local4].name]._height) > Stage.height)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
_local4++;
}
var _local5 = new Array();
var _local3 = 0;
while (_local3 < arrProjectiles.length) {
_local4 = 0;
while (_local4 < arrParticles.length) {
if (_root[arrParticles[_local4]].hitTest(_root[arrProjectiles[_local3].name]._x, _root[arrProjectiles[_local3].name]._y, true) == true) {
_local5.push({name:arrParticles[_local4], X:arrProjectiles[_local3].X, Y:arrProjectiles[_local3].Y});
arrParticles.splice(_local4, 1);
_local4--;
_root[arrProjectiles[_local3].name].removeMovieClip();
arrProjectiles.splice(_local3, 1);
_local3--;
}
_local4++;
}
_local3++;
}
_local4 = 0;
while (_local4 < _local5.length) {
_root[_local5[_local4].name].Collision(_local5[_local4].X, _local5[_local4].Y);
_root[_local5[_local4].name].gotoAndStop(2);
_local4++;
}
_local4 = 0;
while (_local4 < arrProjectiles.length) {
_root[arrProjectiles[_local4].name]._x = _root[arrProjectiles[_local4].name]._x + (arrProjectiles[_local4].dX / 2);
_root[arrProjectiles[_local4].name]._y = _root[arrProjectiles[_local4].name]._y + (arrProjectiles[_local4].dY / 2);
if (((_root[arrProjectiles[_local4].name]._x + _root[arrProjectiles[_local4].name]._width) < 0) || ((_root[arrProjectiles[_local4].name]._x - _root[arrProjectiles[_local4].name]._width) > Stage.width)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
if (((_root[arrProjectiles[_local4].name]._y + _root[arrProjectiles[_local4].name]._height) < 0) || ((_root[arrProjectiles[_local4].name]._y - _root[arrProjectiles[_local4].name]._height) > Stage.height)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
_local4++;
}
_local5 = new Array();
_local3 = 0;
while (_local3 < arrProjectiles.length) {
_local4 = 0;
while (_local4 < arrParticles.length) {
if (_root[arrParticles[_local4]].hitTest(_root[arrProjectiles[_local3].name]._x, _root[arrProjectiles[_local3].name]._y, true) == true) {
_local5.push({name:arrParticles[_local4], X:arrProjectiles[_local3].X, Y:arrProjectiles[_local3].Y});
arrParticles.splice(_local4, 1);
_local4--;
_root[arrProjectiles[_local3].name].removeMovieClip();
arrProjectiles.splice(_local3, 1);
_local3--;
}
_local4++;
}
_local3++;
}
_local4 = 0;
while (_local4 < _local5.length) {
_root[_local5[_local4].name].Collision(_local5[_local4].X, _local5[_local4].Y);
_root[_local5[_local4].name].gotoAndStop(2);
_local4++;
}
if ((arrProjectiles.length == 0) && (projectileOver == true)) {
if (arrParticles.length != 0) {
intState = 3;
_root.messages_mc.gotoAndPlay("retry");
} else {
intState = 4;
var _local10 = ((_global.currentLevel + 5) - 15) / 5;
_global.levels[_local10] = 1;
var _local9 = SharedObject.getLocal("userData");
_local9.data.levelsCompleted = _global.levels;
_global.SoundManager.PlaySound("all");
_root.messages_mc.gotoAndPlay("next");
}
}
}
function LaunchProjectile(deltaX, deltaY, startX, startY, rot) {
var _local2 = "projectile_" + projectileDepth;
arrProjectiles.push({name:_local2, dX:deltaX, dY:deltaY, X:startX, Y:startY});
_root.attachMovie("shootingStar", _local2, projectileDepth);
_root[_local2]._x = startX;
_root[_local2]._y = startY;
_root[_local2]._rotation = rot;
projectileDepth++;
if (projectileDepth > 9999) {
projectileDepth = 5000;
}
}
stop();
var intState = 1;
var vecShootDir;
var arrParticles = new Array();
var arrProjectiles = new Array();
var arrParticlesReset = new Array();
var particleDepth = 1000;
var projectileDepth = 5000;
var arrowDepth = 15000;
var saveX = 0;
var saveY = 0;
var projectileOnScreen = false;
var projectileOver = false;
var saveDepth;
mouseListener = new Object();
mouseListener.onMouseDown = function () {
_root.Shoot();
};
Mouse.addListener(mouseListener);
Frame 85
function GameSetup() {
trace("%%%%%%%%");
trace((_global.currentLevel + " ----- ") + _global.latestLevel);
if (_global.latestLevel == -1) {
_root.gotoAndPlay("splash");
} else if ((_global.latestLevel != 0) && (_global.latestLevel != 20)) {
_global.currentLevel = _global.latestLevel;
_root.gotoAndPlay(_global.latestLevel);
_global.latestLevel = 0;
trace("go here");
} else if ((_global.latestLevel != 0) && (_global.latestLevel == 20)) {
_global.currentLevel = _global.latestLevel;
_global.latestLevel = 0;
}
if (_root.messages_mc.getDepth() != 50000) {
saveDepth = _root.messages_mc.getDepth();
}
vecShootDir = new Vector();
if (_global.musicOn == true) {
_global.myMusicPlayer.SetTrack("game");
_global.myMusicPlayer.SetMaxVolume(40);
_global.myMusicPlayer.PlayWithCrossFade(4);
}
}
function Mediator() {
_global.myMusicPlayer.RunPlayer();
switch (intState) {
case 1 :
AimProjectile();
if (_root.messages_mc.getDepth() != 50000) {
_root.messages_mc.swapDepths(50000);
trace(_root.messages_mc.getDepth());
}
break;
case 2 :
if (projectileOver == false) {
MoveProjectile();
}
DetectParticleCollisions();
MoveProjectilesAndCollide();
break;
case 3 :
if (Key.isDown(32)) {
Reset();
}
break;
case 4 :
if (!Key.isDown(32)) {
break;
}
Next();
}
}
function Reset() {
projectileDepth = 5000;
arrParticles = arrParticlesReset.slice();
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].gotoAndStop(1);
trace(arrParticles[_local2]);
_local2++;
}
trace("-----");
_root.projectile.gotoAndStop(1);
_root.gameBackground.gotoAndStop(1);
_root.messages_mc.gotoAndStop("hide");
projectileOver = false;
projectileOnScreen = false;
intState = 1;
}
function ExitGame() {
CleanupGame();
Mouse.removeListener(mouseListener);
_root.messages_mc.swapDepths(saveDepth);
_global.latestLevel = -1;
_root.gotoAndPlay("level1");
}
function Next() {
_global.currentLevel = _global.currentLevel + 5;
CleanupGame();
_root.messages_mc.swapDepths(saveDepth);
_root.gotoAndPlay(_global.currentLevel);
}
function CleanupGame() {
Mouse.removeListener(mouseListener);
Reset();
var _local3 = 10;
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].swapDepths(_local3);
_local3++;
_root[arrParticles[_local2]].removeMovieClip();
_local2++;
}
delete arrParticles;
arrParticles = new Array();
}
function DetectParticleCollisions() {
var _local3 = new Array();
var _local2 = 0;
while (_local2 < arrParticles.length) {
var _local4 = (_root[arrParticles[_local2]]._width / 2) + 7.5;
if (GetDistance(arrParticles[_local2], "projectile") <= _local4) {
_root[arrParticles[_local2]].Collision(saveX, saveY);
_local3.push(arrParticles[_local2]);
}
_local2++;
}
_local2 = 0;
while (_local2 < _local3.length) {
RemoveParticle(_local3[_local2]);
_root[_local3[_local2]].gotoAndStop(2);
_local2++;
}
}
function RemoveParticle(strName) {
var _local1 = 0;
while (_local1 < arrParticles.length) {
if (strName == arrParticles[_local1]) {
arrParticles.splice(_local1, 1);
break;
}
_local1++;
}
}
function GetDistance(targetA, targetB) {
var _local3 = _root[targetB]._x - _root[targetA]._x;
var _local2 = _root[targetB]._y - _root[targetA]._y;
return(Math.sqrt((_local3 * _local3) + (_local2 * _local2)));
}
function RegisterParticle(particleName) {
arrParticles.push(particleName);
arrParticlesReset.push(particleName);
particleDepth++;
return(particleDepth);
}
function MoveProjectile() {
if (ProjectileOffScreen() == false) {
projectileOnScreen = true;
_root.projectile._x = _root.projectile._x + vecShootDir._x;
_root.projectile._y = _root.projectile._y + vecShootDir._y;
} else if (projectileOnScreen == true) {
projectileOver = true;
} else {
_root.projectile._x = _root.projectile._x + vecShootDir._x;
_root.projectile._y = _root.projectile._y + vecShootDir._y;
}
}
function AimProjectile() {
var _local11 = new Vector();
_local11._x = _xmouse - (Stage.width / 2);
_local11._y = _ymouse - (Stage.height / 2);
var _local12 = Math.atan2(_local11._y, _local11._x);
var _local15 = (360 * _local12) / (Math.PI*2);
var _local6 = _root.gameBackground._width / 2;
_root.projectile._x = (_local6 * Math.cos(_local12)) + (Stage.width / 2);
_root.projectile._y = (_local6 * Math.sin(_local12)) + (Stage.height / 2);
_local11._x = (Stage.width / 2) - _root.projectile._x;
_local11._y = (Stage.height / 2) - _root.projectile._y;
_local12 = Math.atan2(_local11._y, _local11._x);
var _local14 = Math.cos(_local12) * 11;
var _local13 = Math.sin(_local12) * 11;
var _local9 = _root.projectile._x;
var _local10 = _root.projectile._y;
var _local5 = new Array(arrParticles.length);
var _local4 = 0;
while (_local4 < _local5.length) {
_local5[_local4] = 0;
_local4++;
}
var _local8 = 0;
while (_local8 < 70) {
_local9 = _local9 + _local14;
_local10 = _local10 + _local13;
_local4 = 0;
while (_local4 < arrParticles.length) {
var _local7 = (_root[arrParticles[_local4]]._width / 2) + 7.5;
var _local3 = _root[arrParticles[_local4]]._x - _local9;
var _local2 = _root[arrParticles[_local4]]._y - _local10;
_local6 = Math.sqrt((_local3 * _local3) + (_local2 * _local2));
if (_local6 <= _local7) {
_local5[_local4] = 1;
}
_local4++;
}
_local8++;
}
_local4 = 0;
while (_local4 < _local5.length) {
if (_local5[_local4] == 1) {
_root[arrParticles[_local4]].ArrowsOn(arrowDepth, _root.projectile._x, _root.projectile._y);
} else {
_root[arrParticles[_local4]].ArrowsOff();
}
_local4++;
}
}
function TurnOffAllArrows() {
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].ArrowsOff();
_local2++;
}
}
function NextArrowDepth() {
arrowDepth++;
if (arrowDepth > 39999) {
arrowDepth = 15000;
}
}
function DrawLines() {
_root.clear();
_root.lineStyle(2, 16777215, 50);
var _local2 = new Object();
var _local3 = new Object();
_local2.x = _root.projectile._x;
_local2.y = _root.projectile._y;
_local3.x = _xmouse;
_local3.y = _ymouse;
_root.moveTo(_local2.x, _local2.y);
_root.lineTo(_local3.x, _local3.y);
}
function Shoot() {
if ((intState == 1) && (_global.latestLevel != -1)) {
trace("in");
_root.clear();
saveX = _root.projectile._x;
saveY = _root.projectile._y;
var _local4 = new Vector();
_local4._x = (Stage.width / 2) - _root.projectile._x;
_local4._y = (Stage.height / 2) - _root.projectile._y;
var _local5 = Math.atan2(_local4._y, _local4._x);
vecShootDir._x = Math.cos(_local5) * 11;
vecShootDir._y = Math.sin(_local5) * 11;
var _local3 = 100;
do {
if (ProjectileOffScreen() != false) {
break;
}
_root.projectile._x = _root.projectile._x - vecShootDir._x;
_root.projectile._y = _root.projectile._y - vecShootDir._y;
_local3--;
} while (_local3 != 0);
var _local6 = (360 * _local5) / (Math.PI*2);
_root.projectile.gotoAndStop(2);
_root.projectile._rotation = _local6;
_root.gameBackground.gotoAndPlay("hide");
TurnOffAllArrows();
intState = 2;
}
}
function ProjectileOffScreen() {
var _local2 = false;
if (((_root.projectile._x + _root.projectile._width) < 0) || ((_root.projectile._x - _root.projectile._width) > Stage.width)) {
_local2 = true;
}
if (((_root.projectile._y + _root.projectile._height) < 0) || ((_root.projectile._y - _root.projectile._height) > Stage.height)) {
_local2 = true;
}
return(_local2);
}
function MoveProjectilesAndCollide() {
var _local4 = 0;
while (_local4 < arrProjectiles.length) {
_root[arrProjectiles[_local4].name]._x = _root[arrProjectiles[_local4].name]._x + (arrProjectiles[_local4].dX / 2);
_root[arrProjectiles[_local4].name]._y = _root[arrProjectiles[_local4].name]._y + (arrProjectiles[_local4].dY / 2);
if (((_root[arrProjectiles[_local4].name]._x + _root[arrProjectiles[_local4].name]._width) < 0) || ((_root[arrProjectiles[_local4].name]._x - _root[arrProjectiles[_local4].name]._width) > Stage.width)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
if (((_root[arrProjectiles[_local4].name]._y + _root[arrProjectiles[_local4].name]._height) < 0) || ((_root[arrProjectiles[_local4].name]._y - _root[arrProjectiles[_local4].name]._height) > Stage.height)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
_local4++;
}
var _local5 = new Array();
var _local3 = 0;
while (_local3 < arrProjectiles.length) {
_local4 = 0;
while (_local4 < arrParticles.length) {
if (_root[arrParticles[_local4]].hitTest(_root[arrProjectiles[_local3].name]._x, _root[arrProjectiles[_local3].name]._y, true) == true) {
_local5.push({name:arrParticles[_local4], X:arrProjectiles[_local3].X, Y:arrProjectiles[_local3].Y});
arrParticles.splice(_local4, 1);
_local4--;
_root[arrProjectiles[_local3].name].removeMovieClip();
arrProjectiles.splice(_local3, 1);
_local3--;
}
_local4++;
}
_local3++;
}
_local4 = 0;
while (_local4 < _local5.length) {
_root[_local5[_local4].name].Collision(_local5[_local4].X, _local5[_local4].Y);
_root[_local5[_local4].name].gotoAndStop(2);
_local4++;
}
_local4 = 0;
while (_local4 < arrProjectiles.length) {
_root[arrProjectiles[_local4].name]._x = _root[arrProjectiles[_local4].name]._x + (arrProjectiles[_local4].dX / 2);
_root[arrProjectiles[_local4].name]._y = _root[arrProjectiles[_local4].name]._y + (arrProjectiles[_local4].dY / 2);
if (((_root[arrProjectiles[_local4].name]._x + _root[arrProjectiles[_local4].name]._width) < 0) || ((_root[arrProjectiles[_local4].name]._x - _root[arrProjectiles[_local4].name]._width) > Stage.width)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
if (((_root[arrProjectiles[_local4].name]._y + _root[arrProjectiles[_local4].name]._height) < 0) || ((_root[arrProjectiles[_local4].name]._y - _root[arrProjectiles[_local4].name]._height) > Stage.height)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
_local4++;
}
_local5 = new Array();
_local3 = 0;
while (_local3 < arrProjectiles.length) {
_local4 = 0;
while (_local4 < arrParticles.length) {
if (_root[arrParticles[_local4]].hitTest(_root[arrProjectiles[_local3].name]._x, _root[arrProjectiles[_local3].name]._y, true) == true) {
_local5.push({name:arrParticles[_local4], X:arrProjectiles[_local3].X, Y:arrProjectiles[_local3].Y});
arrParticles.splice(_local4, 1);
_local4--;
_root[arrProjectiles[_local3].name].removeMovieClip();
arrProjectiles.splice(_local3, 1);
_local3--;
}
_local4++;
}
_local3++;
}
_local4 = 0;
while (_local4 < _local5.length) {
_root[_local5[_local4].name].Collision(_local5[_local4].X, _local5[_local4].Y);
_root[_local5[_local4].name].gotoAndStop(2);
_local4++;
}
if ((arrProjectiles.length == 0) && (projectileOver == true)) {
if (arrParticles.length != 0) {
intState = 3;
_root.messages_mc.gotoAndPlay("retry");
} else {
intState = 4;
var _local10 = ((_global.currentLevel + 5) - 15) / 5;
_global.levels[_local10] = 1;
var _local9 = SharedObject.getLocal("userData");
_local9.data.levelsCompleted = _global.levels;
_global.SoundManager.PlaySound("all");
_root.messages_mc.gotoAndPlay("next");
}
}
}
function LaunchProjectile(deltaX, deltaY, startX, startY, rot) {
var _local2 = "projectile_" + projectileDepth;
arrProjectiles.push({name:_local2, dX:deltaX, dY:deltaY, X:startX, Y:startY});
_root.attachMovie("shootingStar", _local2, projectileDepth);
_root[_local2]._x = startX;
_root[_local2]._y = startY;
_root[_local2]._rotation = rot;
projectileDepth++;
if (projectileDepth > 9999) {
projectileDepth = 5000;
}
}
stop();
var intState = 1;
var vecShootDir;
var arrParticles = new Array();
var arrProjectiles = new Array();
var arrParticlesReset = new Array();
var particleDepth = 1000;
var projectileDepth = 5000;
var arrowDepth = 15000;
var saveX = 0;
var saveY = 0;
var projectileOnScreen = false;
var projectileOver = false;
var saveDepth;
mouseListener = new Object();
mouseListener.onMouseDown = function () {
_root.Shoot();
};
Mouse.addListener(mouseListener);
Frame 90
function GameSetup() {
trace("%%%%%%%%");
trace((_global.currentLevel + " ----- ") + _global.latestLevel);
if (_global.latestLevel == -1) {
_root.gotoAndPlay("splash");
} else if ((_global.latestLevel != 0) && (_global.latestLevel != 20)) {
_global.currentLevel = _global.latestLevel;
_root.gotoAndPlay(_global.latestLevel);
_global.latestLevel = 0;
trace("go here");
} else if ((_global.latestLevel != 0) && (_global.latestLevel == 20)) {
_global.currentLevel = _global.latestLevel;
_global.latestLevel = 0;
}
if (_root.messages_mc.getDepth() != 50000) {
saveDepth = _root.messages_mc.getDepth();
}
vecShootDir = new Vector();
if (_global.musicOn == true) {
_global.myMusicPlayer.SetTrack("game");
_global.myMusicPlayer.SetMaxVolume(40);
_global.myMusicPlayer.PlayWithCrossFade(4);
}
}
function Mediator() {
_global.myMusicPlayer.RunPlayer();
switch (intState) {
case 1 :
AimProjectile();
if (_root.messages_mc.getDepth() != 50000) {
_root.messages_mc.swapDepths(50000);
trace(_root.messages_mc.getDepth());
}
break;
case 2 :
if (projectileOver == false) {
MoveProjectile();
}
DetectParticleCollisions();
MoveProjectilesAndCollide();
break;
case 3 :
if (Key.isDown(32)) {
Reset();
}
break;
case 4 :
if (!Key.isDown(32)) {
break;
}
Next();
}
}
function Reset() {
projectileDepth = 5000;
arrParticles = arrParticlesReset.slice();
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].gotoAndStop(1);
trace(arrParticles[_local2]);
_local2++;
}
trace("-----");
_root.projectile.gotoAndStop(1);
_root.gameBackground.gotoAndStop(1);
_root.messages_mc.gotoAndStop("hide");
projectileOver = false;
projectileOnScreen = false;
intState = 1;
}
function ExitGame() {
CleanupGame();
Mouse.removeListener(mouseListener);
_root.messages_mc.swapDepths(saveDepth);
_global.latestLevel = -1;
_root.gotoAndPlay("level1");
}
function Next() {
_global.currentLevel = _global.currentLevel + 5;
CleanupGame();
_root.messages_mc.swapDepths(saveDepth);
_root.gotoAndPlay(_global.currentLevel);
}
function CleanupGame() {
Mouse.removeListener(mouseListener);
Reset();
var _local3 = 10;
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].swapDepths(_local3);
_local3++;
_root[arrParticles[_local2]].removeMovieClip();
_local2++;
}
delete arrParticles;
arrParticles = new Array();
}
function DetectParticleCollisions() {
var _local3 = new Array();
var _local2 = 0;
while (_local2 < arrParticles.length) {
var _local4 = (_root[arrParticles[_local2]]._width / 2) + 7.5;
if (GetDistance(arrParticles[_local2], "projectile") <= _local4) {
_root[arrParticles[_local2]].Collision(saveX, saveY);
_local3.push(arrParticles[_local2]);
}
_local2++;
}
_local2 = 0;
while (_local2 < _local3.length) {
RemoveParticle(_local3[_local2]);
_root[_local3[_local2]].gotoAndStop(2);
_local2++;
}
}
function RemoveParticle(strName) {
var _local1 = 0;
while (_local1 < arrParticles.length) {
if (strName == arrParticles[_local1]) {
arrParticles.splice(_local1, 1);
break;
}
_local1++;
}
}
function GetDistance(targetA, targetB) {
var _local3 = _root[targetB]._x - _root[targetA]._x;
var _local2 = _root[targetB]._y - _root[targetA]._y;
return(Math.sqrt((_local3 * _local3) + (_local2 * _local2)));
}
function RegisterParticle(particleName) {
arrParticles.push(particleName);
arrParticlesReset.push(particleName);
particleDepth++;
return(particleDepth);
}
function MoveProjectile() {
if (ProjectileOffScreen() == false) {
projectileOnScreen = true;
_root.projectile._x = _root.projectile._x + vecShootDir._x;
_root.projectile._y = _root.projectile._y + vecShootDir._y;
} else if (projectileOnScreen == true) {
projectileOver = true;
} else {
_root.projectile._x = _root.projectile._x + vecShootDir._x;
_root.projectile._y = _root.projectile._y + vecShootDir._y;
}
}
function AimProjectile() {
var _local11 = new Vector();
_local11._x = _xmouse - (Stage.width / 2);
_local11._y = _ymouse - (Stage.height / 2);
var _local12 = Math.atan2(_local11._y, _local11._x);
var _local15 = (360 * _local12) / (Math.PI*2);
var _local6 = _root.gameBackground._width / 2;
_root.projectile._x = (_local6 * Math.cos(_local12)) + (Stage.width / 2);
_root.projectile._y = (_local6 * Math.sin(_local12)) + (Stage.height / 2);
_local11._x = (Stage.width / 2) - _root.projectile._x;
_local11._y = (Stage.height / 2) - _root.projectile._y;
_local12 = Math.atan2(_local11._y, _local11._x);
var _local14 = Math.cos(_local12) * 11;
var _local13 = Math.sin(_local12) * 11;
var _local9 = _root.projectile._x;
var _local10 = _root.projectile._y;
var _local5 = new Array(arrParticles.length);
var _local4 = 0;
while (_local4 < _local5.length) {
_local5[_local4] = 0;
_local4++;
}
var _local8 = 0;
while (_local8 < 70) {
_local9 = _local9 + _local14;
_local10 = _local10 + _local13;
_local4 = 0;
while (_local4 < arrParticles.length) {
var _local7 = (_root[arrParticles[_local4]]._width / 2) + 7.5;
var _local3 = _root[arrParticles[_local4]]._x - _local9;
var _local2 = _root[arrParticles[_local4]]._y - _local10;
_local6 = Math.sqrt((_local3 * _local3) + (_local2 * _local2));
if (_local6 <= _local7) {
_local5[_local4] = 1;
}
_local4++;
}
_local8++;
}
_local4 = 0;
while (_local4 < _local5.length) {
if (_local5[_local4] == 1) {
_root[arrParticles[_local4]].ArrowsOn(arrowDepth, _root.projectile._x, _root.projectile._y);
} else {
_root[arrParticles[_local4]].ArrowsOff();
}
_local4++;
}
}
function TurnOffAllArrows() {
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].ArrowsOff();
_local2++;
}
}
function NextArrowDepth() {
arrowDepth++;
if (arrowDepth > 39999) {
arrowDepth = 15000;
}
}
function DrawLines() {
_root.clear();
_root.lineStyle(2, 16777215, 50);
var _local2 = new Object();
var _local3 = new Object();
_local2.x = _root.projectile._x;
_local2.y = _root.projectile._y;
_local3.x = _xmouse;
_local3.y = _ymouse;
_root.moveTo(_local2.x, _local2.y);
_root.lineTo(_local3.x, _local3.y);
}
function Shoot() {
if ((intState == 1) && (_global.latestLevel != -1)) {
trace("in");
_root.clear();
saveX = _root.projectile._x;
saveY = _root.projectile._y;
var _local4 = new Vector();
_local4._x = (Stage.width / 2) - _root.projectile._x;
_local4._y = (Stage.height / 2) - _root.projectile._y;
var _local5 = Math.atan2(_local4._y, _local4._x);
vecShootDir._x = Math.cos(_local5) * 11;
vecShootDir._y = Math.sin(_local5) * 11;
var _local3 = 100;
do {
if (ProjectileOffScreen() != false) {
break;
}
_root.projectile._x = _root.projectile._x - vecShootDir._x;
_root.projectile._y = _root.projectile._y - vecShootDir._y;
_local3--;
} while (_local3 != 0);
var _local6 = (360 * _local5) / (Math.PI*2);
_root.projectile.gotoAndStop(2);
_root.projectile._rotation = _local6;
_root.gameBackground.gotoAndPlay("hide");
TurnOffAllArrows();
intState = 2;
}
}
function ProjectileOffScreen() {
var _local2 = false;
if (((_root.projectile._x + _root.projectile._width) < 0) || ((_root.projectile._x - _root.projectile._width) > Stage.width)) {
_local2 = true;
}
if (((_root.projectile._y + _root.projectile._height) < 0) || ((_root.projectile._y - _root.projectile._height) > Stage.height)) {
_local2 = true;
}
return(_local2);
}
function MoveProjectilesAndCollide() {
var _local4 = 0;
while (_local4 < arrProjectiles.length) {
_root[arrProjectiles[_local4].name]._x = _root[arrProjectiles[_local4].name]._x + (arrProjectiles[_local4].dX / 2);
_root[arrProjectiles[_local4].name]._y = _root[arrProjectiles[_local4].name]._y + (arrProjectiles[_local4].dY / 2);
if (((_root[arrProjectiles[_local4].name]._x + _root[arrProjectiles[_local4].name]._width) < 0) || ((_root[arrProjectiles[_local4].name]._x - _root[arrProjectiles[_local4].name]._width) > Stage.width)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
if (((_root[arrProjectiles[_local4].name]._y + _root[arrProjectiles[_local4].name]._height) < 0) || ((_root[arrProjectiles[_local4].name]._y - _root[arrProjectiles[_local4].name]._height) > Stage.height)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
_local4++;
}
var _local5 = new Array();
var _local3 = 0;
while (_local3 < arrProjectiles.length) {
_local4 = 0;
while (_local4 < arrParticles.length) {
if (_root[arrParticles[_local4]].hitTest(_root[arrProjectiles[_local3].name]._x, _root[arrProjectiles[_local3].name]._y, true) == true) {
_local5.push({name:arrParticles[_local4], X:arrProjectiles[_local3].X, Y:arrProjectiles[_local3].Y});
arrParticles.splice(_local4, 1);
_local4--;
_root[arrProjectiles[_local3].name].removeMovieClip();
arrProjectiles.splice(_local3, 1);
_local3--;
}
_local4++;
}
_local3++;
}
_local4 = 0;
while (_local4 < _local5.length) {
_root[_local5[_local4].name].Collision(_local5[_local4].X, _local5[_local4].Y);
_root[_local5[_local4].name].gotoAndStop(2);
_local4++;
}
_local4 = 0;
while (_local4 < arrProjectiles.length) {
_root[arrProjectiles[_local4].name]._x = _root[arrProjectiles[_local4].name]._x + (arrProjectiles[_local4].dX / 2);
_root[arrProjectiles[_local4].name]._y = _root[arrProjectiles[_local4].name]._y + (arrProjectiles[_local4].dY / 2);
if (((_root[arrProjectiles[_local4].name]._x + _root[arrProjectiles[_local4].name]._width) < 0) || ((_root[arrProjectiles[_local4].name]._x - _root[arrProjectiles[_local4].name]._width) > Stage.width)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
if (((_root[arrProjectiles[_local4].name]._y + _root[arrProjectiles[_local4].name]._height) < 0) || ((_root[arrProjectiles[_local4].name]._y - _root[arrProjectiles[_local4].name]._height) > Stage.height)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
_local4++;
}
_local5 = new Array();
_local3 = 0;
while (_local3 < arrProjectiles.length) {
_local4 = 0;
while (_local4 < arrParticles.length) {
if (_root[arrParticles[_local4]].hitTest(_root[arrProjectiles[_local3].name]._x, _root[arrProjectiles[_local3].name]._y, true) == true) {
_local5.push({name:arrParticles[_local4], X:arrProjectiles[_local3].X, Y:arrProjectiles[_local3].Y});
arrParticles.splice(_local4, 1);
_local4--;
_root[arrProjectiles[_local3].name].removeMovieClip();
arrProjectiles.splice(_local3, 1);
_local3--;
}
_local4++;
}
_local3++;
}
_local4 = 0;
while (_local4 < _local5.length) {
_root[_local5[_local4].name].Collision(_local5[_local4].X, _local5[_local4].Y);
_root[_local5[_local4].name].gotoAndStop(2);
_local4++;
}
if ((arrProjectiles.length == 0) && (projectileOver == true)) {
if (arrParticles.length != 0) {
intState = 3;
_root.messages_mc.gotoAndPlay("retry");
} else {
intState = 4;
var _local10 = ((_global.currentLevel + 5) - 15) / 5;
_global.levels[_local10] = 1;
var _local9 = SharedObject.getLocal("userData");
_local9.data.levelsCompleted = _global.levels;
_global.SoundManager.PlaySound("all");
_root.messages_mc.gotoAndPlay("next");
}
}
}
function LaunchProjectile(deltaX, deltaY, startX, startY, rot) {
var _local2 = "projectile_" + projectileDepth;
arrProjectiles.push({name:_local2, dX:deltaX, dY:deltaY, X:startX, Y:startY});
_root.attachMovie("shootingStar", _local2, projectileDepth);
_root[_local2]._x = startX;
_root[_local2]._y = startY;
_root[_local2]._rotation = rot;
projectileDepth++;
if (projectileDepth > 9999) {
projectileDepth = 5000;
}
}
stop();
var intState = 1;
var vecShootDir;
var arrParticles = new Array();
var arrProjectiles = new Array();
var arrParticlesReset = new Array();
var particleDepth = 1000;
var projectileDepth = 5000;
var arrowDepth = 15000;
var saveX = 0;
var saveY = 0;
var projectileOnScreen = false;
var projectileOver = false;
var saveDepth;
mouseListener = new Object();
mouseListener.onMouseDown = function () {
_root.Shoot();
};
Mouse.addListener(mouseListener);
Frame 95
function GameSetup() {
trace("%%%%%%%%");
trace((_global.currentLevel + " ----- ") + _global.latestLevel);
if (_global.latestLevel == -1) {
_root.gotoAndPlay("splash");
} else if ((_global.latestLevel != 0) && (_global.latestLevel != 20)) {
_global.currentLevel = _global.latestLevel;
_root.gotoAndPlay(_global.latestLevel);
_global.latestLevel = 0;
trace("go here");
} else if ((_global.latestLevel != 0) && (_global.latestLevel == 20)) {
_global.currentLevel = _global.latestLevel;
_global.latestLevel = 0;
}
if (_root.messages_mc.getDepth() != 50000) {
saveDepth = _root.messages_mc.getDepth();
}
vecShootDir = new Vector();
if (_global.musicOn == true) {
_global.myMusicPlayer.SetTrack("game");
_global.myMusicPlayer.SetMaxVolume(40);
_global.myMusicPlayer.PlayWithCrossFade(4);
}
}
function Mediator() {
_global.myMusicPlayer.RunPlayer();
switch (intState) {
case 1 :
AimProjectile();
if (_root.messages_mc.getDepth() != 50000) {
_root.messages_mc.swapDepths(50000);
trace(_root.messages_mc.getDepth());
}
break;
case 2 :
if (projectileOver == false) {
MoveProjectile();
}
DetectParticleCollisions();
MoveProjectilesAndCollide();
break;
case 3 :
if (Key.isDown(32)) {
Reset();
}
break;
case 4 :
if (!Key.isDown(32)) {
break;
}
Next();
}
}
function Reset() {
projectileDepth = 5000;
arrParticles = arrParticlesReset.slice();
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].gotoAndStop(1);
trace(arrParticles[_local2]);
_local2++;
}
trace("-----");
_root.projectile.gotoAndStop(1);
_root.gameBackground.gotoAndStop(1);
_root.messages_mc.gotoAndStop("hide");
projectileOver = false;
projectileOnScreen = false;
intState = 1;
}
function ExitGame() {
CleanupGame();
Mouse.removeListener(mouseListener);
_root.messages_mc.swapDepths(saveDepth);
_global.latestLevel = -1;
_root.gotoAndPlay("level1");
}
function Next() {
_global.currentLevel = _global.currentLevel + 5;
CleanupGame();
_root.messages_mc.swapDepths(saveDepth);
_root.gotoAndPlay(_global.currentLevel);
}
function CleanupGame() {
Mouse.removeListener(mouseListener);
Reset();
var _local3 = 10;
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].swapDepths(_local3);
_local3++;
_root[arrParticles[_local2]].removeMovieClip();
_local2++;
}
delete arrParticles;
arrParticles = new Array();
}
function DetectParticleCollisions() {
var _local3 = new Array();
var _local2 = 0;
while (_local2 < arrParticles.length) {
var _local4 = (_root[arrParticles[_local2]]._width / 2) + 7.5;
if (GetDistance(arrParticles[_local2], "projectile") <= _local4) {
_root[arrParticles[_local2]].Collision(saveX, saveY);
_local3.push(arrParticles[_local2]);
}
_local2++;
}
_local2 = 0;
while (_local2 < _local3.length) {
RemoveParticle(_local3[_local2]);
_root[_local3[_local2]].gotoAndStop(2);
_local2++;
}
}
function RemoveParticle(strName) {
var _local1 = 0;
while (_local1 < arrParticles.length) {
if (strName == arrParticles[_local1]) {
arrParticles.splice(_local1, 1);
break;
}
_local1++;
}
}
function GetDistance(targetA, targetB) {
var _local3 = _root[targetB]._x - _root[targetA]._x;
var _local2 = _root[targetB]._y - _root[targetA]._y;
return(Math.sqrt((_local3 * _local3) + (_local2 * _local2)));
}
function RegisterParticle(particleName) {
arrParticles.push(particleName);
arrParticlesReset.push(particleName);
particleDepth++;
return(particleDepth);
}
function MoveProjectile() {
if (ProjectileOffScreen() == false) {
projectileOnScreen = true;
_root.projectile._x = _root.projectile._x + vecShootDir._x;
_root.projectile._y = _root.projectile._y + vecShootDir._y;
} else if (projectileOnScreen == true) {
projectileOver = true;
} else {
_root.projectile._x = _root.projectile._x + vecShootDir._x;
_root.projectile._y = _root.projectile._y + vecShootDir._y;
}
}
function AimProjectile() {
var _local11 = new Vector();
_local11._x = _xmouse - (Stage.width / 2);
_local11._y = _ymouse - (Stage.height / 2);
var _local12 = Math.atan2(_local11._y, _local11._x);
var _local15 = (360 * _local12) / (Math.PI*2);
var _local6 = _root.gameBackground._width / 2;
_root.projectile._x = (_local6 * Math.cos(_local12)) + (Stage.width / 2);
_root.projectile._y = (_local6 * Math.sin(_local12)) + (Stage.height / 2);
_local11._x = (Stage.width / 2) - _root.projectile._x;
_local11._y = (Stage.height / 2) - _root.projectile._y;
_local12 = Math.atan2(_local11._y, _local11._x);
var _local14 = Math.cos(_local12) * 11;
var _local13 = Math.sin(_local12) * 11;
var _local9 = _root.projectile._x;
var _local10 = _root.projectile._y;
var _local5 = new Array(arrParticles.length);
var _local4 = 0;
while (_local4 < _local5.length) {
_local5[_local4] = 0;
_local4++;
}
var _local8 = 0;
while (_local8 < 70) {
_local9 = _local9 + _local14;
_local10 = _local10 + _local13;
_local4 = 0;
while (_local4 < arrParticles.length) {
var _local7 = (_root[arrParticles[_local4]]._width / 2) + 7.5;
var _local3 = _root[arrParticles[_local4]]._x - _local9;
var _local2 = _root[arrParticles[_local4]]._y - _local10;
_local6 = Math.sqrt((_local3 * _local3) + (_local2 * _local2));
if (_local6 <= _local7) {
_local5[_local4] = 1;
}
_local4++;
}
_local8++;
}
_local4 = 0;
while (_local4 < _local5.length) {
if (_local5[_local4] == 1) {
_root[arrParticles[_local4]].ArrowsOn(arrowDepth, _root.projectile._x, _root.projectile._y);
} else {
_root[arrParticles[_local4]].ArrowsOff();
}
_local4++;
}
}
function TurnOffAllArrows() {
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].ArrowsOff();
_local2++;
}
}
function NextArrowDepth() {
arrowDepth++;
if (arrowDepth > 39999) {
arrowDepth = 15000;
}
}
function DrawLines() {
_root.clear();
_root.lineStyle(2, 16777215, 50);
var _local2 = new Object();
var _local3 = new Object();
_local2.x = _root.projectile._x;
_local2.y = _root.projectile._y;
_local3.x = _xmouse;
_local3.y = _ymouse;
_root.moveTo(_local2.x, _local2.y);
_root.lineTo(_local3.x, _local3.y);
}
function Shoot() {
if ((intState == 1) && (_global.latestLevel != -1)) {
trace("in");
_root.clear();
saveX = _root.projectile._x;
saveY = _root.projectile._y;
var _local4 = new Vector();
_local4._x = (Stage.width / 2) - _root.projectile._x;
_local4._y = (Stage.height / 2) - _root.projectile._y;
var _local5 = Math.atan2(_local4._y, _local4._x);
vecShootDir._x = Math.cos(_local5) * 11;
vecShootDir._y = Math.sin(_local5) * 11;
var _local3 = 100;
do {
if (ProjectileOffScreen() != false) {
break;
}
_root.projectile._x = _root.projectile._x - vecShootDir._x;
_root.projectile._y = _root.projectile._y - vecShootDir._y;
_local3--;
} while (_local3 != 0);
var _local6 = (360 * _local5) / (Math.PI*2);
_root.projectile.gotoAndStop(2);
_root.projectile._rotation = _local6;
_root.gameBackground.gotoAndPlay("hide");
TurnOffAllArrows();
intState = 2;
}
}
function ProjectileOffScreen() {
var _local2 = false;
if (((_root.projectile._x + _root.projectile._width) < 0) || ((_root.projectile._x - _root.projectile._width) > Stage.width)) {
_local2 = true;
}
if (((_root.projectile._y + _root.projectile._height) < 0) || ((_root.projectile._y - _root.projectile._height) > Stage.height)) {
_local2 = true;
}
return(_local2);
}
function MoveProjectilesAndCollide() {
var _local4 = 0;
while (_local4 < arrProjectiles.length) {
_root[arrProjectiles[_local4].name]._x = _root[arrProjectiles[_local4].name]._x + (arrProjectiles[_local4].dX / 2);
_root[arrProjectiles[_local4].name]._y = _root[arrProjectiles[_local4].name]._y + (arrProjectiles[_local4].dY / 2);
if (((_root[arrProjectiles[_local4].name]._x + _root[arrProjectiles[_local4].name]._width) < 0) || ((_root[arrProjectiles[_local4].name]._x - _root[arrProjectiles[_local4].name]._width) > Stage.width)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
if (((_root[arrProjectiles[_local4].name]._y + _root[arrProjectiles[_local4].name]._height) < 0) || ((_root[arrProjectiles[_local4].name]._y - _root[arrProjectiles[_local4].name]._height) > Stage.height)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
_local4++;
}
var _local5 = new Array();
var _local3 = 0;
while (_local3 < arrProjectiles.length) {
_local4 = 0;
while (_local4 < arrParticles.length) {
if (_root[arrParticles[_local4]].hitTest(_root[arrProjectiles[_local3].name]._x, _root[arrProjectiles[_local3].name]._y, true) == true) {
_local5.push({name:arrParticles[_local4], X:arrProjectiles[_local3].X, Y:arrProjectiles[_local3].Y});
arrParticles.splice(_local4, 1);
_local4--;
_root[arrProjectiles[_local3].name].removeMovieClip();
arrProjectiles.splice(_local3, 1);
_local3--;
}
_local4++;
}
_local3++;
}
_local4 = 0;
while (_local4 < _local5.length) {
_root[_local5[_local4].name].Collision(_local5[_local4].X, _local5[_local4].Y);
_root[_local5[_local4].name].gotoAndStop(2);
_local4++;
}
_local4 = 0;
while (_local4 < arrProjectiles.length) {
_root[arrProjectiles[_local4].name]._x = _root[arrProjectiles[_local4].name]._x + (arrProjectiles[_local4].dX / 2);
_root[arrProjectiles[_local4].name]._y = _root[arrProjectiles[_local4].name]._y + (arrProjectiles[_local4].dY / 2);
if (((_root[arrProjectiles[_local4].name]._x + _root[arrProjectiles[_local4].name]._width) < 0) || ((_root[arrProjectiles[_local4].name]._x - _root[arrProjectiles[_local4].name]._width) > Stage.width)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
if (((_root[arrProjectiles[_local4].name]._y + _root[arrProjectiles[_local4].name]._height) < 0) || ((_root[arrProjectiles[_local4].name]._y - _root[arrProjectiles[_local4].name]._height) > Stage.height)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
_local4++;
}
_local5 = new Array();
_local3 = 0;
while (_local3 < arrProjectiles.length) {
_local4 = 0;
while (_local4 < arrParticles.length) {
if (_root[arrParticles[_local4]].hitTest(_root[arrProjectiles[_local3].name]._x, _root[arrProjectiles[_local3].name]._y, true) == true) {
_local5.push({name:arrParticles[_local4], X:arrProjectiles[_local3].X, Y:arrProjectiles[_local3].Y});
arrParticles.splice(_local4, 1);
_local4--;
_root[arrProjectiles[_local3].name].removeMovieClip();
arrProjectiles.splice(_local3, 1);
_local3--;
}
_local4++;
}
_local3++;
}
_local4 = 0;
while (_local4 < _local5.length) {
_root[_local5[_local4].name].Collision(_local5[_local4].X, _local5[_local4].Y);
_root[_local5[_local4].name].gotoAndStop(2);
_local4++;
}
if ((arrProjectiles.length == 0) && (projectileOver == true)) {
if (arrParticles.length != 0) {
intState = 3;
_root.messages_mc.gotoAndPlay("retry");
} else {
intState = 4;
var _local10 = ((_global.currentLevel + 5) - 15) / 5;
_global.levels[_local10] = 1;
var _local9 = SharedObject.getLocal("userData");
_local9.data.levelsCompleted = _global.levels;
_global.SoundManager.PlaySound("all");
_root.messages_mc.gotoAndPlay("next");
}
}
}
function LaunchProjectile(deltaX, deltaY, startX, startY, rot) {
var _local2 = "projectile_" + projectileDepth;
arrProjectiles.push({name:_local2, dX:deltaX, dY:deltaY, X:startX, Y:startY});
_root.attachMovie("shootingStar", _local2, projectileDepth);
_root[_local2]._x = startX;
_root[_local2]._y = startY;
_root[_local2]._rotation = rot;
projectileDepth++;
if (projectileDepth > 9999) {
projectileDepth = 5000;
}
}
stop();
var intState = 1;
var vecShootDir;
var arrParticles = new Array();
var arrProjectiles = new Array();
var arrParticlesReset = new Array();
var particleDepth = 1000;
var projectileDepth = 5000;
var arrowDepth = 15000;
var saveX = 0;
var saveY = 0;
var projectileOnScreen = false;
var projectileOver = false;
var saveDepth;
mouseListener = new Object();
mouseListener.onMouseDown = function () {
_root.Shoot();
};
Mouse.addListener(mouseListener);
Frame 100
function GameSetup() {
trace("%%%%%%%%");
trace((_global.currentLevel + " ----- ") + _global.latestLevel);
if (_global.latestLevel == -1) {
_root.gotoAndPlay("splash");
} else if ((_global.latestLevel != 0) && (_global.latestLevel != 20)) {
_global.currentLevel = _global.latestLevel;
_root.gotoAndPlay(_global.latestLevel);
_global.latestLevel = 0;
trace("go here");
} else if ((_global.latestLevel != 0) && (_global.latestLevel == 20)) {
_global.currentLevel = _global.latestLevel;
_global.latestLevel = 0;
}
if (_root.messages_mc.getDepth() != 50000) {
saveDepth = _root.messages_mc.getDepth();
}
vecShootDir = new Vector();
if (_global.musicOn == true) {
_global.myMusicPlayer.SetTrack("game");
_global.myMusicPlayer.SetMaxVolume(40);
_global.myMusicPlayer.PlayWithCrossFade(4);
}
}
function Mediator() {
_global.myMusicPlayer.RunPlayer();
switch (intState) {
case 1 :
AimProjectile();
if (_root.messages_mc.getDepth() != 50000) {
_root.messages_mc.swapDepths(50000);
trace(_root.messages_mc.getDepth());
}
break;
case 2 :
if (projectileOver == false) {
MoveProjectile();
}
DetectParticleCollisions();
MoveProjectilesAndCollide();
break;
case 3 :
if (Key.isDown(32)) {
Reset();
}
break;
case 4 :
if (!Key.isDown(32)) {
break;
}
Next();
}
}
function Reset() {
projectileDepth = 5000;
arrParticles = arrParticlesReset.slice();
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].gotoAndStop(1);
trace(arrParticles[_local2]);
_local2++;
}
trace("-----");
_root.projectile.gotoAndStop(1);
_root.gameBackground.gotoAndStop(1);
_root.messages_mc.gotoAndStop("hide");
projectileOver = false;
projectileOnScreen = false;
intState = 1;
}
function ExitGame() {
CleanupGame();
Mouse.removeListener(mouseListener);
_root.messages_mc.swapDepths(saveDepth);
_global.latestLevel = -1;
_root.gotoAndPlay("level1");
}
function Next() {
_global.currentLevel = _global.currentLevel + 5;
CleanupGame();
_root.messages_mc.swapDepths(saveDepth);
_root.gotoAndPlay(_global.currentLevel);
}
function CleanupGame() {
Mouse.removeListener(mouseListener);
Reset();
var _local3 = 10;
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].swapDepths(_local3);
_local3++;
_root[arrParticles[_local2]].removeMovieClip();
_local2++;
}
delete arrParticles;
arrParticles = new Array();
}
function DetectParticleCollisions() {
var _local3 = new Array();
var _local2 = 0;
while (_local2 < arrParticles.length) {
var _local4 = (_root[arrParticles[_local2]]._width / 2) + 7.5;
if (GetDistance(arrParticles[_local2], "projectile") <= _local4) {
_root[arrParticles[_local2]].Collision(saveX, saveY);
_local3.push(arrParticles[_local2]);
}
_local2++;
}
_local2 = 0;
while (_local2 < _local3.length) {
RemoveParticle(_local3[_local2]);
_root[_local3[_local2]].gotoAndStop(2);
_local2++;
}
}
function RemoveParticle(strName) {
var _local1 = 0;
while (_local1 < arrParticles.length) {
if (strName == arrParticles[_local1]) {
arrParticles.splice(_local1, 1);
break;
}
_local1++;
}
}
function GetDistance(targetA, targetB) {
var _local3 = _root[targetB]._x - _root[targetA]._x;
var _local2 = _root[targetB]._y - _root[targetA]._y;
return(Math.sqrt((_local3 * _local3) + (_local2 * _local2)));
}
function RegisterParticle(particleName) {
arrParticles.push(particleName);
arrParticlesReset.push(particleName);
particleDepth++;
return(particleDepth);
}
function MoveProjectile() {
if (ProjectileOffScreen() == false) {
projectileOnScreen = true;
_root.projectile._x = _root.projectile._x + vecShootDir._x;
_root.projectile._y = _root.projectile._y + vecShootDir._y;
} else if (projectileOnScreen == true) {
projectileOver = true;
} else {
_root.projectile._x = _root.projectile._x + vecShootDir._x;
_root.projectile._y = _root.projectile._y + vecShootDir._y;
}
}
function AimProjectile() {
var _local11 = new Vector();
_local11._x = _xmouse - (Stage.width / 2);
_local11._y = _ymouse - (Stage.height / 2);
var _local12 = Math.atan2(_local11._y, _local11._x);
var _local15 = (360 * _local12) / (Math.PI*2);
var _local6 = _root.gameBackground._width / 2;
_root.projectile._x = (_local6 * Math.cos(_local12)) + (Stage.width / 2);
_root.projectile._y = (_local6 * Math.sin(_local12)) + (Stage.height / 2);
_local11._x = (Stage.width / 2) - _root.projectile._x;
_local11._y = (Stage.height / 2) - _root.projectile._y;
_local12 = Math.atan2(_local11._y, _local11._x);
var _local14 = Math.cos(_local12) * 11;
var _local13 = Math.sin(_local12) * 11;
var _local9 = _root.projectile._x;
var _local10 = _root.projectile._y;
var _local5 = new Array(arrParticles.length);
var _local4 = 0;
while (_local4 < _local5.length) {
_local5[_local4] = 0;
_local4++;
}
var _local8 = 0;
while (_local8 < 70) {
_local9 = _local9 + _local14;
_local10 = _local10 + _local13;
_local4 = 0;
while (_local4 < arrParticles.length) {
var _local7 = (_root[arrParticles[_local4]]._width / 2) + 7.5;
var _local3 = _root[arrParticles[_local4]]._x - _local9;
var _local2 = _root[arrParticles[_local4]]._y - _local10;
_local6 = Math.sqrt((_local3 * _local3) + (_local2 * _local2));
if (_local6 <= _local7) {
_local5[_local4] = 1;
}
_local4++;
}
_local8++;
}
_local4 = 0;
while (_local4 < _local5.length) {
if (_local5[_local4] == 1) {
_root[arrParticles[_local4]].ArrowsOn(arrowDepth, _root.projectile._x, _root.projectile._y);
} else {
_root[arrParticles[_local4]].ArrowsOff();
}
_local4++;
}
}
function TurnOffAllArrows() {
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].ArrowsOff();
_local2++;
}
}
function NextArrowDepth() {
arrowDepth++;
if (arrowDepth > 39999) {
arrowDepth = 15000;
}
}
function DrawLines() {
_root.clear();
_root.lineStyle(2, 16777215, 50);
var _local2 = new Object();
var _local3 = new Object();
_local2.x = _root.projectile._x;
_local2.y = _root.projectile._y;
_local3.x = _xmouse;
_local3.y = _ymouse;
_root.moveTo(_local2.x, _local2.y);
_root.lineTo(_local3.x, _local3.y);
}
function Shoot() {
if ((intState == 1) && (_global.latestLevel != -1)) {
trace("in");
_root.clear();
saveX = _root.projectile._x;
saveY = _root.projectile._y;
var _local4 = new Vector();
_local4._x = (Stage.width / 2) - _root.projectile._x;
_local4._y = (Stage.height / 2) - _root.projectile._y;
var _local5 = Math.atan2(_local4._y, _local4._x);
vecShootDir._x = Math.cos(_local5) * 11;
vecShootDir._y = Math.sin(_local5) * 11;
var _local3 = 100;
do {
if (ProjectileOffScreen() != false) {
break;
}
_root.projectile._x = _root.projectile._x - vecShootDir._x;
_root.projectile._y = _root.projectile._y - vecShootDir._y;
_local3--;
} while (_local3 != 0);
var _local6 = (360 * _local5) / (Math.PI*2);
_root.projectile.gotoAndStop(2);
_root.projectile._rotation = _local6;
_root.gameBackground.gotoAndPlay("hide");
TurnOffAllArrows();
intState = 2;
}
}
function ProjectileOffScreen() {
var _local2 = false;
if (((_root.projectile._x + _root.projectile._width) < 0) || ((_root.projectile._x - _root.projectile._width) > Stage.width)) {
_local2 = true;
}
if (((_root.projectile._y + _root.projectile._height) < 0) || ((_root.projectile._y - _root.projectile._height) > Stage.height)) {
_local2 = true;
}
return(_local2);
}
function MoveProjectilesAndCollide() {
var _local4 = 0;
while (_local4 < arrProjectiles.length) {
_root[arrProjectiles[_local4].name]._x = _root[arrProjectiles[_local4].name]._x + (arrProjectiles[_local4].dX / 2);
_root[arrProjectiles[_local4].name]._y = _root[arrProjectiles[_local4].name]._y + (arrProjectiles[_local4].dY / 2);
if (((_root[arrProjectiles[_local4].name]._x + _root[arrProjectiles[_local4].name]._width) < 0) || ((_root[arrProjectiles[_local4].name]._x - _root[arrProjectiles[_local4].name]._width) > Stage.width)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
if (((_root[arrProjectiles[_local4].name]._y + _root[arrProjectiles[_local4].name]._height) < 0) || ((_root[arrProjectiles[_local4].name]._y - _root[arrProjectiles[_local4].name]._height) > Stage.height)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
_local4++;
}
var _local5 = new Array();
var _local3 = 0;
while (_local3 < arrProjectiles.length) {
_local4 = 0;
while (_local4 < arrParticles.length) {
if (_root[arrParticles[_local4]].hitTest(_root[arrProjectiles[_local3].name]._x, _root[arrProjectiles[_local3].name]._y, true) == true) {
_local5.push({name:arrParticles[_local4], X:arrProjectiles[_local3].X, Y:arrProjectiles[_local3].Y});
arrParticles.splice(_local4, 1);
_local4--;
_root[arrProjectiles[_local3].name].removeMovieClip();
arrProjectiles.splice(_local3, 1);
_local3--;
}
_local4++;
}
_local3++;
}
_local4 = 0;
while (_local4 < _local5.length) {
_root[_local5[_local4].name].Collision(_local5[_local4].X, _local5[_local4].Y);
_root[_local5[_local4].name].gotoAndStop(2);
_local4++;
}
_local4 = 0;
while (_local4 < arrProjectiles.length) {
_root[arrProjectiles[_local4].name]._x = _root[arrProjectiles[_local4].name]._x + (arrProjectiles[_local4].dX / 2);
_root[arrProjectiles[_local4].name]._y = _root[arrProjectiles[_local4].name]._y + (arrProjectiles[_local4].dY / 2);
if (((_root[arrProjectiles[_local4].name]._x + _root[arrProjectiles[_local4].name]._width) < 0) || ((_root[arrProjectiles[_local4].name]._x - _root[arrProjectiles[_local4].name]._width) > Stage.width)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
if (((_root[arrProjectiles[_local4].name]._y + _root[arrProjectiles[_local4].name]._height) < 0) || ((_root[arrProjectiles[_local4].name]._y - _root[arrProjectiles[_local4].name]._height) > Stage.height)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
_local4++;
}
_local5 = new Array();
_local3 = 0;
while (_local3 < arrProjectiles.length) {
_local4 = 0;
while (_local4 < arrParticles.length) {
if (_root[arrParticles[_local4]].hitTest(_root[arrProjectiles[_local3].name]._x, _root[arrProjectiles[_local3].name]._y, true) == true) {
_local5.push({name:arrParticles[_local4], X:arrProjectiles[_local3].X, Y:arrProjectiles[_local3].Y});
arrParticles.splice(_local4, 1);
_local4--;
_root[arrProjectiles[_local3].name].removeMovieClip();
arrProjectiles.splice(_local3, 1);
_local3--;
}
_local4++;
}
_local3++;
}
_local4 = 0;
while (_local4 < _local5.length) {
_root[_local5[_local4].name].Collision(_local5[_local4].X, _local5[_local4].Y);
_root[_local5[_local4].name].gotoAndStop(2);
_local4++;
}
if ((arrProjectiles.length == 0) && (projectileOver == true)) {
if (arrParticles.length != 0) {
intState = 3;
_root.messages_mc.gotoAndPlay("retry");
} else {
intState = 4;
var _local10 = ((_global.currentLevel + 5) - 15) / 5;
_global.levels[_local10] = 1;
var _local9 = SharedObject.getLocal("userData");
_local9.data.levelsCompleted = _global.levels;
_global.SoundManager.PlaySound("all");
_root.messages_mc.gotoAndPlay("next");
}
}
}
function LaunchProjectile(deltaX, deltaY, startX, startY, rot) {
var _local2 = "projectile_" + projectileDepth;
arrProjectiles.push({name:_local2, dX:deltaX, dY:deltaY, X:startX, Y:startY});
_root.attachMovie("shootingStar", _local2, projectileDepth);
_root[_local2]._x = startX;
_root[_local2]._y = startY;
_root[_local2]._rotation = rot;
projectileDepth++;
if (projectileDepth > 9999) {
projectileDepth = 5000;
}
}
stop();
var intState = 1;
var vecShootDir;
var arrParticles = new Array();
var arrProjectiles = new Array();
var arrParticlesReset = new Array();
var particleDepth = 1000;
var projectileDepth = 5000;
var arrowDepth = 15000;
var saveX = 0;
var saveY = 0;
var projectileOnScreen = false;
var projectileOver = false;
var saveDepth;
mouseListener = new Object();
mouseListener.onMouseDown = function () {
_root.Shoot();
};
Mouse.addListener(mouseListener);
Frame 105
function GameSetup() {
trace("%%%%%%%%");
trace((_global.currentLevel + " ----- ") + _global.latestLevel);
if (_global.latestLevel == -1) {
_root.gotoAndPlay("splash");
} else if ((_global.latestLevel != 0) && (_global.latestLevel != 20)) {
_global.currentLevel = _global.latestLevel;
_root.gotoAndPlay(_global.latestLevel);
_global.latestLevel = 0;
trace("go here");
} else if ((_global.latestLevel != 0) && (_global.latestLevel == 20)) {
_global.currentLevel = _global.latestLevel;
_global.latestLevel = 0;
}
if (_root.messages_mc.getDepth() != 50000) {
saveDepth = _root.messages_mc.getDepth();
}
vecShootDir = new Vector();
if (_global.musicOn == true) {
_global.myMusicPlayer.SetTrack("game");
_global.myMusicPlayer.SetMaxVolume(40);
_global.myMusicPlayer.PlayWithCrossFade(4);
}
}
function Mediator() {
_global.myMusicPlayer.RunPlayer();
switch (intState) {
case 1 :
AimProjectile();
if (_root.messages_mc.getDepth() != 50000) {
_root.messages_mc.swapDepths(50000);
trace(_root.messages_mc.getDepth());
}
break;
case 2 :
if (projectileOver == false) {
MoveProjectile();
}
DetectParticleCollisions();
MoveProjectilesAndCollide();
break;
case 3 :
if (Key.isDown(32)) {
Reset();
}
break;
case 4 :
if (!Key.isDown(32)) {
break;
}
Next();
}
}
function Reset() {
projectileDepth = 5000;
arrParticles = arrParticlesReset.slice();
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].gotoAndStop(1);
trace(arrParticles[_local2]);
_local2++;
}
trace("-----");
_root.projectile.gotoAndStop(1);
_root.gameBackground.gotoAndStop(1);
_root.messages_mc.gotoAndStop("hide");
projectileOver = false;
projectileOnScreen = false;
intState = 1;
}
function ExitGame() {
CleanupGame();
Mouse.removeListener(mouseListener);
_root.messages_mc.swapDepths(saveDepth);
_global.latestLevel = -1;
_root.gotoAndPlay("level1");
}
function Next() {
_global.currentLevel = _global.currentLevel + 5;
CleanupGame();
_root.messages_mc.swapDepths(saveDepth);
_root.gotoAndPlay(_global.currentLevel);
}
function CleanupGame() {
Mouse.removeListener(mouseListener);
Reset();
var _local3 = 10;
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].swapDepths(_local3);
_local3++;
_root[arrParticles[_local2]].removeMovieClip();
_local2++;
}
delete arrParticles;
arrParticles = new Array();
}
function DetectParticleCollisions() {
var _local3 = new Array();
var _local2 = 0;
while (_local2 < arrParticles.length) {
var _local4 = (_root[arrParticles[_local2]]._width / 2) + 7.5;
if (GetDistance(arrParticles[_local2], "projectile") <= _local4) {
_root[arrParticles[_local2]].Collision(saveX, saveY);
_local3.push(arrParticles[_local2]);
}
_local2++;
}
_local2 = 0;
while (_local2 < _local3.length) {
RemoveParticle(_local3[_local2]);
_root[_local3[_local2]].gotoAndStop(2);
_local2++;
}
}
function RemoveParticle(strName) {
var _local1 = 0;
while (_local1 < arrParticles.length) {
if (strName == arrParticles[_local1]) {
arrParticles.splice(_local1, 1);
break;
}
_local1++;
}
}
function GetDistance(targetA, targetB) {
var _local3 = _root[targetB]._x - _root[targetA]._x;
var _local2 = _root[targetB]._y - _root[targetA]._y;
return(Math.sqrt((_local3 * _local3) + (_local2 * _local2)));
}
function RegisterParticle(particleName) {
arrParticles.push(particleName);
arrParticlesReset.push(particleName);
particleDepth++;
return(particleDepth);
}
function MoveProjectile() {
if (ProjectileOffScreen() == false) {
projectileOnScreen = true;
_root.projectile._x = _root.projectile._x + vecShootDir._x;
_root.projectile._y = _root.projectile._y + vecShootDir._y;
} else if (projectileOnScreen == true) {
projectileOver = true;
} else {
_root.projectile._x = _root.projectile._x + vecShootDir._x;
_root.projectile._y = _root.projectile._y + vecShootDir._y;
}
}
function AimProjectile() {
var _local11 = new Vector();
_local11._x = _xmouse - (Stage.width / 2);
_local11._y = _ymouse - (Stage.height / 2);
var _local12 = Math.atan2(_local11._y, _local11._x);
var _local15 = (360 * _local12) / (Math.PI*2);
var _local6 = _root.gameBackground._width / 2;
_root.projectile._x = (_local6 * Math.cos(_local12)) + (Stage.width / 2);
_root.projectile._y = (_local6 * Math.sin(_local12)) + (Stage.height / 2);
_local11._x = (Stage.width / 2) - _root.projectile._x;
_local11._y = (Stage.height / 2) - _root.projectile._y;
_local12 = Math.atan2(_local11._y, _local11._x);
var _local14 = Math.cos(_local12) * 11;
var _local13 = Math.sin(_local12) * 11;
var _local9 = _root.projectile._x;
var _local10 = _root.projectile._y;
var _local5 = new Array(arrParticles.length);
var _local4 = 0;
while (_local4 < _local5.length) {
_local5[_local4] = 0;
_local4++;
}
var _local8 = 0;
while (_local8 < 70) {
_local9 = _local9 + _local14;
_local10 = _local10 + _local13;
_local4 = 0;
while (_local4 < arrParticles.length) {
var _local7 = (_root[arrParticles[_local4]]._width / 2) + 7.5;
var _local3 = _root[arrParticles[_local4]]._x - _local9;
var _local2 = _root[arrParticles[_local4]]._y - _local10;
_local6 = Math.sqrt((_local3 * _local3) + (_local2 * _local2));
if (_local6 <= _local7) {
_local5[_local4] = 1;
}
_local4++;
}
_local8++;
}
_local4 = 0;
while (_local4 < _local5.length) {
if (_local5[_local4] == 1) {
_root[arrParticles[_local4]].ArrowsOn(arrowDepth, _root.projectile._x, _root.projectile._y);
} else {
_root[arrParticles[_local4]].ArrowsOff();
}
_local4++;
}
}
function TurnOffAllArrows() {
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].ArrowsOff();
_local2++;
}
}
function NextArrowDepth() {
arrowDepth++;
if (arrowDepth > 39999) {
arrowDepth = 15000;
}
}
function DrawLines() {
_root.clear();
_root.lineStyle(2, 16777215, 50);
var _local2 = new Object();
var _local3 = new Object();
_local2.x = _root.projectile._x;
_local2.y = _root.projectile._y;
_local3.x = _xmouse;
_local3.y = _ymouse;
_root.moveTo(_local2.x, _local2.y);
_root.lineTo(_local3.x, _local3.y);
}
function Shoot() {
if ((intState == 1) && (_global.latestLevel != -1)) {
trace("in");
_root.clear();
saveX = _root.projectile._x;
saveY = _root.projectile._y;
var _local4 = new Vector();
_local4._x = (Stage.width / 2) - _root.projectile._x;
_local4._y = (Stage.height / 2) - _root.projectile._y;
var _local5 = Math.atan2(_local4._y, _local4._x);
vecShootDir._x = Math.cos(_local5) * 11;
vecShootDir._y = Math.sin(_local5) * 11;
var _local3 = 100;
do {
if (ProjectileOffScreen() != false) {
break;
}
_root.projectile._x = _root.projectile._x - vecShootDir._x;
_root.projectile._y = _root.projectile._y - vecShootDir._y;
_local3--;
} while (_local3 != 0);
var _local6 = (360 * _local5) / (Math.PI*2);
_root.projectile.gotoAndStop(2);
_root.projectile._rotation = _local6;
_root.gameBackground.gotoAndPlay("hide");
TurnOffAllArrows();
intState = 2;
}
}
function ProjectileOffScreen() {
var _local2 = false;
if (((_root.projectile._x + _root.projectile._width) < 0) || ((_root.projectile._x - _root.projectile._width) > Stage.width)) {
_local2 = true;
}
if (((_root.projectile._y + _root.projectile._height) < 0) || ((_root.projectile._y - _root.projectile._height) > Stage.height)) {
_local2 = true;
}
return(_local2);
}
function MoveProjectilesAndCollide() {
var _local4 = 0;
while (_local4 < arrProjectiles.length) {
_root[arrProjectiles[_local4].name]._x = _root[arrProjectiles[_local4].name]._x + (arrProjectiles[_local4].dX / 2);
_root[arrProjectiles[_local4].name]._y = _root[arrProjectiles[_local4].name]._y + (arrProjectiles[_local4].dY / 2);
if (((_root[arrProjectiles[_local4].name]._x + _root[arrProjectiles[_local4].name]._width) < 0) || ((_root[arrProjectiles[_local4].name]._x - _root[arrProjectiles[_local4].name]._width) > Stage.width)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
if (((_root[arrProjectiles[_local4].name]._y + _root[arrProjectiles[_local4].name]._height) < 0) || ((_root[arrProjectiles[_local4].name]._y - _root[arrProjectiles[_local4].name]._height) > Stage.height)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
_local4++;
}
var _local5 = new Array();
var _local3 = 0;
while (_local3 < arrProjectiles.length) {
_local4 = 0;
while (_local4 < arrParticles.length) {
if (_root[arrParticles[_local4]].hitTest(_root[arrProjectiles[_local3].name]._x, _root[arrProjectiles[_local3].name]._y, true) == true) {
_local5.push({name:arrParticles[_local4], X:arrProjectiles[_local3].X, Y:arrProjectiles[_local3].Y});
arrParticles.splice(_local4, 1);
_local4--;
_root[arrProjectiles[_local3].name].removeMovieClip();
arrProjectiles.splice(_local3, 1);
_local3--;
}
_local4++;
}
_local3++;
}
_local4 = 0;
while (_local4 < _local5.length) {
_root[_local5[_local4].name].Collision(_local5[_local4].X, _local5[_local4].Y);
_root[_local5[_local4].name].gotoAndStop(2);
_local4++;
}
_local4 = 0;
while (_local4 < arrProjectiles.length) {
_root[arrProjectiles[_local4].name]._x = _root[arrProjectiles[_local4].name]._x + (arrProjectiles[_local4].dX / 2);
_root[arrProjectiles[_local4].name]._y = _root[arrProjectiles[_local4].name]._y + (arrProjectiles[_local4].dY / 2);
if (((_root[arrProjectiles[_local4].name]._x + _root[arrProjectiles[_local4].name]._width) < 0) || ((_root[arrProjectiles[_local4].name]._x - _root[arrProjectiles[_local4].name]._width) > Stage.width)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
if (((_root[arrProjectiles[_local4].name]._y + _root[arrProjectiles[_local4].name]._height) < 0) || ((_root[arrProjectiles[_local4].name]._y - _root[arrProjectiles[_local4].name]._height) > Stage.height)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
_local4++;
}
_local5 = new Array();
_local3 = 0;
while (_local3 < arrProjectiles.length) {
_local4 = 0;
while (_local4 < arrParticles.length) {
if (_root[arrParticles[_local4]].hitTest(_root[arrProjectiles[_local3].name]._x, _root[arrProjectiles[_local3].name]._y, true) == true) {
_local5.push({name:arrParticles[_local4], X:arrProjectiles[_local3].X, Y:arrProjectiles[_local3].Y});
arrParticles.splice(_local4, 1);
_local4--;
_root[arrProjectiles[_local3].name].removeMovieClip();
arrProjectiles.splice(_local3, 1);
_local3--;
}
_local4++;
}
_local3++;
}
_local4 = 0;
while (_local4 < _local5.length) {
_root[_local5[_local4].name].Collision(_local5[_local4].X, _local5[_local4].Y);
_root[_local5[_local4].name].gotoAndStop(2);
_local4++;
}
if ((arrProjectiles.length == 0) && (projectileOver == true)) {
if (arrParticles.length != 0) {
intState = 3;
_root.messages_mc.gotoAndPlay("retry");
} else {
intState = 4;
var _local10 = ((_global.currentLevel + 5) - 15) / 5;
_global.levels[_local10] = 1;
var _local9 = SharedObject.getLocal("userData");
_local9.data.levelsCompleted = _global.levels;
_global.SoundManager.PlaySound("all");
_root.messages_mc.gotoAndPlay("next");
}
}
}
function LaunchProjectile(deltaX, deltaY, startX, startY, rot) {
var _local2 = "projectile_" + projectileDepth;
arrProjectiles.push({name:_local2, dX:deltaX, dY:deltaY, X:startX, Y:startY});
_root.attachMovie("shootingStar", _local2, projectileDepth);
_root[_local2]._x = startX;
_root[_local2]._y = startY;
_root[_local2]._rotation = rot;
projectileDepth++;
if (projectileDepth > 9999) {
projectileDepth = 5000;
}
}
stop();
var intState = 1;
var vecShootDir;
var arrParticles = new Array();
var arrProjectiles = new Array();
var arrParticlesReset = new Array();
var particleDepth = 1000;
var projectileDepth = 5000;
var arrowDepth = 15000;
var saveX = 0;
var saveY = 0;
var projectileOnScreen = false;
var projectileOver = false;
var saveDepth;
mouseListener = new Object();
mouseListener.onMouseDown = function () {
_root.Shoot();
};
Mouse.addListener(mouseListener);
Frame 110
function GameSetup() {
trace("%%%%%%%%");
trace((_global.currentLevel + " ----- ") + _global.latestLevel);
if (_global.latestLevel == -1) {
_root.gotoAndPlay("splash");
} else if ((_global.latestLevel != 0) && (_global.latestLevel != 20)) {
_global.currentLevel = _global.latestLevel;
_root.gotoAndPlay(_global.latestLevel);
_global.latestLevel = 0;
trace("go here");
} else if ((_global.latestLevel != 0) && (_global.latestLevel == 20)) {
_global.currentLevel = _global.latestLevel;
_global.latestLevel = 0;
}
if (_root.messages_mc.getDepth() != 50000) {
saveDepth = _root.messages_mc.getDepth();
}
vecShootDir = new Vector();
if (_global.musicOn == true) {
_global.myMusicPlayer.SetTrack("game");
_global.myMusicPlayer.SetMaxVolume(40);
_global.myMusicPlayer.PlayWithCrossFade(4);
}
}
function Mediator() {
_global.myMusicPlayer.RunPlayer();
switch (intState) {
case 1 :
AimProjectile();
if (_root.messages_mc.getDepth() != 50000) {
_root.messages_mc.swapDepths(50000);
trace(_root.messages_mc.getDepth());
}
break;
case 2 :
if (projectileOver == false) {
MoveProjectile();
}
DetectParticleCollisions();
MoveProjectilesAndCollide();
break;
case 3 :
if (Key.isDown(32)) {
Reset();
}
break;
case 4 :
if (!Key.isDown(32)) {
break;
}
Next();
}
}
function Reset() {
projectileDepth = 5000;
arrParticles = arrParticlesReset.slice();
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].gotoAndStop(1);
trace(arrParticles[_local2]);
_local2++;
}
trace("-----");
_root.projectile.gotoAndStop(1);
_root.gameBackground.gotoAndStop(1);
_root.messages_mc.gotoAndStop("hide");
projectileOver = false;
projectileOnScreen = false;
intState = 1;
}
function ExitGame() {
CleanupGame();
Mouse.removeListener(mouseListener);
_root.messages_mc.swapDepths(saveDepth);
_global.latestLevel = -1;
_root.gotoAndPlay("level1");
}
function Next() {
_global.currentLevel = _global.currentLevel + 5;
CleanupGame();
_root.messages_mc.swapDepths(saveDepth);
_root.gotoAndPlay(_global.currentLevel);
}
function CleanupGame() {
Mouse.removeListener(mouseListener);
Reset();
var _local3 = 10;
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].swapDepths(_local3);
_local3++;
_root[arrParticles[_local2]].removeMovieClip();
_local2++;
}
delete arrParticles;
arrParticles = new Array();
}
function DetectParticleCollisions() {
var _local3 = new Array();
var _local2 = 0;
while (_local2 < arrParticles.length) {
var _local4 = (_root[arrParticles[_local2]]._width / 2) + 7.5;
if (GetDistance(arrParticles[_local2], "projectile") <= _local4) {
_root[arrParticles[_local2]].Collision(saveX, saveY);
_local3.push(arrParticles[_local2]);
}
_local2++;
}
_local2 = 0;
while (_local2 < _local3.length) {
RemoveParticle(_local3[_local2]);
_root[_local3[_local2]].gotoAndStop(2);
_local2++;
}
}
function RemoveParticle(strName) {
var _local1 = 0;
while (_local1 < arrParticles.length) {
if (strName == arrParticles[_local1]) {
arrParticles.splice(_local1, 1);
break;
}
_local1++;
}
}
function GetDistance(targetA, targetB) {
var _local3 = _root[targetB]._x - _root[targetA]._x;
var _local2 = _root[targetB]._y - _root[targetA]._y;
return(Math.sqrt((_local3 * _local3) + (_local2 * _local2)));
}
function RegisterParticle(particleName) {
arrParticles.push(particleName);
arrParticlesReset.push(particleName);
particleDepth++;
return(particleDepth);
}
function MoveProjectile() {
if (ProjectileOffScreen() == false) {
projectileOnScreen = true;
_root.projectile._x = _root.projectile._x + vecShootDir._x;
_root.projectile._y = _root.projectile._y + vecShootDir._y;
} else if (projectileOnScreen == true) {
projectileOver = true;
} else {
_root.projectile._x = _root.projectile._x + vecShootDir._x;
_root.projectile._y = _root.projectile._y + vecShootDir._y;
}
}
function AimProjectile() {
var _local11 = new Vector();
_local11._x = _xmouse - (Stage.width / 2);
_local11._y = _ymouse - (Stage.height / 2);
var _local12 = Math.atan2(_local11._y, _local11._x);
var _local15 = (360 * _local12) / (Math.PI*2);
var _local6 = _root.gameBackground._width / 2;
_root.projectile._x = (_local6 * Math.cos(_local12)) + (Stage.width / 2);
_root.projectile._y = (_local6 * Math.sin(_local12)) + (Stage.height / 2);
_local11._x = (Stage.width / 2) - _root.projectile._x;
_local11._y = (Stage.height / 2) - _root.projectile._y;
_local12 = Math.atan2(_local11._y, _local11._x);
var _local14 = Math.cos(_local12) * 11;
var _local13 = Math.sin(_local12) * 11;
var _local9 = _root.projectile._x;
var _local10 = _root.projectile._y;
var _local5 = new Array(arrParticles.length);
var _local4 = 0;
while (_local4 < _local5.length) {
_local5[_local4] = 0;
_local4++;
}
var _local8 = 0;
while (_local8 < 70) {
_local9 = _local9 + _local14;
_local10 = _local10 + _local13;
_local4 = 0;
while (_local4 < arrParticles.length) {
var _local7 = (_root[arrParticles[_local4]]._width / 2) + 7.5;
var _local3 = _root[arrParticles[_local4]]._x - _local9;
var _local2 = _root[arrParticles[_local4]]._y - _local10;
_local6 = Math.sqrt((_local3 * _local3) + (_local2 * _local2));
if (_local6 <= _local7) {
_local5[_local4] = 1;
}
_local4++;
}
_local8++;
}
_local4 = 0;
while (_local4 < _local5.length) {
if (_local5[_local4] == 1) {
_root[arrParticles[_local4]].ArrowsOn(arrowDepth, _root.projectile._x, _root.projectile._y);
} else {
_root[arrParticles[_local4]].ArrowsOff();
}
_local4++;
}
}
function TurnOffAllArrows() {
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].ArrowsOff();
_local2++;
}
}
function NextArrowDepth() {
arrowDepth++;
if (arrowDepth > 39999) {
arrowDepth = 15000;
}
}
function DrawLines() {
_root.clear();
_root.lineStyle(2, 16777215, 50);
var _local2 = new Object();
var _local3 = new Object();
_local2.x = _root.projectile._x;
_local2.y = _root.projectile._y;
_local3.x = _xmouse;
_local3.y = _ymouse;
_root.moveTo(_local2.x, _local2.y);
_root.lineTo(_local3.x, _local3.y);
}
function Shoot() {
if ((intState == 1) && (_global.latestLevel != -1)) {
trace("in");
_root.clear();
saveX = _root.projectile._x;
saveY = _root.projectile._y;
var _local4 = new Vector();
_local4._x = (Stage.width / 2) - _root.projectile._x;
_local4._y = (Stage.height / 2) - _root.projectile._y;
var _local5 = Math.atan2(_local4._y, _local4._x);
vecShootDir._x = Math.cos(_local5) * 11;
vecShootDir._y = Math.sin(_local5) * 11;
var _local3 = 100;
do {
if (ProjectileOffScreen() != false) {
break;
}
_root.projectile._x = _root.projectile._x - vecShootDir._x;
_root.projectile._y = _root.projectile._y - vecShootDir._y;
_local3--;
} while (_local3 != 0);
var _local6 = (360 * _local5) / (Math.PI*2);
_root.projectile.gotoAndStop(2);
_root.projectile._rotation = _local6;
_root.gameBackground.gotoAndPlay("hide");
TurnOffAllArrows();
intState = 2;
}
}
function ProjectileOffScreen() {
var _local2 = false;
if (((_root.projectile._x + _root.projectile._width) < 0) || ((_root.projectile._x - _root.projectile._width) > Stage.width)) {
_local2 = true;
}
if (((_root.projectile._y + _root.projectile._height) < 0) || ((_root.projectile._y - _root.projectile._height) > Stage.height)) {
_local2 = true;
}
return(_local2);
}
function MoveProjectilesAndCollide() {
var _local4 = 0;
while (_local4 < arrProjectiles.length) {
_root[arrProjectiles[_local4].name]._x = _root[arrProjectiles[_local4].name]._x + (arrProjectiles[_local4].dX / 2);
_root[arrProjectiles[_local4].name]._y = _root[arrProjectiles[_local4].name]._y + (arrProjectiles[_local4].dY / 2);
if (((_root[arrProjectiles[_local4].name]._x + _root[arrProjectiles[_local4].name]._width) < 0) || ((_root[arrProjectiles[_local4].name]._x - _root[arrProjectiles[_local4].name]._width) > Stage.width)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
if (((_root[arrProjectiles[_local4].name]._y + _root[arrProjectiles[_local4].name]._height) < 0) || ((_root[arrProjectiles[_local4].name]._y - _root[arrProjectiles[_local4].name]._height) > Stage.height)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
_local4++;
}
var _local5 = new Array();
var _local3 = 0;
while (_local3 < arrProjectiles.length) {
_local4 = 0;
while (_local4 < arrParticles.length) {
if (_root[arrParticles[_local4]].hitTest(_root[arrProjectiles[_local3].name]._x, _root[arrProjectiles[_local3].name]._y, true) == true) {
_local5.push({name:arrParticles[_local4], X:arrProjectiles[_local3].X, Y:arrProjectiles[_local3].Y});
arrParticles.splice(_local4, 1);
_local4--;
_root[arrProjectiles[_local3].name].removeMovieClip();
arrProjectiles.splice(_local3, 1);
_local3--;
}
_local4++;
}
_local3++;
}
_local4 = 0;
while (_local4 < _local5.length) {
_root[_local5[_local4].name].Collision(_local5[_local4].X, _local5[_local4].Y);
_root[_local5[_local4].name].gotoAndStop(2);
_local4++;
}
_local4 = 0;
while (_local4 < arrProjectiles.length) {
_root[arrProjectiles[_local4].name]._x = _root[arrProjectiles[_local4].name]._x + (arrProjectiles[_local4].dX / 2);
_root[arrProjectiles[_local4].name]._y = _root[arrProjectiles[_local4].name]._y + (arrProjectiles[_local4].dY / 2);
if (((_root[arrProjectiles[_local4].name]._x + _root[arrProjectiles[_local4].name]._width) < 0) || ((_root[arrProjectiles[_local4].name]._x - _root[arrProjectiles[_local4].name]._width) > Stage.width)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
if (((_root[arrProjectiles[_local4].name]._y + _root[arrProjectiles[_local4].name]._height) < 0) || ((_root[arrProjectiles[_local4].name]._y - _root[arrProjectiles[_local4].name]._height) > Stage.height)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
_local4++;
}
_local5 = new Array();
_local3 = 0;
while (_local3 < arrProjectiles.length) {
_local4 = 0;
while (_local4 < arrParticles.length) {
if (_root[arrParticles[_local4]].hitTest(_root[arrProjectiles[_local3].name]._x, _root[arrProjectiles[_local3].name]._y, true) == true) {
_local5.push({name:arrParticles[_local4], X:arrProjectiles[_local3].X, Y:arrProjectiles[_local3].Y});
arrParticles.splice(_local4, 1);
_local4--;
_root[arrProjectiles[_local3].name].removeMovieClip();
arrProjectiles.splice(_local3, 1);
_local3--;
}
_local4++;
}
_local3++;
}
_local4 = 0;
while (_local4 < _local5.length) {
_root[_local5[_local4].name].Collision(_local5[_local4].X, _local5[_local4].Y);
_root[_local5[_local4].name].gotoAndStop(2);
_local4++;
}
if ((arrProjectiles.length == 0) && (projectileOver == true)) {
if (arrParticles.length != 0) {
intState = 3;
_root.messages_mc.gotoAndPlay("retry");
} else {
intState = 4;
var _local10 = ((_global.currentLevel + 5) - 15) / 5;
_global.levels[_local10] = 1;
var _local9 = SharedObject.getLocal("userData");
_local9.data.levelsCompleted = _global.levels;
_global.SoundManager.PlaySound("all");
_root.messages_mc.gotoAndPlay("next");
}
}
}
function LaunchProjectile(deltaX, deltaY, startX, startY, rot) {
var _local2 = "projectile_" + projectileDepth;
arrProjectiles.push({name:_local2, dX:deltaX, dY:deltaY, X:startX, Y:startY});
_root.attachMovie("shootingStar", _local2, projectileDepth);
_root[_local2]._x = startX;
_root[_local2]._y = startY;
_root[_local2]._rotation = rot;
projectileDepth++;
if (projectileDepth > 9999) {
projectileDepth = 5000;
}
}
stop();
var intState = 1;
var vecShootDir;
var arrParticles = new Array();
var arrProjectiles = new Array();
var arrParticlesReset = new Array();
var particleDepth = 1000;
var projectileDepth = 5000;
var arrowDepth = 15000;
var saveX = 0;
var saveY = 0;
var projectileOnScreen = false;
var projectileOver = false;
var saveDepth;
mouseListener = new Object();
mouseListener.onMouseDown = function () {
_root.Shoot();
};
Mouse.addListener(mouseListener);
Frame 115
function GameSetup() {
trace("%%%%%%%%");
trace((_global.currentLevel + " ----- ") + _global.latestLevel);
if (_global.latestLevel == -1) {
_root.gotoAndPlay("splash");
} else if ((_global.latestLevel != 0) && (_global.latestLevel != 20)) {
_global.currentLevel = _global.latestLevel;
_root.gotoAndPlay(_global.latestLevel);
_global.latestLevel = 0;
trace("go here");
} else if ((_global.latestLevel != 0) && (_global.latestLevel == 20)) {
_global.currentLevel = _global.latestLevel;
_global.latestLevel = 0;
}
if (_root.messages_mc.getDepth() != 50000) {
saveDepth = _root.messages_mc.getDepth();
}
vecShootDir = new Vector();
if (_global.musicOn == true) {
_global.myMusicPlayer.SetTrack("game");
_global.myMusicPlayer.SetMaxVolume(40);
_global.myMusicPlayer.PlayWithCrossFade(4);
}
}
function Mediator() {
_global.myMusicPlayer.RunPlayer();
switch (intState) {
case 1 :
AimProjectile();
if (_root.messages_mc.getDepth() != 50000) {
_root.messages_mc.swapDepths(50000);
trace(_root.messages_mc.getDepth());
}
break;
case 2 :
if (projectileOver == false) {
MoveProjectile();
}
DetectParticleCollisions();
MoveProjectilesAndCollide();
break;
case 3 :
if (Key.isDown(32)) {
Reset();
}
break;
case 4 :
if (!Key.isDown(32)) {
break;
}
Next();
}
}
function Reset() {
projectileDepth = 5000;
arrParticles = arrParticlesReset.slice();
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].gotoAndStop(1);
trace(arrParticles[_local2]);
_local2++;
}
trace("-----");
_root.projectile.gotoAndStop(1);
_root.gameBackground.gotoAndStop(1);
_root.messages_mc.gotoAndStop("hide");
projectileOver = false;
projectileOnScreen = false;
intState = 1;
}
function ExitGame() {
CleanupGame();
Mouse.removeListener(mouseListener);
_root.messages_mc.swapDepths(saveDepth);
_global.latestLevel = -1;
_root.gotoAndPlay("level1");
}
function Next() {
_global.currentLevel = _global.currentLevel + 5;
CleanupGame();
_root.messages_mc.swapDepths(saveDepth);
_root.gotoAndPlay(_global.currentLevel);
}
function CleanupGame() {
Mouse.removeListener(mouseListener);
Reset();
var _local3 = 10;
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].swapDepths(_local3);
_local3++;
_root[arrParticles[_local2]].removeMovieClip();
_local2++;
}
delete arrParticles;
arrParticles = new Array();
}
function DetectParticleCollisions() {
var _local3 = new Array();
var _local2 = 0;
while (_local2 < arrParticles.length) {
var _local4 = (_root[arrParticles[_local2]]._width / 2) + 7.5;
if (GetDistance(arrParticles[_local2], "projectile") <= _local4) {
_root[arrParticles[_local2]].Collision(saveX, saveY);
_local3.push(arrParticles[_local2]);
}
_local2++;
}
_local2 = 0;
while (_local2 < _local3.length) {
RemoveParticle(_local3[_local2]);
_root[_local3[_local2]].gotoAndStop(2);
_local2++;
}
}
function RemoveParticle(strName) {
var _local1 = 0;
while (_local1 < arrParticles.length) {
if (strName == arrParticles[_local1]) {
arrParticles.splice(_local1, 1);
break;
}
_local1++;
}
}
function GetDistance(targetA, targetB) {
var _local3 = _root[targetB]._x - _root[targetA]._x;
var _local2 = _root[targetB]._y - _root[targetA]._y;
return(Math.sqrt((_local3 * _local3) + (_local2 * _local2)));
}
function RegisterParticle(particleName) {
arrParticles.push(particleName);
arrParticlesReset.push(particleName);
particleDepth++;
return(particleDepth);
}
function MoveProjectile() {
if (ProjectileOffScreen() == false) {
projectileOnScreen = true;
_root.projectile._x = _root.projectile._x + vecShootDir._x;
_root.projectile._y = _root.projectile._y + vecShootDir._y;
} else if (projectileOnScreen == true) {
projectileOver = true;
} else {
_root.projectile._x = _root.projectile._x + vecShootDir._x;
_root.projectile._y = _root.projectile._y + vecShootDir._y;
}
}
function AimProjectile() {
var _local11 = new Vector();
_local11._x = _xmouse - (Stage.width / 2);
_local11._y = _ymouse - (Stage.height / 2);
var _local12 = Math.atan2(_local11._y, _local11._x);
var _local15 = (360 * _local12) / (Math.PI*2);
var _local6 = _root.gameBackground._width / 2;
_root.projectile._x = (_local6 * Math.cos(_local12)) + (Stage.width / 2);
_root.projectile._y = (_local6 * Math.sin(_local12)) + (Stage.height / 2);
_local11._x = (Stage.width / 2) - _root.projectile._x;
_local11._y = (Stage.height / 2) - _root.projectile._y;
_local12 = Math.atan2(_local11._y, _local11._x);
var _local14 = Math.cos(_local12) * 11;
var _local13 = Math.sin(_local12) * 11;
var _local9 = _root.projectile._x;
var _local10 = _root.projectile._y;
var _local5 = new Array(arrParticles.length);
var _local4 = 0;
while (_local4 < _local5.length) {
_local5[_local4] = 0;
_local4++;
}
var _local8 = 0;
while (_local8 < 70) {
_local9 = _local9 + _local14;
_local10 = _local10 + _local13;
_local4 = 0;
while (_local4 < arrParticles.length) {
var _local7 = (_root[arrParticles[_local4]]._width / 2) + 7.5;
var _local3 = _root[arrParticles[_local4]]._x - _local9;
var _local2 = _root[arrParticles[_local4]]._y - _local10;
_local6 = Math.sqrt((_local3 * _local3) + (_local2 * _local2));
if (_local6 <= _local7) {
_local5[_local4] = 1;
}
_local4++;
}
_local8++;
}
_local4 = 0;
while (_local4 < _local5.length) {
if (_local5[_local4] == 1) {
_root[arrParticles[_local4]].ArrowsOn(arrowDepth, _root.projectile._x, _root.projectile._y);
} else {
_root[arrParticles[_local4]].ArrowsOff();
}
_local4++;
}
}
function TurnOffAllArrows() {
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].ArrowsOff();
_local2++;
}
}
function NextArrowDepth() {
arrowDepth++;
if (arrowDepth > 39999) {
arrowDepth = 15000;
}
}
function DrawLines() {
_root.clear();
_root.lineStyle(2, 16777215, 50);
var _local2 = new Object();
var _local3 = new Object();
_local2.x = _root.projectile._x;
_local2.y = _root.projectile._y;
_local3.x = _xmouse;
_local3.y = _ymouse;
_root.moveTo(_local2.x, _local2.y);
_root.lineTo(_local3.x, _local3.y);
}
function Shoot() {
if ((intState == 1) && (_global.latestLevel != -1)) {
trace("in");
_root.clear();
saveX = _root.projectile._x;
saveY = _root.projectile._y;
var _local4 = new Vector();
_local4._x = (Stage.width / 2) - _root.projectile._x;
_local4._y = (Stage.height / 2) - _root.projectile._y;
var _local5 = Math.atan2(_local4._y, _local4._x);
vecShootDir._x = Math.cos(_local5) * 11;
vecShootDir._y = Math.sin(_local5) * 11;
var _local3 = 100;
do {
if (ProjectileOffScreen() != false) {
break;
}
_root.projectile._x = _root.projectile._x - vecShootDir._x;
_root.projectile._y = _root.projectile._y - vecShootDir._y;
_local3--;
} while (_local3 != 0);
var _local6 = (360 * _local5) / (Math.PI*2);
_root.projectile.gotoAndStop(2);
_root.projectile._rotation = _local6;
_root.gameBackground.gotoAndPlay("hide");
TurnOffAllArrows();
intState = 2;
}
}
function ProjectileOffScreen() {
var _local2 = false;
if (((_root.projectile._x + _root.projectile._width) < 0) || ((_root.projectile._x - _root.projectile._width) > Stage.width)) {
_local2 = true;
}
if (((_root.projectile._y + _root.projectile._height) < 0) || ((_root.projectile._y - _root.projectile._height) > Stage.height)) {
_local2 = true;
}
return(_local2);
}
function MoveProjectilesAndCollide() {
var _local4 = 0;
while (_local4 < arrProjectiles.length) {
_root[arrProjectiles[_local4].name]._x = _root[arrProjectiles[_local4].name]._x + (arrProjectiles[_local4].dX / 2);
_root[arrProjectiles[_local4].name]._y = _root[arrProjectiles[_local4].name]._y + (arrProjectiles[_local4].dY / 2);
if (((_root[arrProjectiles[_local4].name]._x + _root[arrProjectiles[_local4].name]._width) < 0) || ((_root[arrProjectiles[_local4].name]._x - _root[arrProjectiles[_local4].name]._width) > Stage.width)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
if (((_root[arrProjectiles[_local4].name]._y + _root[arrProjectiles[_local4].name]._height) < 0) || ((_root[arrProjectiles[_local4].name]._y - _root[arrProjectiles[_local4].name]._height) > Stage.height)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
_local4++;
}
var _local5 = new Array();
var _local3 = 0;
while (_local3 < arrProjectiles.length) {
_local4 = 0;
while (_local4 < arrParticles.length) {
if (_root[arrParticles[_local4]].hitTest(_root[arrProjectiles[_local3].name]._x, _root[arrProjectiles[_local3].name]._y, true) == true) {
_local5.push({name:arrParticles[_local4], X:arrProjectiles[_local3].X, Y:arrProjectiles[_local3].Y});
arrParticles.splice(_local4, 1);
_local4--;
_root[arrProjectiles[_local3].name].removeMovieClip();
arrProjectiles.splice(_local3, 1);
_local3--;
}
_local4++;
}
_local3++;
}
_local4 = 0;
while (_local4 < _local5.length) {
_root[_local5[_local4].name].Collision(_local5[_local4].X, _local5[_local4].Y);
_root[_local5[_local4].name].gotoAndStop(2);
_local4++;
}
_local4 = 0;
while (_local4 < arrProjectiles.length) {
_root[arrProjectiles[_local4].name]._x = _root[arrProjectiles[_local4].name]._x + (arrProjectiles[_local4].dX / 2);
_root[arrProjectiles[_local4].name]._y = _root[arrProjectiles[_local4].name]._y + (arrProjectiles[_local4].dY / 2);
if (((_root[arrProjectiles[_local4].name]._x + _root[arrProjectiles[_local4].name]._width) < 0) || ((_root[arrProjectiles[_local4].name]._x - _root[arrProjectiles[_local4].name]._width) > Stage.width)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
if (((_root[arrProjectiles[_local4].name]._y + _root[arrProjectiles[_local4].name]._height) < 0) || ((_root[arrProjectiles[_local4].name]._y - _root[arrProjectiles[_local4].name]._height) > Stage.height)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
_local4++;
}
_local5 = new Array();
_local3 = 0;
while (_local3 < arrProjectiles.length) {
_local4 = 0;
while (_local4 < arrParticles.length) {
if (_root[arrParticles[_local4]].hitTest(_root[arrProjectiles[_local3].name]._x, _root[arrProjectiles[_local3].name]._y, true) == true) {
_local5.push({name:arrParticles[_local4], X:arrProjectiles[_local3].X, Y:arrProjectiles[_local3].Y});
arrParticles.splice(_local4, 1);
_local4--;
_root[arrProjectiles[_local3].name].removeMovieClip();
arrProjectiles.splice(_local3, 1);
_local3--;
}
_local4++;
}
_local3++;
}
_local4 = 0;
while (_local4 < _local5.length) {
_root[_local5[_local4].name].Collision(_local5[_local4].X, _local5[_local4].Y);
_root[_local5[_local4].name].gotoAndStop(2);
_local4++;
}
if ((arrProjectiles.length == 0) && (projectileOver == true)) {
if (arrParticles.length != 0) {
intState = 3;
_root.messages_mc.gotoAndPlay("retry");
} else {
intState = 4;
var _local10 = ((_global.currentLevel + 5) - 15) / 5;
_global.levels[_local10] = 1;
var _local9 = SharedObject.getLocal("userData");
_local9.data.levelsCompleted = _global.levels;
_global.SoundManager.PlaySound("all");
_root.messages_mc.gotoAndPlay("next");
}
}
}
function LaunchProjectile(deltaX, deltaY, startX, startY, rot) {
var _local2 = "projectile_" + projectileDepth;
arrProjectiles.push({name:_local2, dX:deltaX, dY:deltaY, X:startX, Y:startY});
_root.attachMovie("shootingStar", _local2, projectileDepth);
_root[_local2]._x = startX;
_root[_local2]._y = startY;
_root[_local2]._rotation = rot;
projectileDepth++;
if (projectileDepth > 9999) {
projectileDepth = 5000;
}
}
stop();
var intState = 1;
var vecShootDir;
var arrParticles = new Array();
var arrProjectiles = new Array();
var arrParticlesReset = new Array();
var particleDepth = 1000;
var projectileDepth = 5000;
var arrowDepth = 15000;
var saveX = 0;
var saveY = 0;
var projectileOnScreen = false;
var projectileOver = false;
var saveDepth;
mouseListener = new Object();
mouseListener.onMouseDown = function () {
_root.Shoot();
};
Mouse.addListener(mouseListener);
Frame 120
function GameSetup() {
trace("%%%%%%%%");
trace((_global.currentLevel + " ----- ") + _global.latestLevel);
if (_global.latestLevel == -1) {
_root.gotoAndPlay("splash");
} else if ((_global.latestLevel != 0) && (_global.latestLevel != 20)) {
_global.currentLevel = _global.latestLevel;
_root.gotoAndPlay(_global.latestLevel);
_global.latestLevel = 0;
trace("go here");
} else if ((_global.latestLevel != 0) && (_global.latestLevel == 20)) {
_global.currentLevel = _global.latestLevel;
_global.latestLevel = 0;
}
if (_root.messages_mc.getDepth() != 50000) {
saveDepth = _root.messages_mc.getDepth();
}
vecShootDir = new Vector();
if (_global.musicOn == true) {
_global.myMusicPlayer.SetTrack("game");
_global.myMusicPlayer.SetMaxVolume(40);
_global.myMusicPlayer.PlayWithCrossFade(4);
}
}
function Mediator() {
_global.myMusicPlayer.RunPlayer();
switch (intState) {
case 1 :
AimProjectile();
if (_root.messages_mc.getDepth() != 50000) {
_root.messages_mc.swapDepths(50000);
trace(_root.messages_mc.getDepth());
}
break;
case 2 :
if (projectileOver == false) {
MoveProjectile();
}
DetectParticleCollisions();
MoveProjectilesAndCollide();
break;
case 3 :
if (Key.isDown(32)) {
Reset();
}
break;
case 4 :
if (!Key.isDown(32)) {
break;
}
Next();
}
}
function Reset() {
projectileDepth = 5000;
arrParticles = arrParticlesReset.slice();
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].gotoAndStop(1);
trace(arrParticles[_local2]);
_local2++;
}
trace("-----");
_root.projectile.gotoAndStop(1);
_root.gameBackground.gotoAndStop(1);
_root.messages_mc.gotoAndStop("hide");
projectileOver = false;
projectileOnScreen = false;
intState = 1;
}
function ExitGame() {
CleanupGame();
Mouse.removeListener(mouseListener);
_root.messages_mc.swapDepths(saveDepth);
_global.latestLevel = -1;
_root.gotoAndPlay("level1");
}
function Next() {
_global.currentLevel = _global.currentLevel + 5;
CleanupGame();
_root.messages_mc.swapDepths(saveDepth);
_root.gotoAndPlay(_global.currentLevel);
}
function CleanupGame() {
Mouse.removeListener(mouseListener);
Reset();
var _local3 = 10;
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].swapDepths(_local3);
_local3++;
_root[arrParticles[_local2]].removeMovieClip();
_local2++;
}
delete arrParticles;
arrParticles = new Array();
}
function DetectParticleCollisions() {
var _local3 = new Array();
var _local2 = 0;
while (_local2 < arrParticles.length) {
var _local4 = (_root[arrParticles[_local2]]._width / 2) + 7.5;
if (GetDistance(arrParticles[_local2], "projectile") <= _local4) {
_root[arrParticles[_local2]].Collision(saveX, saveY);
_local3.push(arrParticles[_local2]);
}
_local2++;
}
_local2 = 0;
while (_local2 < _local3.length) {
RemoveParticle(_local3[_local2]);
_root[_local3[_local2]].gotoAndStop(2);
_local2++;
}
}
function RemoveParticle(strName) {
var _local1 = 0;
while (_local1 < arrParticles.length) {
if (strName == arrParticles[_local1]) {
arrParticles.splice(_local1, 1);
break;
}
_local1++;
}
}
function GetDistance(targetA, targetB) {
var _local3 = _root[targetB]._x - _root[targetA]._x;
var _local2 = _root[targetB]._y - _root[targetA]._y;
return(Math.sqrt((_local3 * _local3) + (_local2 * _local2)));
}
function RegisterParticle(particleName) {
arrParticles.push(particleName);
arrParticlesReset.push(particleName);
particleDepth++;
return(particleDepth);
}
function MoveProjectile() {
if (ProjectileOffScreen() == false) {
projectileOnScreen = true;
_root.projectile._x = _root.projectile._x + vecShootDir._x;
_root.projectile._y = _root.projectile._y + vecShootDir._y;
} else if (projectileOnScreen == true) {
projectileOver = true;
} else {
_root.projectile._x = _root.projectile._x + vecShootDir._x;
_root.projectile._y = _root.projectile._y + vecShootDir._y;
}
}
function AimProjectile() {
var _local11 = new Vector();
_local11._x = _xmouse - (Stage.width / 2);
_local11._y = _ymouse - (Stage.height / 2);
var _local12 = Math.atan2(_local11._y, _local11._x);
var _local15 = (360 * _local12) / (Math.PI*2);
var _local6 = _root.gameBackground._width / 2;
_root.projectile._x = (_local6 * Math.cos(_local12)) + (Stage.width / 2);
_root.projectile._y = (_local6 * Math.sin(_local12)) + (Stage.height / 2);
_local11._x = (Stage.width / 2) - _root.projectile._x;
_local11._y = (Stage.height / 2) - _root.projectile._y;
_local12 = Math.atan2(_local11._y, _local11._x);
var _local14 = Math.cos(_local12) * 11;
var _local13 = Math.sin(_local12) * 11;
var _local9 = _root.projectile._x;
var _local10 = _root.projectile._y;
var _local5 = new Array(arrParticles.length);
var _local4 = 0;
while (_local4 < _local5.length) {
_local5[_local4] = 0;
_local4++;
}
var _local8 = 0;
while (_local8 < 70) {
_local9 = _local9 + _local14;
_local10 = _local10 + _local13;
_local4 = 0;
while (_local4 < arrParticles.length) {
var _local7 = (_root[arrParticles[_local4]]._width / 2) + 7.5;
var _local3 = _root[arrParticles[_local4]]._x - _local9;
var _local2 = _root[arrParticles[_local4]]._y - _local10;
_local6 = Math.sqrt((_local3 * _local3) + (_local2 * _local2));
if (_local6 <= _local7) {
_local5[_local4] = 1;
}
_local4++;
}
_local8++;
}
_local4 = 0;
while (_local4 < _local5.length) {
if (_local5[_local4] == 1) {
_root[arrParticles[_local4]].ArrowsOn(arrowDepth, _root.projectile._x, _root.projectile._y);
} else {
_root[arrParticles[_local4]].ArrowsOff();
}
_local4++;
}
}
function TurnOffAllArrows() {
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].ArrowsOff();
_local2++;
}
}
function NextArrowDepth() {
arrowDepth++;
if (arrowDepth > 39999) {
arrowDepth = 15000;
}
}
function DrawLines() {
_root.clear();
_root.lineStyle(2, 16777215, 50);
var _local2 = new Object();
var _local3 = new Object();
_local2.x = _root.projectile._x;
_local2.y = _root.projectile._y;
_local3.x = _xmouse;
_local3.y = _ymouse;
_root.moveTo(_local2.x, _local2.y);
_root.lineTo(_local3.x, _local3.y);
}
function Shoot() {
if ((intState == 1) && (_global.latestLevel != -1)) {
trace("in");
_root.clear();
saveX = _root.projectile._x;
saveY = _root.projectile._y;
var _local4 = new Vector();
_local4._x = (Stage.width / 2) - _root.projectile._x;
_local4._y = (Stage.height / 2) - _root.projectile._y;
var _local5 = Math.atan2(_local4._y, _local4._x);
vecShootDir._x = Math.cos(_local5) * 11;
vecShootDir._y = Math.sin(_local5) * 11;
var _local3 = 100;
do {
if (ProjectileOffScreen() != false) {
break;
}
_root.projectile._x = _root.projectile._x - vecShootDir._x;
_root.projectile._y = _root.projectile._y - vecShootDir._y;
_local3--;
} while (_local3 != 0);
var _local6 = (360 * _local5) / (Math.PI*2);
_root.projectile.gotoAndStop(2);
_root.projectile._rotation = _local6;
_root.gameBackground.gotoAndPlay("hide");
TurnOffAllArrows();
intState = 2;
}
}
function ProjectileOffScreen() {
var _local2 = false;
if (((_root.projectile._x + _root.projectile._width) < 0) || ((_root.projectile._x - _root.projectile._width) > Stage.width)) {
_local2 = true;
}
if (((_root.projectile._y + _root.projectile._height) < 0) || ((_root.projectile._y - _root.projectile._height) > Stage.height)) {
_local2 = true;
}
return(_local2);
}
function MoveProjectilesAndCollide() {
var _local4 = 0;
while (_local4 < arrProjectiles.length) {
_root[arrProjectiles[_local4].name]._x = _root[arrProjectiles[_local4].name]._x + (arrProjectiles[_local4].dX / 2);
_root[arrProjectiles[_local4].name]._y = _root[arrProjectiles[_local4].name]._y + (arrProjectiles[_local4].dY / 2);
if (((_root[arrProjectiles[_local4].name]._x + _root[arrProjectiles[_local4].name]._width) < 0) || ((_root[arrProjectiles[_local4].name]._x - _root[arrProjectiles[_local4].name]._width) > Stage.width)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
if (((_root[arrProjectiles[_local4].name]._y + _root[arrProjectiles[_local4].name]._height) < 0) || ((_root[arrProjectiles[_local4].name]._y - _root[arrProjectiles[_local4].name]._height) > Stage.height)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
_local4++;
}
var _local5 = new Array();
var _local3 = 0;
while (_local3 < arrProjectiles.length) {
_local4 = 0;
while (_local4 < arrParticles.length) {
if (_root[arrParticles[_local4]].hitTest(_root[arrProjectiles[_local3].name]._x, _root[arrProjectiles[_local3].name]._y, true) == true) {
_local5.push({name:arrParticles[_local4], X:arrProjectiles[_local3].X, Y:arrProjectiles[_local3].Y});
arrParticles.splice(_local4, 1);
_local4--;
_root[arrProjectiles[_local3].name].removeMovieClip();
arrProjectiles.splice(_local3, 1);
_local3--;
}
_local4++;
}
_local3++;
}
_local4 = 0;
while (_local4 < _local5.length) {
_root[_local5[_local4].name].Collision(_local5[_local4].X, _local5[_local4].Y);
_root[_local5[_local4].name].gotoAndStop(2);
_local4++;
}
_local4 = 0;
while (_local4 < arrProjectiles.length) {
_root[arrProjectiles[_local4].name]._x = _root[arrProjectiles[_local4].name]._x + (arrProjectiles[_local4].dX / 2);
_root[arrProjectiles[_local4].name]._y = _root[arrProjectiles[_local4].name]._y + (arrProjectiles[_local4].dY / 2);
if (((_root[arrProjectiles[_local4].name]._x + _root[arrProjectiles[_local4].name]._width) < 0) || ((_root[arrProjectiles[_local4].name]._x - _root[arrProjectiles[_local4].name]._width) > Stage.width)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
if (((_root[arrProjectiles[_local4].name]._y + _root[arrProjectiles[_local4].name]._height) < 0) || ((_root[arrProjectiles[_local4].name]._y - _root[arrProjectiles[_local4].name]._height) > Stage.height)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
_local4++;
}
_local5 = new Array();
_local3 = 0;
while (_local3 < arrProjectiles.length) {
_local4 = 0;
while (_local4 < arrParticles.length) {
if (_root[arrParticles[_local4]].hitTest(_root[arrProjectiles[_local3].name]._x, _root[arrProjectiles[_local3].name]._y, true) == true) {
_local5.push({name:arrParticles[_local4], X:arrProjectiles[_local3].X, Y:arrProjectiles[_local3].Y});
arrParticles.splice(_local4, 1);
_local4--;
_root[arrProjectiles[_local3].name].removeMovieClip();
arrProjectiles.splice(_local3, 1);
_local3--;
}
_local4++;
}
_local3++;
}
_local4 = 0;
while (_local4 < _local5.length) {
_root[_local5[_local4].name].Collision(_local5[_local4].X, _local5[_local4].Y);
_root[_local5[_local4].name].gotoAndStop(2);
_local4++;
}
if ((arrProjectiles.length == 0) && (projectileOver == true)) {
if (arrParticles.length != 0) {
intState = 3;
_root.messages_mc.gotoAndPlay("retry");
} else {
intState = 4;
var _local10 = ((_global.currentLevel + 5) - 15) / 5;
_global.levels[_local10] = 1;
var _local9 = SharedObject.getLocal("userData");
_local9.data.levelsCompleted = _global.levels;
_global.SoundManager.PlaySound("all");
_root.messages_mc.gotoAndPlay("next");
}
}
}
function LaunchProjectile(deltaX, deltaY, startX, startY, rot) {
var _local2 = "projectile_" + projectileDepth;
arrProjectiles.push({name:_local2, dX:deltaX, dY:deltaY, X:startX, Y:startY});
_root.attachMovie("shootingStar", _local2, projectileDepth);
_root[_local2]._x = startX;
_root[_local2]._y = startY;
_root[_local2]._rotation = rot;
projectileDepth++;
if (projectileDepth > 9999) {
projectileDepth = 5000;
}
}
stop();
var intState = 1;
var vecShootDir;
var arrParticles = new Array();
var arrProjectiles = new Array();
var arrParticlesReset = new Array();
var particleDepth = 1000;
var projectileDepth = 5000;
var arrowDepth = 15000;
var saveX = 0;
var saveY = 0;
var projectileOnScreen = false;
var projectileOver = false;
var saveDepth;
mouseListener = new Object();
mouseListener.onMouseDown = function () {
_root.Shoot();
};
Mouse.addListener(mouseListener);
Frame 125
function GameSetup() {
trace("%%%%%%%%");
trace((_global.currentLevel + " ----- ") + _global.latestLevel);
if (_global.latestLevel == -1) {
_root.gotoAndPlay("splash");
} else if ((_global.latestLevel != 0) && (_global.latestLevel != 20)) {
_global.currentLevel = _global.latestLevel;
_root.gotoAndPlay(_global.latestLevel);
_global.latestLevel = 0;
trace("go here");
} else if ((_global.latestLevel != 0) && (_global.latestLevel == 20)) {
_global.currentLevel = _global.latestLevel;
_global.latestLevel = 0;
}
if (_root.messages_mc.getDepth() != 50000) {
saveDepth = _root.messages_mc.getDepth();
}
vecShootDir = new Vector();
if (_global.musicOn == true) {
_global.myMusicPlayer.SetTrack("game");
_global.myMusicPlayer.SetMaxVolume(40);
_global.myMusicPlayer.PlayWithCrossFade(4);
}
}
function Mediator() {
_global.myMusicPlayer.RunPlayer();
switch (intState) {
case 1 :
AimProjectile();
if (_root.messages_mc.getDepth() != 50000) {
_root.messages_mc.swapDepths(50000);
trace(_root.messages_mc.getDepth());
}
break;
case 2 :
if (projectileOver == false) {
MoveProjectile();
}
DetectParticleCollisions();
MoveProjectilesAndCollide();
break;
case 3 :
if (Key.isDown(32)) {
Reset();
}
break;
case 4 :
if (!Key.isDown(32)) {
break;
}
Next();
}
}
function Reset() {
projectileDepth = 5000;
arrParticles = arrParticlesReset.slice();
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].gotoAndStop(1);
trace(arrParticles[_local2]);
_local2++;
}
trace("-----");
_root.projectile.gotoAndStop(1);
_root.gameBackground.gotoAndStop(1);
_root.messages_mc.gotoAndStop("hide");
projectileOver = false;
projectileOnScreen = false;
intState = 1;
}
function ExitGame() {
CleanupGame();
Mouse.removeListener(mouseListener);
_root.messages_mc.swapDepths(saveDepth);
_global.latestLevel = -1;
_root.gotoAndPlay("level1");
}
function Next() {
_global.currentLevel = _global.currentLevel + 5;
CleanupGame();
_root.messages_mc.swapDepths(saveDepth);
_root.gotoAndPlay(_global.currentLevel);
}
function CleanupGame() {
Mouse.removeListener(mouseListener);
Reset();
var _local3 = 10;
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].swapDepths(_local3);
_local3++;
_root[arrParticles[_local2]].removeMovieClip();
_local2++;
}
delete arrParticles;
arrParticles = new Array();
}
function DetectParticleCollisions() {
var _local3 = new Array();
var _local2 = 0;
while (_local2 < arrParticles.length) {
var _local4 = (_root[arrParticles[_local2]]._width / 2) + 7.5;
if (GetDistance(arrParticles[_local2], "projectile") <= _local4) {
_root[arrParticles[_local2]].Collision(saveX, saveY);
_local3.push(arrParticles[_local2]);
}
_local2++;
}
_local2 = 0;
while (_local2 < _local3.length) {
RemoveParticle(_local3[_local2]);
_root[_local3[_local2]].gotoAndStop(2);
_local2++;
}
}
function RemoveParticle(strName) {
var _local1 = 0;
while (_local1 < arrParticles.length) {
if (strName == arrParticles[_local1]) {
arrParticles.splice(_local1, 1);
break;
}
_local1++;
}
}
function GetDistance(targetA, targetB) {
var _local3 = _root[targetB]._x - _root[targetA]._x;
var _local2 = _root[targetB]._y - _root[targetA]._y;
return(Math.sqrt((_local3 * _local3) + (_local2 * _local2)));
}
function RegisterParticle(particleName) {
arrParticles.push(particleName);
arrParticlesReset.push(particleName);
particleDepth++;
return(particleDepth);
}
function MoveProjectile() {
if (ProjectileOffScreen() == false) {
projectileOnScreen = true;
_root.projectile._x = _root.projectile._x + vecShootDir._x;
_root.projectile._y = _root.projectile._y + vecShootDir._y;
} else if (projectileOnScreen == true) {
projectileOver = true;
} else {
_root.projectile._x = _root.projectile._x + vecShootDir._x;
_root.projectile._y = _root.projectile._y + vecShootDir._y;
}
}
function AimProjectile() {
var _local11 = new Vector();
_local11._x = _xmouse - (Stage.width / 2);
_local11._y = _ymouse - (Stage.height / 2);
var _local12 = Math.atan2(_local11._y, _local11._x);
var _local15 = (360 * _local12) / (Math.PI*2);
var _local6 = _root.gameBackground._width / 2;
_root.projectile._x = (_local6 * Math.cos(_local12)) + (Stage.width / 2);
_root.projectile._y = (_local6 * Math.sin(_local12)) + (Stage.height / 2);
_local11._x = (Stage.width / 2) - _root.projectile._x;
_local11._y = (Stage.height / 2) - _root.projectile._y;
_local12 = Math.atan2(_local11._y, _local11._x);
var _local14 = Math.cos(_local12) * 11;
var _local13 = Math.sin(_local12) * 11;
var _local9 = _root.projectile._x;
var _local10 = _root.projectile._y;
var _local5 = new Array(arrParticles.length);
var _local4 = 0;
while (_local4 < _local5.length) {
_local5[_local4] = 0;
_local4++;
}
var _local8 = 0;
while (_local8 < 70) {
_local9 = _local9 + _local14;
_local10 = _local10 + _local13;
_local4 = 0;
while (_local4 < arrParticles.length) {
var _local7 = (_root[arrParticles[_local4]]._width / 2) + 7.5;
var _local3 = _root[arrParticles[_local4]]._x - _local9;
var _local2 = _root[arrParticles[_local4]]._y - _local10;
_local6 = Math.sqrt((_local3 * _local3) + (_local2 * _local2));
if (_local6 <= _local7) {
_local5[_local4] = 1;
}
_local4++;
}
_local8++;
}
_local4 = 0;
while (_local4 < _local5.length) {
if (_local5[_local4] == 1) {
_root[arrParticles[_local4]].ArrowsOn(arrowDepth, _root.projectile._x, _root.projectile._y);
} else {
_root[arrParticles[_local4]].ArrowsOff();
}
_local4++;
}
}
function TurnOffAllArrows() {
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].ArrowsOff();
_local2++;
}
}
function NextArrowDepth() {
arrowDepth++;
if (arrowDepth > 39999) {
arrowDepth = 15000;
}
}
function DrawLines() {
_root.clear();
_root.lineStyle(2, 16777215, 50);
var _local2 = new Object();
var _local3 = new Object();
_local2.x = _root.projectile._x;
_local2.y = _root.projectile._y;
_local3.x = _xmouse;
_local3.y = _ymouse;
_root.moveTo(_local2.x, _local2.y);
_root.lineTo(_local3.x, _local3.y);
}
function Shoot() {
if ((intState == 1) && (_global.latestLevel != -1)) {
trace("in");
_root.clear();
saveX = _root.projectile._x;
saveY = _root.projectile._y;
var _local4 = new Vector();
_local4._x = (Stage.width / 2) - _root.projectile._x;
_local4._y = (Stage.height / 2) - _root.projectile._y;
var _local5 = Math.atan2(_local4._y, _local4._x);
vecShootDir._x = Math.cos(_local5) * 11;
vecShootDir._y = Math.sin(_local5) * 11;
var _local3 = 100;
do {
if (ProjectileOffScreen() != false) {
break;
}
_root.projectile._x = _root.projectile._x - vecShootDir._x;
_root.projectile._y = _root.projectile._y - vecShootDir._y;
_local3--;
} while (_local3 != 0);
var _local6 = (360 * _local5) / (Math.PI*2);
_root.projectile.gotoAndStop(2);
_root.projectile._rotation = _local6;
_root.gameBackground.gotoAndPlay("hide");
TurnOffAllArrows();
intState = 2;
}
}
function ProjectileOffScreen() {
var _local2 = false;
if (((_root.projectile._x + _root.projectile._width) < 0) || ((_root.projectile._x - _root.projectile._width) > Stage.width)) {
_local2 = true;
}
if (((_root.projectile._y + _root.projectile._height) < 0) || ((_root.projectile._y - _root.projectile._height) > Stage.height)) {
_local2 = true;
}
return(_local2);
}
function MoveProjectilesAndCollide() {
var _local4 = 0;
while (_local4 < arrProjectiles.length) {
_root[arrProjectiles[_local4].name]._x = _root[arrProjectiles[_local4].name]._x + (arrProjectiles[_local4].dX / 2);
_root[arrProjectiles[_local4].name]._y = _root[arrProjectiles[_local4].name]._y + (arrProjectiles[_local4].dY / 2);
if (((_root[arrProjectiles[_local4].name]._x + _root[arrProjectiles[_local4].name]._width) < 0) || ((_root[arrProjectiles[_local4].name]._x - _root[arrProjectiles[_local4].name]._width) > Stage.width)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
if (((_root[arrProjectiles[_local4].name]._y + _root[arrProjectiles[_local4].name]._height) < 0) || ((_root[arrProjectiles[_local4].name]._y - _root[arrProjectiles[_local4].name]._height) > Stage.height)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
_local4++;
}
var _local5 = new Array();
var _local3 = 0;
while (_local3 < arrProjectiles.length) {
_local4 = 0;
while (_local4 < arrParticles.length) {
if (_root[arrParticles[_local4]].hitTest(_root[arrProjectiles[_local3].name]._x, _root[arrProjectiles[_local3].name]._y, true) == true) {
_local5.push({name:arrParticles[_local4], X:arrProjectiles[_local3].X, Y:arrProjectiles[_local3].Y});
arrParticles.splice(_local4, 1);
_local4--;
_root[arrProjectiles[_local3].name].removeMovieClip();
arrProjectiles.splice(_local3, 1);
_local3--;
}
_local4++;
}
_local3++;
}
_local4 = 0;
while (_local4 < _local5.length) {
_root[_local5[_local4].name].Collision(_local5[_local4].X, _local5[_local4].Y);
_root[_local5[_local4].name].gotoAndStop(2);
_local4++;
}
_local4 = 0;
while (_local4 < arrProjectiles.length) {
_root[arrProjectiles[_local4].name]._x = _root[arrProjectiles[_local4].name]._x + (arrProjectiles[_local4].dX / 2);
_root[arrProjectiles[_local4].name]._y = _root[arrProjectiles[_local4].name]._y + (arrProjectiles[_local4].dY / 2);
if (((_root[arrProjectiles[_local4].name]._x + _root[arrProjectiles[_local4].name]._width) < 0) || ((_root[arrProjectiles[_local4].name]._x - _root[arrProjectiles[_local4].name]._width) > Stage.width)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
if (((_root[arrProjectiles[_local4].name]._y + _root[arrProjectiles[_local4].name]._height) < 0) || ((_root[arrProjectiles[_local4].name]._y - _root[arrProjectiles[_local4].name]._height) > Stage.height)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
_local4++;
}
_local5 = new Array();
_local3 = 0;
while (_local3 < arrProjectiles.length) {
_local4 = 0;
while (_local4 < arrParticles.length) {
if (_root[arrParticles[_local4]].hitTest(_root[arrProjectiles[_local3].name]._x, _root[arrProjectiles[_local3].name]._y, true) == true) {
_local5.push({name:arrParticles[_local4], X:arrProjectiles[_local3].X, Y:arrProjectiles[_local3].Y});
arrParticles.splice(_local4, 1);
_local4--;
_root[arrProjectiles[_local3].name].removeMovieClip();
arrProjectiles.splice(_local3, 1);
_local3--;
}
_local4++;
}
_local3++;
}
_local4 = 0;
while (_local4 < _local5.length) {
_root[_local5[_local4].name].Collision(_local5[_local4].X, _local5[_local4].Y);
_root[_local5[_local4].name].gotoAndStop(2);
_local4++;
}
if ((arrProjectiles.length == 0) && (projectileOver == true)) {
if (arrParticles.length != 0) {
intState = 3;
_root.messages_mc.gotoAndPlay("retry");
} else {
intState = 4;
var _local10 = ((_global.currentLevel + 5) - 15) / 5;
_global.levels[_local10] = 1;
var _local9 = SharedObject.getLocal("userData");
_local9.data.levelsCompleted = _global.levels;
_global.SoundManager.PlaySound("all");
_root.messages_mc.gotoAndPlay("next");
}
}
}
function LaunchProjectile(deltaX, deltaY, startX, startY, rot) {
var _local2 = "projectile_" + projectileDepth;
arrProjectiles.push({name:_local2, dX:deltaX, dY:deltaY, X:startX, Y:startY});
_root.attachMovie("shootingStar", _local2, projectileDepth);
_root[_local2]._x = startX;
_root[_local2]._y = startY;
_root[_local2]._rotation = rot;
projectileDepth++;
if (projectileDepth > 9999) {
projectileDepth = 5000;
}
}
stop();
var intState = 1;
var vecShootDir;
var arrParticles = new Array();
var arrProjectiles = new Array();
var arrParticlesReset = new Array();
var particleDepth = 1000;
var projectileDepth = 5000;
var arrowDepth = 15000;
var saveX = 0;
var saveY = 0;
var projectileOnScreen = false;
var projectileOver = false;
var saveDepth;
mouseListener = new Object();
mouseListener.onMouseDown = function () {
_root.Shoot();
};
Mouse.addListener(mouseListener);
Frame 130
function GameSetup() {
trace("%%%%%%%%");
trace((_global.currentLevel + " ----- ") + _global.latestLevel);
if (_global.latestLevel == -1) {
_root.gotoAndPlay("splash");
} else if ((_global.latestLevel != 0) && (_global.latestLevel != 20)) {
_global.currentLevel = _global.latestLevel;
_root.gotoAndPlay(_global.latestLevel);
_global.latestLevel = 0;
trace("go here");
} else if ((_global.latestLevel != 0) && (_global.latestLevel == 20)) {
_global.currentLevel = _global.latestLevel;
_global.latestLevel = 0;
}
if (_root.messages_mc.getDepth() != 50000) {
saveDepth = _root.messages_mc.getDepth();
}
vecShootDir = new Vector();
if (_global.musicOn == true) {
_global.myMusicPlayer.SetTrack("game");
_global.myMusicPlayer.SetMaxVolume(40);
_global.myMusicPlayer.PlayWithCrossFade(4);
}
}
function Mediator() {
_global.myMusicPlayer.RunPlayer();
switch (intState) {
case 1 :
AimProjectile();
if (_root.messages_mc.getDepth() != 50000) {
_root.messages_mc.swapDepths(50000);
trace(_root.messages_mc.getDepth());
}
break;
case 2 :
if (projectileOver == false) {
MoveProjectile();
}
DetectParticleCollisions();
MoveProjectilesAndCollide();
break;
case 3 :
if (Key.isDown(32)) {
Reset();
}
break;
case 4 :
if (!Key.isDown(32)) {
break;
}
Next();
}
}
function Reset() {
projectileDepth = 5000;
arrParticles = arrParticlesReset.slice();
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].gotoAndStop(1);
trace(arrParticles[_local2]);
_local2++;
}
trace("-----");
_root.projectile.gotoAndStop(1);
_root.gameBackground.gotoAndStop(1);
_root.messages_mc.gotoAndStop("hide");
projectileOver = false;
projectileOnScreen = false;
intState = 1;
}
function ExitGame() {
CleanupGame();
Mouse.removeListener(mouseListener);
_root.messages_mc.swapDepths(saveDepth);
_global.latestLevel = -1;
_root.gotoAndPlay("level1");
}
function Next() {
_global.currentLevel = _global.currentLevel + 5;
CleanupGame();
_root.messages_mc.swapDepths(saveDepth);
_root.gotoAndPlay(_global.currentLevel);
}
function CleanupGame() {
Mouse.removeListener(mouseListener);
Reset();
var _local3 = 10;
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].swapDepths(_local3);
_local3++;
_root[arrParticles[_local2]].removeMovieClip();
_local2++;
}
delete arrParticles;
arrParticles = new Array();
}
function DetectParticleCollisions() {
var _local3 = new Array();
var _local2 = 0;
while (_local2 < arrParticles.length) {
var _local4 = (_root[arrParticles[_local2]]._width / 2) + 7.5;
if (GetDistance(arrParticles[_local2], "projectile") <= _local4) {
_root[arrParticles[_local2]].Collision(saveX, saveY);
_local3.push(arrParticles[_local2]);
}
_local2++;
}
_local2 = 0;
while (_local2 < _local3.length) {
RemoveParticle(_local3[_local2]);
_root[_local3[_local2]].gotoAndStop(2);
_local2++;
}
}
function RemoveParticle(strName) {
var _local1 = 0;
while (_local1 < arrParticles.length) {
if (strName == arrParticles[_local1]) {
arrParticles.splice(_local1, 1);
break;
}
_local1++;
}
}
function GetDistance(targetA, targetB) {
var _local3 = _root[targetB]._x - _root[targetA]._x;
var _local2 = _root[targetB]._y - _root[targetA]._y;
return(Math.sqrt((_local3 * _local3) + (_local2 * _local2)));
}
function RegisterParticle(particleName) {
arrParticles.push(particleName);
arrParticlesReset.push(particleName);
particleDepth++;
return(particleDepth);
}
function MoveProjectile() {
if (ProjectileOffScreen() == false) {
projectileOnScreen = true;
_root.projectile._x = _root.projectile._x + vecShootDir._x;
_root.projectile._y = _root.projectile._y + vecShootDir._y;
} else if (projectileOnScreen == true) {
projectileOver = true;
} else {
_root.projectile._x = _root.projectile._x + vecShootDir._x;
_root.projectile._y = _root.projectile._y + vecShootDir._y;
}
}
function AimProjectile() {
var _local11 = new Vector();
_local11._x = _xmouse - (Stage.width / 2);
_local11._y = _ymouse - (Stage.height / 2);
var _local12 = Math.atan2(_local11._y, _local11._x);
var _local15 = (360 * _local12) / (Math.PI*2);
var _local6 = _root.gameBackground._width / 2;
_root.projectile._x = (_local6 * Math.cos(_local12)) + (Stage.width / 2);
_root.projectile._y = (_local6 * Math.sin(_local12)) + (Stage.height / 2);
_local11._x = (Stage.width / 2) - _root.projectile._x;
_local11._y = (Stage.height / 2) - _root.projectile._y;
_local12 = Math.atan2(_local11._y, _local11._x);
var _local14 = Math.cos(_local12) * 11;
var _local13 = Math.sin(_local12) * 11;
var _local9 = _root.projectile._x;
var _local10 = _root.projectile._y;
var _local5 = new Array(arrParticles.length);
var _local4 = 0;
while (_local4 < _local5.length) {
_local5[_local4] = 0;
_local4++;
}
var _local8 = 0;
while (_local8 < 70) {
_local9 = _local9 + _local14;
_local10 = _local10 + _local13;
_local4 = 0;
while (_local4 < arrParticles.length) {
var _local7 = (_root[arrParticles[_local4]]._width / 2) + 7.5;
var _local3 = _root[arrParticles[_local4]]._x - _local9;
var _local2 = _root[arrParticles[_local4]]._y - _local10;
_local6 = Math.sqrt((_local3 * _local3) + (_local2 * _local2));
if (_local6 <= _local7) {
_local5[_local4] = 1;
}
_local4++;
}
_local8++;
}
_local4 = 0;
while (_local4 < _local5.length) {
if (_local5[_local4] == 1) {
_root[arrParticles[_local4]].ArrowsOn(arrowDepth, _root.projectile._x, _root.projectile._y);
} else {
_root[arrParticles[_local4]].ArrowsOff();
}
_local4++;
}
}
function TurnOffAllArrows() {
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].ArrowsOff();
_local2++;
}
}
function NextArrowDepth() {
arrowDepth++;
if (arrowDepth > 39999) {
arrowDepth = 15000;
}
}
function DrawLines() {
_root.clear();
_root.lineStyle(2, 16777215, 50);
var _local2 = new Object();
var _local3 = new Object();
_local2.x = _root.projectile._x;
_local2.y = _root.projectile._y;
_local3.x = _xmouse;
_local3.y = _ymouse;
_root.moveTo(_local2.x, _local2.y);
_root.lineTo(_local3.x, _local3.y);
}
function Shoot() {
if ((intState == 1) && (_global.latestLevel != -1)) {
trace("in");
_root.clear();
saveX = _root.projectile._x;
saveY = _root.projectile._y;
var _local4 = new Vector();
_local4._x = (Stage.width / 2) - _root.projectile._x;
_local4._y = (Stage.height / 2) - _root.projectile._y;
var _local5 = Math.atan2(_local4._y, _local4._x);
vecShootDir._x = Math.cos(_local5) * 11;
vecShootDir._y = Math.sin(_local5) * 11;
var _local3 = 100;
do {
if (ProjectileOffScreen() != false) {
break;
}
_root.projectile._x = _root.projectile._x - vecShootDir._x;
_root.projectile._y = _root.projectile._y - vecShootDir._y;
_local3--;
} while (_local3 != 0);
var _local6 = (360 * _local5) / (Math.PI*2);
_root.projectile.gotoAndStop(2);
_root.projectile._rotation = _local6;
_root.gameBackground.gotoAndPlay("hide");
TurnOffAllArrows();
intState = 2;
}
}
function ProjectileOffScreen() {
var _local2 = false;
if (((_root.projectile._x + _root.projectile._width) < 0) || ((_root.projectile._x - _root.projectile._width) > Stage.width)) {
_local2 = true;
}
if (((_root.projectile._y + _root.projectile._height) < 0) || ((_root.projectile._y - _root.projectile._height) > Stage.height)) {
_local2 = true;
}
return(_local2);
}
function MoveProjectilesAndCollide() {
var _local4 = 0;
while (_local4 < arrProjectiles.length) {
_root[arrProjectiles[_local4].name]._x = _root[arrProjectiles[_local4].name]._x + (arrProjectiles[_local4].dX / 2);
_root[arrProjectiles[_local4].name]._y = _root[arrProjectiles[_local4].name]._y + (arrProjectiles[_local4].dY / 2);
if (((_root[arrProjectiles[_local4].name]._x + _root[arrProjectiles[_local4].name]._width) < 0) || ((_root[arrProjectiles[_local4].name]._x - _root[arrProjectiles[_local4].name]._width) > Stage.width)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
if (((_root[arrProjectiles[_local4].name]._y + _root[arrProjectiles[_local4].name]._height) < 0) || ((_root[arrProjectiles[_local4].name]._y - _root[arrProjectiles[_local4].name]._height) > Stage.height)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
_local4++;
}
var _local5 = new Array();
var _local3 = 0;
while (_local3 < arrProjectiles.length) {
_local4 = 0;
while (_local4 < arrParticles.length) {
if (_root[arrParticles[_local4]].hitTest(_root[arrProjectiles[_local3].name]._x, _root[arrProjectiles[_local3].name]._y, true) == true) {
_local5.push({name:arrParticles[_local4], X:arrProjectiles[_local3].X, Y:arrProjectiles[_local3].Y});
arrParticles.splice(_local4, 1);
_local4--;
_root[arrProjectiles[_local3].name].removeMovieClip();
arrProjectiles.splice(_local3, 1);
_local3--;
}
_local4++;
}
_local3++;
}
_local4 = 0;
while (_local4 < _local5.length) {
_root[_local5[_local4].name].Collision(_local5[_local4].X, _local5[_local4].Y);
_root[_local5[_local4].name].gotoAndStop(2);
_local4++;
}
_local4 = 0;
while (_local4 < arrProjectiles.length) {
_root[arrProjectiles[_local4].name]._x = _root[arrProjectiles[_local4].name]._x + (arrProjectiles[_local4].dX / 2);
_root[arrProjectiles[_local4].name]._y = _root[arrProjectiles[_local4].name]._y + (arrProjectiles[_local4].dY / 2);
if (((_root[arrProjectiles[_local4].name]._x + _root[arrProjectiles[_local4].name]._width) < 0) || ((_root[arrProjectiles[_local4].name]._x - _root[arrProjectiles[_local4].name]._width) > Stage.width)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
if (((_root[arrProjectiles[_local4].name]._y + _root[arrProjectiles[_local4].name]._height) < 0) || ((_root[arrProjectiles[_local4].name]._y - _root[arrProjectiles[_local4].name]._height) > Stage.height)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
_local4++;
}
_local5 = new Array();
_local3 = 0;
while (_local3 < arrProjectiles.length) {
_local4 = 0;
while (_local4 < arrParticles.length) {
if (_root[arrParticles[_local4]].hitTest(_root[arrProjectiles[_local3].name]._x, _root[arrProjectiles[_local3].name]._y, true) == true) {
_local5.push({name:arrParticles[_local4], X:arrProjectiles[_local3].X, Y:arrProjectiles[_local3].Y});
arrParticles.splice(_local4, 1);
_local4--;
_root[arrProjectiles[_local3].name].removeMovieClip();
arrProjectiles.splice(_local3, 1);
_local3--;
}
_local4++;
}
_local3++;
}
_local4 = 0;
while (_local4 < _local5.length) {
_root[_local5[_local4].name].Collision(_local5[_local4].X, _local5[_local4].Y);
_root[_local5[_local4].name].gotoAndStop(2);
_local4++;
}
if ((arrProjectiles.length == 0) && (projectileOver == true)) {
if (arrParticles.length != 0) {
intState = 3;
_root.messages_mc.gotoAndPlay("retry");
} else {
intState = 4;
var _local10 = ((_global.currentLevel + 5) - 15) / 5;
_global.levels[_local10] = 1;
var _local9 = SharedObject.getLocal("userData");
_local9.data.levelsCompleted = _global.levels;
_global.SoundManager.PlaySound("all");
_root.messages_mc.gotoAndPlay("next");
}
}
}
function LaunchProjectile(deltaX, deltaY, startX, startY, rot) {
var _local2 = "projectile_" + projectileDepth;
arrProjectiles.push({name:_local2, dX:deltaX, dY:deltaY, X:startX, Y:startY});
_root.attachMovie("shootingStar", _local2, projectileDepth);
_root[_local2]._x = startX;
_root[_local2]._y = startY;
_root[_local2]._rotation = rot;
projectileDepth++;
if (projectileDepth > 9999) {
projectileDepth = 5000;
}
}
stop();
var intState = 1;
var vecShootDir;
var arrParticles = new Array();
var arrProjectiles = new Array();
var arrParticlesReset = new Array();
var particleDepth = 1000;
var projectileDepth = 5000;
var arrowDepth = 15000;
var saveX = 0;
var saveY = 0;
var projectileOnScreen = false;
var projectileOver = false;
var saveDepth;
mouseListener = new Object();
mouseListener.onMouseDown = function () {
_root.Shoot();
};
Mouse.addListener(mouseListener);
Frame 135
function GameSetup() {
trace("%%%%%%%%");
trace((_global.currentLevel + " ----- ") + _global.latestLevel);
if (_global.latestLevel == -1) {
_root.gotoAndPlay("splash");
} else if ((_global.latestLevel != 0) && (_global.latestLevel != 20)) {
_global.currentLevel = _global.latestLevel;
_root.gotoAndPlay(_global.latestLevel);
_global.latestLevel = 0;
trace("go here");
} else if ((_global.latestLevel != 0) && (_global.latestLevel == 20)) {
_global.currentLevel = _global.latestLevel;
_global.latestLevel = 0;
}
if (_root.messages_mc.getDepth() != 50000) {
saveDepth = _root.messages_mc.getDepth();
}
vecShootDir = new Vector();
if (_global.musicOn == true) {
_global.myMusicPlayer.SetTrack("game");
_global.myMusicPlayer.SetMaxVolume(40);
_global.myMusicPlayer.PlayWithCrossFade(4);
}
}
function Mediator() {
_global.myMusicPlayer.RunPlayer();
switch (intState) {
case 1 :
AimProjectile();
if (_root.messages_mc.getDepth() != 50000) {
_root.messages_mc.swapDepths(50000);
trace(_root.messages_mc.getDepth());
}
break;
case 2 :
if (projectileOver == false) {
MoveProjectile();
}
DetectParticleCollisions();
MoveProjectilesAndCollide();
break;
case 3 :
if (Key.isDown(32)) {
Reset();
}
break;
case 4 :
if (!Key.isDown(32)) {
break;
}
Next();
}
}
function Reset() {
projectileDepth = 5000;
arrParticles = arrParticlesReset.slice();
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].gotoAndStop(1);
trace(arrParticles[_local2]);
_local2++;
}
trace("-----");
_root.projectile.gotoAndStop(1);
_root.gameBackground.gotoAndStop(1);
_root.messages_mc.gotoAndStop("hide");
projectileOver = false;
projectileOnScreen = false;
intState = 1;
}
function ExitGame() {
CleanupGame();
Mouse.removeListener(mouseListener);
_root.messages_mc.swapDepths(saveDepth);
_global.latestLevel = -1;
_root.gotoAndPlay("level1");
}
function Next() {
_global.currentLevel = _global.currentLevel + 5;
CleanupGame();
_root.messages_mc.swapDepths(saveDepth);
_root.gotoAndPlay(_global.currentLevel);
}
function CleanupGame() {
Mouse.removeListener(mouseListener);
Reset();
var _local3 = 10;
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].swapDepths(_local3);
_local3++;
_root[arrParticles[_local2]].removeMovieClip();
_local2++;
}
delete arrParticles;
arrParticles = new Array();
}
function DetectParticleCollisions() {
var _local3 = new Array();
var _local2 = 0;
while (_local2 < arrParticles.length) {
var _local4 = (_root[arrParticles[_local2]]._width / 2) + 7.5;
if (GetDistance(arrParticles[_local2], "projectile") <= _local4) {
_root[arrParticles[_local2]].Collision(saveX, saveY);
_local3.push(arrParticles[_local2]);
}
_local2++;
}
_local2 = 0;
while (_local2 < _local3.length) {
RemoveParticle(_local3[_local2]);
_root[_local3[_local2]].gotoAndStop(2);
_local2++;
}
}
function RemoveParticle(strName) {
var _local1 = 0;
while (_local1 < arrParticles.length) {
if (strName == arrParticles[_local1]) {
arrParticles.splice(_local1, 1);
break;
}
_local1++;
}
}
function GetDistance(targetA, targetB) {
var _local3 = _root[targetB]._x - _root[targetA]._x;
var _local2 = _root[targetB]._y - _root[targetA]._y;
return(Math.sqrt((_local3 * _local3) + (_local2 * _local2)));
}
function RegisterParticle(particleName) {
arrParticles.push(particleName);
arrParticlesReset.push(particleName);
particleDepth++;
return(particleDepth);
}
function MoveProjectile() {
if (ProjectileOffScreen() == false) {
projectileOnScreen = true;
_root.projectile._x = _root.projectile._x + vecShootDir._x;
_root.projectile._y = _root.projectile._y + vecShootDir._y;
} else if (projectileOnScreen == true) {
projectileOver = true;
} else {
_root.projectile._x = _root.projectile._x + vecShootDir._x;
_root.projectile._y = _root.projectile._y + vecShootDir._y;
}
}
function AimProjectile() {
var _local11 = new Vector();
_local11._x = _xmouse - (Stage.width / 2);
_local11._y = _ymouse - (Stage.height / 2);
var _local12 = Math.atan2(_local11._y, _local11._x);
var _local15 = (360 * _local12) / (Math.PI*2);
var _local6 = _root.gameBackground._width / 2;
_root.projectile._x = (_local6 * Math.cos(_local12)) + (Stage.width / 2);
_root.projectile._y = (_local6 * Math.sin(_local12)) + (Stage.height / 2);
_local11._x = (Stage.width / 2) - _root.projectile._x;
_local11._y = (Stage.height / 2) - _root.projectile._y;
_local12 = Math.atan2(_local11._y, _local11._x);
var _local14 = Math.cos(_local12) * 11;
var _local13 = Math.sin(_local12) * 11;
var _local9 = _root.projectile._x;
var _local10 = _root.projectile._y;
var _local5 = new Array(arrParticles.length);
var _local4 = 0;
while (_local4 < _local5.length) {
_local5[_local4] = 0;
_local4++;
}
var _local8 = 0;
while (_local8 < 70) {
_local9 = _local9 + _local14;
_local10 = _local10 + _local13;
_local4 = 0;
while (_local4 < arrParticles.length) {
var _local7 = (_root[arrParticles[_local4]]._width / 2) + 7.5;
var _local3 = _root[arrParticles[_local4]]._x - _local9;
var _local2 = _root[arrParticles[_local4]]._y - _local10;
_local6 = Math.sqrt((_local3 * _local3) + (_local2 * _local2));
if (_local6 <= _local7) {
_local5[_local4] = 1;
}
_local4++;
}
_local8++;
}
_local4 = 0;
while (_local4 < _local5.length) {
if (_local5[_local4] == 1) {
_root[arrParticles[_local4]].ArrowsOn(arrowDepth, _root.projectile._x, _root.projectile._y);
} else {
_root[arrParticles[_local4]].ArrowsOff();
}
_local4++;
}
}
function TurnOffAllArrows() {
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].ArrowsOff();
_local2++;
}
}
function NextArrowDepth() {
arrowDepth++;
if (arrowDepth > 39999) {
arrowDepth = 15000;
}
}
function DrawLines() {
_root.clear();
_root.lineStyle(2, 16777215, 50);
var _local2 = new Object();
var _local3 = new Object();
_local2.x = _root.projectile._x;
_local2.y = _root.projectile._y;
_local3.x = _xmouse;
_local3.y = _ymouse;
_root.moveTo(_local2.x, _local2.y);
_root.lineTo(_local3.x, _local3.y);
}
function Shoot() {
if ((intState == 1) && (_global.latestLevel != -1)) {
trace("in");
_root.clear();
saveX = _root.projectile._x;
saveY = _root.projectile._y;
var _local4 = new Vector();
_local4._x = (Stage.width / 2) - _root.projectile._x;
_local4._y = (Stage.height / 2) - _root.projectile._y;
var _local5 = Math.atan2(_local4._y, _local4._x);
vecShootDir._x = Math.cos(_local5) * 11;
vecShootDir._y = Math.sin(_local5) * 11;
var _local3 = 100;
do {
if (ProjectileOffScreen() != false) {
break;
}
_root.projectile._x = _root.projectile._x - vecShootDir._x;
_root.projectile._y = _root.projectile._y - vecShootDir._y;
_local3--;
} while (_local3 != 0);
var _local6 = (360 * _local5) / (Math.PI*2);
_root.projectile.gotoAndStop(2);
_root.projectile._rotation = _local6;
_root.gameBackground.gotoAndPlay("hide");
TurnOffAllArrows();
intState = 2;
}
}
function ProjectileOffScreen() {
var _local2 = false;
if (((_root.projectile._x + _root.projectile._width) < 0) || ((_root.projectile._x - _root.projectile._width) > Stage.width)) {
_local2 = true;
}
if (((_root.projectile._y + _root.projectile._height) < 0) || ((_root.projectile._y - _root.projectile._height) > Stage.height)) {
_local2 = true;
}
return(_local2);
}
function MoveProjectilesAndCollide() {
var _local4 = 0;
while (_local4 < arrProjectiles.length) {
_root[arrProjectiles[_local4].name]._x = _root[arrProjectiles[_local4].name]._x + (arrProjectiles[_local4].dX / 2);
_root[arrProjectiles[_local4].name]._y = _root[arrProjectiles[_local4].name]._y + (arrProjectiles[_local4].dY / 2);
if (((_root[arrProjectiles[_local4].name]._x + _root[arrProjectiles[_local4].name]._width) < 0) || ((_root[arrProjectiles[_local4].name]._x - _root[arrProjectiles[_local4].name]._width) > Stage.width)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
if (((_root[arrProjectiles[_local4].name]._y + _root[arrProjectiles[_local4].name]._height) < 0) || ((_root[arrProjectiles[_local4].name]._y - _root[arrProjectiles[_local4].name]._height) > Stage.height)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
_local4++;
}
var _local5 = new Array();
var _local3 = 0;
while (_local3 < arrProjectiles.length) {
_local4 = 0;
while (_local4 < arrParticles.length) {
if (_root[arrParticles[_local4]].hitTest(_root[arrProjectiles[_local3].name]._x, _root[arrProjectiles[_local3].name]._y, true) == true) {
_local5.push({name:arrParticles[_local4], X:arrProjectiles[_local3].X, Y:arrProjectiles[_local3].Y});
arrParticles.splice(_local4, 1);
_local4--;
_root[arrProjectiles[_local3].name].removeMovieClip();
arrProjectiles.splice(_local3, 1);
_local3--;
}
_local4++;
}
_local3++;
}
_local4 = 0;
while (_local4 < _local5.length) {
_root[_local5[_local4].name].Collision(_local5[_local4].X, _local5[_local4].Y);
_root[_local5[_local4].name].gotoAndStop(2);
_local4++;
}
_local4 = 0;
while (_local4 < arrProjectiles.length) {
_root[arrProjectiles[_local4].name]._x = _root[arrProjectiles[_local4].name]._x + (arrProjectiles[_local4].dX / 2);
_root[arrProjectiles[_local4].name]._y = _root[arrProjectiles[_local4].name]._y + (arrProjectiles[_local4].dY / 2);
if (((_root[arrProjectiles[_local4].name]._x + _root[arrProjectiles[_local4].name]._width) < 0) || ((_root[arrProjectiles[_local4].name]._x - _root[arrProjectiles[_local4].name]._width) > Stage.width)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
if (((_root[arrProjectiles[_local4].name]._y + _root[arrProjectiles[_local4].name]._height) < 0) || ((_root[arrProjectiles[_local4].name]._y - _root[arrProjectiles[_local4].name]._height) > Stage.height)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
_local4++;
}
_local5 = new Array();
_local3 = 0;
while (_local3 < arrProjectiles.length) {
_local4 = 0;
while (_local4 < arrParticles.length) {
if (_root[arrParticles[_local4]].hitTest(_root[arrProjectiles[_local3].name]._x, _root[arrProjectiles[_local3].name]._y, true) == true) {
_local5.push({name:arrParticles[_local4], X:arrProjectiles[_local3].X, Y:arrProjectiles[_local3].Y});
arrParticles.splice(_local4, 1);
_local4--;
_root[arrProjectiles[_local3].name].removeMovieClip();
arrProjectiles.splice(_local3, 1);
_local3--;
}
_local4++;
}
_local3++;
}
_local4 = 0;
while (_local4 < _local5.length) {
_root[_local5[_local4].name].Collision(_local5[_local4].X, _local5[_local4].Y);
_root[_local5[_local4].name].gotoAndStop(2);
_local4++;
}
if ((arrProjectiles.length == 0) && (projectileOver == true)) {
if (arrParticles.length != 0) {
intState = 3;
_root.messages_mc.gotoAndPlay("retry");
} else {
intState = 4;
var _local10 = ((_global.currentLevel + 5) - 15) / 5;
_global.levels[_local10] = 1;
var _local9 = SharedObject.getLocal("userData");
_local9.data.levelsCompleted = _global.levels;
_global.SoundManager.PlaySound("all");
_root.messages_mc.gotoAndPlay("next");
}
}
}
function LaunchProjectile(deltaX, deltaY, startX, startY, rot) {
var _local2 = "projectile_" + projectileDepth;
arrProjectiles.push({name:_local2, dX:deltaX, dY:deltaY, X:startX, Y:startY});
_root.attachMovie("shootingStar", _local2, projectileDepth);
_root[_local2]._x = startX;
_root[_local2]._y = startY;
_root[_local2]._rotation = rot;
projectileDepth++;
if (projectileDepth > 9999) {
projectileDepth = 5000;
}
}
stop();
var intState = 1;
var vecShootDir;
var arrParticles = new Array();
var arrProjectiles = new Array();
var arrParticlesReset = new Array();
var particleDepth = 1000;
var projectileDepth = 5000;
var arrowDepth = 15000;
var saveX = 0;
var saveY = 0;
var projectileOnScreen = false;
var projectileOver = false;
var saveDepth;
mouseListener = new Object();
mouseListener.onMouseDown = function () {
_root.Shoot();
};
Mouse.addListener(mouseListener);
Frame 140
function GameSetup() {
trace("%%%%%%%%");
trace((_global.currentLevel + " ----- ") + _global.latestLevel);
if (_global.latestLevel == -1) {
_root.gotoAndPlay("splash");
} else if ((_global.latestLevel != 0) && (_global.latestLevel != 20)) {
_global.currentLevel = _global.latestLevel;
_root.gotoAndPlay(_global.latestLevel);
_global.latestLevel = 0;
trace("go here");
} else if ((_global.latestLevel != 0) && (_global.latestLevel == 20)) {
_global.currentLevel = _global.latestLevel;
_global.latestLevel = 0;
}
if (_root.messages_mc.getDepth() != 50000) {
saveDepth = _root.messages_mc.getDepth();
}
vecShootDir = new Vector();
if (_global.musicOn == true) {
_global.myMusicPlayer.SetTrack("game");
_global.myMusicPlayer.SetMaxVolume(40);
_global.myMusicPlayer.PlayWithCrossFade(4);
}
}
function Mediator() {
_global.myMusicPlayer.RunPlayer();
switch (intState) {
case 1 :
AimProjectile();
if (_root.messages_mc.getDepth() != 50000) {
_root.messages_mc.swapDepths(50000);
trace(_root.messages_mc.getDepth());
}
break;
case 2 :
if (projectileOver == false) {
MoveProjectile();
}
DetectParticleCollisions();
MoveProjectilesAndCollide();
break;
case 3 :
if (Key.isDown(32)) {
Reset();
}
break;
case 4 :
if (!Key.isDown(32)) {
break;
}
Next();
}
}
function Reset() {
projectileDepth = 5000;
arrParticles = arrParticlesReset.slice();
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].gotoAndStop(1);
trace(arrParticles[_local2]);
_local2++;
}
trace("-----");
_root.projectile.gotoAndStop(1);
_root.gameBackground.gotoAndStop(1);
_root.messages_mc.gotoAndStop("hide");
projectileOver = false;
projectileOnScreen = false;
intState = 1;
}
function ExitGame() {
CleanupGame();
Mouse.removeListener(mouseListener);
_root.messages_mc.swapDepths(saveDepth);
_global.latestLevel = -1;
_root.gotoAndPlay("level1");
}
function Next() {
_global.currentLevel = _global.currentLevel + 5;
CleanupGame();
_root.messages_mc.swapDepths(saveDepth);
_root.gotoAndPlay(_global.currentLevel);
}
function CleanupGame() {
Mouse.removeListener(mouseListener);
Reset();
var _local3 = 10;
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].swapDepths(_local3);
_local3++;
_root[arrParticles[_local2]].removeMovieClip();
_local2++;
}
delete arrParticles;
arrParticles = new Array();
}
function DetectParticleCollisions() {
var _local3 = new Array();
var _local2 = 0;
while (_local2 < arrParticles.length) {
var _local4 = (_root[arrParticles[_local2]]._width / 2) + 7.5;
if (GetDistance(arrParticles[_local2], "projectile") <= _local4) {
_root[arrParticles[_local2]].Collision(saveX, saveY);
_local3.push(arrParticles[_local2]);
}
_local2++;
}
_local2 = 0;
while (_local2 < _local3.length) {
RemoveParticle(_local3[_local2]);
_root[_local3[_local2]].gotoAndStop(2);
_local2++;
}
}
function RemoveParticle(strName) {
var _local1 = 0;
while (_local1 < arrParticles.length) {
if (strName == arrParticles[_local1]) {
arrParticles.splice(_local1, 1);
break;
}
_local1++;
}
}
function GetDistance(targetA, targetB) {
var _local3 = _root[targetB]._x - _root[targetA]._x;
var _local2 = _root[targetB]._y - _root[targetA]._y;
return(Math.sqrt((_local3 * _local3) + (_local2 * _local2)));
}
function RegisterParticle(particleName) {
arrParticles.push(particleName);
arrParticlesReset.push(particleName);
particleDepth++;
return(particleDepth);
}
function MoveProjectile() {
if (ProjectileOffScreen() == false) {
projectileOnScreen = true;
_root.projectile._x = _root.projectile._x + vecShootDir._x;
_root.projectile._y = _root.projectile._y + vecShootDir._y;
} else if (projectileOnScreen == true) {
projectileOver = true;
} else {
_root.projectile._x = _root.projectile._x + vecShootDir._x;
_root.projectile._y = _root.projectile._y + vecShootDir._y;
}
}
function AimProjectile() {
var _local11 = new Vector();
_local11._x = _xmouse - (Stage.width / 2);
_local11._y = _ymouse - (Stage.height / 2);
var _local12 = Math.atan2(_local11._y, _local11._x);
var _local15 = (360 * _local12) / (Math.PI*2);
var _local6 = _root.gameBackground._width / 2;
_root.projectile._x = (_local6 * Math.cos(_local12)) + (Stage.width / 2);
_root.projectile._y = (_local6 * Math.sin(_local12)) + (Stage.height / 2);
_local11._x = (Stage.width / 2) - _root.projectile._x;
_local11._y = (Stage.height / 2) - _root.projectile._y;
_local12 = Math.atan2(_local11._y, _local11._x);
var _local14 = Math.cos(_local12) * 11;
var _local13 = Math.sin(_local12) * 11;
var _local9 = _root.projectile._x;
var _local10 = _root.projectile._y;
var _local5 = new Array(arrParticles.length);
var _local4 = 0;
while (_local4 < _local5.length) {
_local5[_local4] = 0;
_local4++;
}
var _local8 = 0;
while (_local8 < 70) {
_local9 = _local9 + _local14;
_local10 = _local10 + _local13;
_local4 = 0;
while (_local4 < arrParticles.length) {
var _local7 = (_root[arrParticles[_local4]]._width / 2) + 7.5;
var _local3 = _root[arrParticles[_local4]]._x - _local9;
var _local2 = _root[arrParticles[_local4]]._y - _local10;
_local6 = Math.sqrt((_local3 * _local3) + (_local2 * _local2));
if (_local6 <= _local7) {
_local5[_local4] = 1;
}
_local4++;
}
_local8++;
}
_local4 = 0;
while (_local4 < _local5.length) {
if (_local5[_local4] == 1) {
_root[arrParticles[_local4]].ArrowsOn(arrowDepth, _root.projectile._x, _root.projectile._y);
} else {
_root[arrParticles[_local4]].ArrowsOff();
}
_local4++;
}
}
function TurnOffAllArrows() {
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].ArrowsOff();
_local2++;
}
}
function NextArrowDepth() {
arrowDepth++;
if (arrowDepth > 39999) {
arrowDepth = 15000;
}
}
function DrawLines() {
_root.clear();
_root.lineStyle(2, 16777215, 50);
var _local2 = new Object();
var _local3 = new Object();
_local2.x = _root.projectile._x;
_local2.y = _root.projectile._y;
_local3.x = _xmouse;
_local3.y = _ymouse;
_root.moveTo(_local2.x, _local2.y);
_root.lineTo(_local3.x, _local3.y);
}
function Shoot() {
if ((intState == 1) && (_global.latestLevel != -1)) {
trace("in");
_root.clear();
saveX = _root.projectile._x;
saveY = _root.projectile._y;
var _local4 = new Vector();
_local4._x = (Stage.width / 2) - _root.projectile._x;
_local4._y = (Stage.height / 2) - _root.projectile._y;
var _local5 = Math.atan2(_local4._y, _local4._x);
vecShootDir._x = Math.cos(_local5) * 11;
vecShootDir._y = Math.sin(_local5) * 11;
var _local3 = 100;
do {
if (ProjectileOffScreen() != false) {
break;
}
_root.projectile._x = _root.projectile._x - vecShootDir._x;
_root.projectile._y = _root.projectile._y - vecShootDir._y;
_local3--;
} while (_local3 != 0);
var _local6 = (360 * _local5) / (Math.PI*2);
_root.projectile.gotoAndStop(2);
_root.projectile._rotation = _local6;
_root.gameBackground.gotoAndPlay("hide");
TurnOffAllArrows();
intState = 2;
}
}
function ProjectileOffScreen() {
var _local2 = false;
if (((_root.projectile._x + _root.projectile._width) < 0) || ((_root.projectile._x - _root.projectile._width) > Stage.width)) {
_local2 = true;
}
if (((_root.projectile._y + _root.projectile._height) < 0) || ((_root.projectile._y - _root.projectile._height) > Stage.height)) {
_local2 = true;
}
return(_local2);
}
function MoveProjectilesAndCollide() {
var _local4 = 0;
while (_local4 < arrProjectiles.length) {
_root[arrProjectiles[_local4].name]._x = _root[arrProjectiles[_local4].name]._x + (arrProjectiles[_local4].dX / 2);
_root[arrProjectiles[_local4].name]._y = _root[arrProjectiles[_local4].name]._y + (arrProjectiles[_local4].dY / 2);
if (((_root[arrProjectiles[_local4].name]._x + _root[arrProjectiles[_local4].name]._width) < 0) || ((_root[arrProjectiles[_local4].name]._x - _root[arrProjectiles[_local4].name]._width) > Stage.width)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
if (((_root[arrProjectiles[_local4].name]._y + _root[arrProjectiles[_local4].name]._height) < 0) || ((_root[arrProjectiles[_local4].name]._y - _root[arrProjectiles[_local4].name]._height) > Stage.height)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
_local4++;
}
var _local5 = new Array();
var _local3 = 0;
while (_local3 < arrProjectiles.length) {
_local4 = 0;
while (_local4 < arrParticles.length) {
if (_root[arrParticles[_local4]].hitTest(_root[arrProjectiles[_local3].name]._x, _root[arrProjectiles[_local3].name]._y, true) == true) {
_local5.push({name:arrParticles[_local4], X:arrProjectiles[_local3].X, Y:arrProjectiles[_local3].Y});
arrParticles.splice(_local4, 1);
_local4--;
_root[arrProjectiles[_local3].name].removeMovieClip();
arrProjectiles.splice(_local3, 1);
_local3--;
}
_local4++;
}
_local3++;
}
_local4 = 0;
while (_local4 < _local5.length) {
_root[_local5[_local4].name].Collision(_local5[_local4].X, _local5[_local4].Y);
_root[_local5[_local4].name].gotoAndStop(2);
_local4++;
}
_local4 = 0;
while (_local4 < arrProjectiles.length) {
_root[arrProjectiles[_local4].name]._x = _root[arrProjectiles[_local4].name]._x + (arrProjectiles[_local4].dX / 2);
_root[arrProjectiles[_local4].name]._y = _root[arrProjectiles[_local4].name]._y + (arrProjectiles[_local4].dY / 2);
if (((_root[arrProjectiles[_local4].name]._x + _root[arrProjectiles[_local4].name]._width) < 0) || ((_root[arrProjectiles[_local4].name]._x - _root[arrProjectiles[_local4].name]._width) > Stage.width)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
if (((_root[arrProjectiles[_local4].name]._y + _root[arrProjectiles[_local4].name]._height) < 0) || ((_root[arrProjectiles[_local4].name]._y - _root[arrProjectiles[_local4].name]._height) > Stage.height)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
_local4++;
}
_local5 = new Array();
_local3 = 0;
while (_local3 < arrProjectiles.length) {
_local4 = 0;
while (_local4 < arrParticles.length) {
if (_root[arrParticles[_local4]].hitTest(_root[arrProjectiles[_local3].name]._x, _root[arrProjectiles[_local3].name]._y, true) == true) {
_local5.push({name:arrParticles[_local4], X:arrProjectiles[_local3].X, Y:arrProjectiles[_local3].Y});
arrParticles.splice(_local4, 1);
_local4--;
_root[arrProjectiles[_local3].name].removeMovieClip();
arrProjectiles.splice(_local3, 1);
_local3--;
}
_local4++;
}
_local3++;
}
_local4 = 0;
while (_local4 < _local5.length) {
_root[_local5[_local4].name].Collision(_local5[_local4].X, _local5[_local4].Y);
_root[_local5[_local4].name].gotoAndStop(2);
_local4++;
}
if ((arrProjectiles.length == 0) && (projectileOver == true)) {
if (arrParticles.length != 0) {
intState = 3;
_root.messages_mc.gotoAndPlay("retry");
} else {
intState = 4;
var _local10 = ((_global.currentLevel + 5) - 15) / 5;
_global.levels[_local10] = 1;
var _local9 = SharedObject.getLocal("userData");
_local9.data.levelsCompleted = _global.levels;
_global.SoundManager.PlaySound("all");
_root.messages_mc.gotoAndPlay("next");
}
}
}
function LaunchProjectile(deltaX, deltaY, startX, startY, rot) {
var _local2 = "projectile_" + projectileDepth;
arrProjectiles.push({name:_local2, dX:deltaX, dY:deltaY, X:startX, Y:startY});
_root.attachMovie("shootingStar", _local2, projectileDepth);
_root[_local2]._x = startX;
_root[_local2]._y = startY;
_root[_local2]._rotation = rot;
projectileDepth++;
if (projectileDepth > 9999) {
projectileDepth = 5000;
}
}
stop();
var intState = 1;
var vecShootDir;
var arrParticles = new Array();
var arrProjectiles = new Array();
var arrParticlesReset = new Array();
var particleDepth = 1000;
var projectileDepth = 5000;
var arrowDepth = 15000;
var saveX = 0;
var saveY = 0;
var projectileOnScreen = false;
var projectileOver = false;
var saveDepth;
mouseListener = new Object();
mouseListener.onMouseDown = function () {
_root.Shoot();
};
Mouse.addListener(mouseListener);
Frame 145
function GameSetup() {
trace("%%%%%%%%");
trace((_global.currentLevel + " ----- ") + _global.latestLevel);
if (_global.latestLevel == -1) {
_root.gotoAndPlay("splash");
} else if ((_global.latestLevel != 0) && (_global.latestLevel != 20)) {
_global.currentLevel = _global.latestLevel;
_root.gotoAndPlay(_global.latestLevel);
_global.latestLevel = 0;
trace("go here");
} else if ((_global.latestLevel != 0) && (_global.latestLevel == 20)) {
_global.currentLevel = _global.latestLevel;
_global.latestLevel = 0;
}
if (_root.messages_mc.getDepth() != 50000) {
saveDepth = _root.messages_mc.getDepth();
}
vecShootDir = new Vector();
if (_global.musicOn == true) {
_global.myMusicPlayer.SetTrack("game");
_global.myMusicPlayer.SetMaxVolume(40);
_global.myMusicPlayer.PlayWithCrossFade(4);
}
}
function Mediator() {
_global.myMusicPlayer.RunPlayer();
switch (intState) {
case 1 :
AimProjectile();
if (_root.messages_mc.getDepth() != 50000) {
_root.messages_mc.swapDepths(50000);
trace(_root.messages_mc.getDepth());
}
break;
case 2 :
if (projectileOver == false) {
MoveProjectile();
}
DetectParticleCollisions();
MoveProjectilesAndCollide();
break;
case 3 :
if (Key.isDown(32)) {
Reset();
}
break;
case 4 :
if (!Key.isDown(32)) {
break;
}
Next();
}
}
function Reset() {
projectileDepth = 5000;
arrParticles = arrParticlesReset.slice();
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].gotoAndStop(1);
trace(arrParticles[_local2]);
_local2++;
}
trace("-----");
_root.projectile.gotoAndStop(1);
_root.gameBackground.gotoAndStop(1);
_root.messages_mc.gotoAndStop("hide");
projectileOver = false;
projectileOnScreen = false;
intState = 1;
}
function ExitGame() {
CleanupGame();
Mouse.removeListener(mouseListener);
_root.messages_mc.swapDepths(saveDepth);
_global.latestLevel = -1;
_root.gotoAndPlay("level1");
}
function Next() {
_global.currentLevel = _global.currentLevel + 5;
CleanupGame();
_root.messages_mc.swapDepths(saveDepth);
_root.gotoAndPlay(_global.currentLevel);
}
function CleanupGame() {
Mouse.removeListener(mouseListener);
Reset();
var _local3 = 10;
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].swapDepths(_local3);
_local3++;
_root[arrParticles[_local2]].removeMovieClip();
_local2++;
}
delete arrParticles;
arrParticles = new Array();
}
function DetectParticleCollisions() {
var _local3 = new Array();
var _local2 = 0;
while (_local2 < arrParticles.length) {
var _local4 = (_root[arrParticles[_local2]]._width / 2) + 7.5;
if (GetDistance(arrParticles[_local2], "projectile") <= _local4) {
_root[arrParticles[_local2]].Collision(saveX, saveY);
_local3.push(arrParticles[_local2]);
}
_local2++;
}
_local2 = 0;
while (_local2 < _local3.length) {
RemoveParticle(_local3[_local2]);
_root[_local3[_local2]].gotoAndStop(2);
_local2++;
}
}
function RemoveParticle(strName) {
var _local1 = 0;
while (_local1 < arrParticles.length) {
if (strName == arrParticles[_local1]) {
arrParticles.splice(_local1, 1);
break;
}
_local1++;
}
}
function GetDistance(targetA, targetB) {
var _local3 = _root[targetB]._x - _root[targetA]._x;
var _local2 = _root[targetB]._y - _root[targetA]._y;
return(Math.sqrt((_local3 * _local3) + (_local2 * _local2)));
}
function RegisterParticle(particleName) {
arrParticles.push(particleName);
arrParticlesReset.push(particleName);
particleDepth++;
return(particleDepth);
}
function MoveProjectile() {
if (ProjectileOffScreen() == false) {
projectileOnScreen = true;
_root.projectile._x = _root.projectile._x + vecShootDir._x;
_root.projectile._y = _root.projectile._y + vecShootDir._y;
} else if (projectileOnScreen == true) {
projectileOver = true;
} else {
_root.projectile._x = _root.projectile._x + vecShootDir._x;
_root.projectile._y = _root.projectile._y + vecShootDir._y;
}
}
function AimProjectile() {
var _local11 = new Vector();
_local11._x = _xmouse - (Stage.width / 2);
_local11._y = _ymouse - (Stage.height / 2);
var _local12 = Math.atan2(_local11._y, _local11._x);
var _local15 = (360 * _local12) / (Math.PI*2);
var _local6 = _root.gameBackground._width / 2;
_root.projectile._x = (_local6 * Math.cos(_local12)) + (Stage.width / 2);
_root.projectile._y = (_local6 * Math.sin(_local12)) + (Stage.height / 2);
_local11._x = (Stage.width / 2) - _root.projectile._x;
_local11._y = (Stage.height / 2) - _root.projectile._y;
_local12 = Math.atan2(_local11._y, _local11._x);
var _local14 = Math.cos(_local12) * 11;
var _local13 = Math.sin(_local12) * 11;
var _local9 = _root.projectile._x;
var _local10 = _root.projectile._y;
var _local5 = new Array(arrParticles.length);
var _local4 = 0;
while (_local4 < _local5.length) {
_local5[_local4] = 0;
_local4++;
}
var _local8 = 0;
while (_local8 < 70) {
_local9 = _local9 + _local14;
_local10 = _local10 + _local13;
_local4 = 0;
while (_local4 < arrParticles.length) {
var _local7 = (_root[arrParticles[_local4]]._width / 2) + 7.5;
var _local3 = _root[arrParticles[_local4]]._x - _local9;
var _local2 = _root[arrParticles[_local4]]._y - _local10;
_local6 = Math.sqrt((_local3 * _local3) + (_local2 * _local2));
if (_local6 <= _local7) {
_local5[_local4] = 1;
}
_local4++;
}
_local8++;
}
_local4 = 0;
while (_local4 < _local5.length) {
if (_local5[_local4] == 1) {
_root[arrParticles[_local4]].ArrowsOn(arrowDepth, _root.projectile._x, _root.projectile._y);
} else {
_root[arrParticles[_local4]].ArrowsOff();
}
_local4++;
}
}
function TurnOffAllArrows() {
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].ArrowsOff();
_local2++;
}
}
function NextArrowDepth() {
arrowDepth++;
if (arrowDepth > 39999) {
arrowDepth = 15000;
}
}
function DrawLines() {
_root.clear();
_root.lineStyle(2, 16777215, 50);
var _local2 = new Object();
var _local3 = new Object();
_local2.x = _root.projectile._x;
_local2.y = _root.projectile._y;
_local3.x = _xmouse;
_local3.y = _ymouse;
_root.moveTo(_local2.x, _local2.y);
_root.lineTo(_local3.x, _local3.y);
}
function Shoot() {
if ((intState == 1) && (_global.latestLevel != -1)) {
trace("in");
_root.clear();
saveX = _root.projectile._x;
saveY = _root.projectile._y;
var _local4 = new Vector();
_local4._x = (Stage.width / 2) - _root.projectile._x;
_local4._y = (Stage.height / 2) - _root.projectile._y;
var _local5 = Math.atan2(_local4._y, _local4._x);
vecShootDir._x = Math.cos(_local5) * 11;
vecShootDir._y = Math.sin(_local5) * 11;
var _local3 = 100;
do {
if (ProjectileOffScreen() != false) {
break;
}
_root.projectile._x = _root.projectile._x - vecShootDir._x;
_root.projectile._y = _root.projectile._y - vecShootDir._y;
_local3--;
} while (_local3 != 0);
var _local6 = (360 * _local5) / (Math.PI*2);
_root.projectile.gotoAndStop(2);
_root.projectile._rotation = _local6;
_root.gameBackground.gotoAndPlay("hide");
TurnOffAllArrows();
intState = 2;
}
}
function ProjectileOffScreen() {
var _local2 = false;
if (((_root.projectile._x + _root.projectile._width) < 0) || ((_root.projectile._x - _root.projectile._width) > Stage.width)) {
_local2 = true;
}
if (((_root.projectile._y + _root.projectile._height) < 0) || ((_root.projectile._y - _root.projectile._height) > Stage.height)) {
_local2 = true;
}
return(_local2);
}
function MoveProjectilesAndCollide() {
var _local4 = 0;
while (_local4 < arrProjectiles.length) {
_root[arrProjectiles[_local4].name]._x = _root[arrProjectiles[_local4].name]._x + (arrProjectiles[_local4].dX / 2);
_root[arrProjectiles[_local4].name]._y = _root[arrProjectiles[_local4].name]._y + (arrProjectiles[_local4].dY / 2);
if (((_root[arrProjectiles[_local4].name]._x + _root[arrProjectiles[_local4].name]._width) < 0) || ((_root[arrProjectiles[_local4].name]._x - _root[arrProjectiles[_local4].name]._width) > Stage.width)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
if (((_root[arrProjectiles[_local4].name]._y + _root[arrProjectiles[_local4].name]._height) < 0) || ((_root[arrProjectiles[_local4].name]._y - _root[arrProjectiles[_local4].name]._height) > Stage.height)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
_local4++;
}
var _local5 = new Array();
var _local3 = 0;
while (_local3 < arrProjectiles.length) {
_local4 = 0;
while (_local4 < arrParticles.length) {
if (_root[arrParticles[_local4]].hitTest(_root[arrProjectiles[_local3].name]._x, _root[arrProjectiles[_local3].name]._y, true) == true) {
_local5.push({name:arrParticles[_local4], X:arrProjectiles[_local3].X, Y:arrProjectiles[_local3].Y});
arrParticles.splice(_local4, 1);
_local4--;
_root[arrProjectiles[_local3].name].removeMovieClip();
arrProjectiles.splice(_local3, 1);
_local3--;
}
_local4++;
}
_local3++;
}
_local4 = 0;
while (_local4 < _local5.length) {
_root[_local5[_local4].name].Collision(_local5[_local4].X, _local5[_local4].Y);
_root[_local5[_local4].name].gotoAndStop(2);
_local4++;
}
_local4 = 0;
while (_local4 < arrProjectiles.length) {
_root[arrProjectiles[_local4].name]._x = _root[arrProjectiles[_local4].name]._x + (arrProjectiles[_local4].dX / 2);
_root[arrProjectiles[_local4].name]._y = _root[arrProjectiles[_local4].name]._y + (arrProjectiles[_local4].dY / 2);
if (((_root[arrProjectiles[_local4].name]._x + _root[arrProjectiles[_local4].name]._width) < 0) || ((_root[arrProjectiles[_local4].name]._x - _root[arrProjectiles[_local4].name]._width) > Stage.width)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
if (((_root[arrProjectiles[_local4].name]._y + _root[arrProjectiles[_local4].name]._height) < 0) || ((_root[arrProjectiles[_local4].name]._y - _root[arrProjectiles[_local4].name]._height) > Stage.height)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
_local4++;
}
_local5 = new Array();
_local3 = 0;
while (_local3 < arrProjectiles.length) {
_local4 = 0;
while (_local4 < arrParticles.length) {
if (_root[arrParticles[_local4]].hitTest(_root[arrProjectiles[_local3].name]._x, _root[arrProjectiles[_local3].name]._y, true) == true) {
_local5.push({name:arrParticles[_local4], X:arrProjectiles[_local3].X, Y:arrProjectiles[_local3].Y});
arrParticles.splice(_local4, 1);
_local4--;
_root[arrProjectiles[_local3].name].removeMovieClip();
arrProjectiles.splice(_local3, 1);
_local3--;
}
_local4++;
}
_local3++;
}
_local4 = 0;
while (_local4 < _local5.length) {
_root[_local5[_local4].name].Collision(_local5[_local4].X, _local5[_local4].Y);
_root[_local5[_local4].name].gotoAndStop(2);
_local4++;
}
if ((arrProjectiles.length == 0) && (projectileOver == true)) {
if (arrParticles.length != 0) {
intState = 3;
_root.messages_mc.gotoAndPlay("retry");
} else {
intState = 4;
var _local10 = ((_global.currentLevel + 5) - 15) / 5;
_global.levels[_local10] = 1;
var _local9 = SharedObject.getLocal("userData");
_local9.data.levelsCompleted = _global.levels;
_global.SoundManager.PlaySound("all");
_root.messages_mc.gotoAndPlay("next");
}
}
}
function LaunchProjectile(deltaX, deltaY, startX, startY, rot) {
var _local2 = "projectile_" + projectileDepth;
arrProjectiles.push({name:_local2, dX:deltaX, dY:deltaY, X:startX, Y:startY});
_root.attachMovie("shootingStar", _local2, projectileDepth);
_root[_local2]._x = startX;
_root[_local2]._y = startY;
_root[_local2]._rotation = rot;
projectileDepth++;
if (projectileDepth > 9999) {
projectileDepth = 5000;
}
}
stop();
var intState = 1;
var vecShootDir;
var arrParticles = new Array();
var arrProjectiles = new Array();
var arrParticlesReset = new Array();
var particleDepth = 1000;
var projectileDepth = 5000;
var arrowDepth = 15000;
var saveX = 0;
var saveY = 0;
var projectileOnScreen = false;
var projectileOver = false;
var saveDepth;
mouseListener = new Object();
mouseListener.onMouseDown = function () {
_root.Shoot();
};
Mouse.addListener(mouseListener);
Frame 150
function GameSetup() {
trace("%%%%%%%%");
trace((_global.currentLevel + " ----- ") + _global.latestLevel);
if (_global.latestLevel == -1) {
_root.gotoAndPlay("splash");
} else if ((_global.latestLevel != 0) && (_global.latestLevel != 20)) {
_global.currentLevel = _global.latestLevel;
_root.gotoAndPlay(_global.latestLevel);
_global.latestLevel = 0;
trace("go here");
} else if ((_global.latestLevel != 0) && (_global.latestLevel == 20)) {
_global.currentLevel = _global.latestLevel;
_global.latestLevel = 0;
}
if (_root.messages_mc.getDepth() != 50000) {
saveDepth = _root.messages_mc.getDepth();
}
vecShootDir = new Vector();
if (_global.musicOn == true) {
_global.myMusicPlayer.SetTrack("game");
_global.myMusicPlayer.SetMaxVolume(40);
_global.myMusicPlayer.PlayWithCrossFade(4);
}
}
function Mediator() {
_global.myMusicPlayer.RunPlayer();
switch (intState) {
case 1 :
AimProjectile();
if (_root.messages_mc.getDepth() != 50000) {
_root.messages_mc.swapDepths(50000);
trace(_root.messages_mc.getDepth());
}
break;
case 2 :
if (projectileOver == false) {
MoveProjectile();
}
DetectParticleCollisions();
MoveProjectilesAndCollide();
break;
case 3 :
if (Key.isDown(32)) {
Reset();
}
break;
case 4 :
if (!Key.isDown(32)) {
break;
}
Next();
}
}
function Reset() {
projectileDepth = 5000;
arrParticles = arrParticlesReset.slice();
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].gotoAndStop(1);
trace(arrParticles[_local2]);
_local2++;
}
trace("-----");
_root.projectile.gotoAndStop(1);
_root.gameBackground.gotoAndStop(1);
_root.messages_mc.gotoAndStop("hide");
projectileOver = false;
projectileOnScreen = false;
intState = 1;
}
function ExitGame() {
CleanupGame();
Mouse.removeListener(mouseListener);
_root.messages_mc.swapDepths(saveDepth);
_global.latestLevel = -1;
_root.gotoAndPlay("level1");
}
function Next() {
_global.currentLevel = _global.currentLevel + 5;
CleanupGame();
_root.messages_mc.swapDepths(saveDepth);
_root.gotoAndPlay(_global.currentLevel);
}
function CleanupGame() {
Mouse.removeListener(mouseListener);
Reset();
var _local3 = 10;
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].swapDepths(_local3);
_local3++;
_root[arrParticles[_local2]].removeMovieClip();
_local2++;
}
delete arrParticles;
arrParticles = new Array();
}
function DetectParticleCollisions() {
var _local3 = new Array();
var _local2 = 0;
while (_local2 < arrParticles.length) {
var _local4 = (_root[arrParticles[_local2]]._width / 2) + 7.5;
if (GetDistance(arrParticles[_local2], "projectile") <= _local4) {
_root[arrParticles[_local2]].Collision(saveX, saveY);
_local3.push(arrParticles[_local2]);
}
_local2++;
}
_local2 = 0;
while (_local2 < _local3.length) {
RemoveParticle(_local3[_local2]);
_root[_local3[_local2]].gotoAndStop(2);
_local2++;
}
}
function RemoveParticle(strName) {
var _local1 = 0;
while (_local1 < arrParticles.length) {
if (strName == arrParticles[_local1]) {
arrParticles.splice(_local1, 1);
break;
}
_local1++;
}
}
function GetDistance(targetA, targetB) {
var _local3 = _root[targetB]._x - _root[targetA]._x;
var _local2 = _root[targetB]._y - _root[targetA]._y;
return(Math.sqrt((_local3 * _local3) + (_local2 * _local2)));
}
function RegisterParticle(particleName) {
arrParticles.push(particleName);
arrParticlesReset.push(particleName);
particleDepth++;
return(particleDepth);
}
function MoveProjectile() {
if (ProjectileOffScreen() == false) {
projectileOnScreen = true;
_root.projectile._x = _root.projectile._x + vecShootDir._x;
_root.projectile._y = _root.projectile._y + vecShootDir._y;
} else if (projectileOnScreen == true) {
projectileOver = true;
} else {
_root.projectile._x = _root.projectile._x + vecShootDir._x;
_root.projectile._y = _root.projectile._y + vecShootDir._y;
}
}
function AimProjectile() {
var _local11 = new Vector();
_local11._x = _xmouse - (Stage.width / 2);
_local11._y = _ymouse - (Stage.height / 2);
var _local12 = Math.atan2(_local11._y, _local11._x);
var _local15 = (360 * _local12) / (Math.PI*2);
var _local6 = _root.gameBackground._width / 2;
_root.projectile._x = (_local6 * Math.cos(_local12)) + (Stage.width / 2);
_root.projectile._y = (_local6 * Math.sin(_local12)) + (Stage.height / 2);
_local11._x = (Stage.width / 2) - _root.projectile._x;
_local11._y = (Stage.height / 2) - _root.projectile._y;
_local12 = Math.atan2(_local11._y, _local11._x);
var _local14 = Math.cos(_local12) * 11;
var _local13 = Math.sin(_local12) * 11;
var _local9 = _root.projectile._x;
var _local10 = _root.projectile._y;
var _local5 = new Array(arrParticles.length);
var _local4 = 0;
while (_local4 < _local5.length) {
_local5[_local4] = 0;
_local4++;
}
var _local8 = 0;
while (_local8 < 70) {
_local9 = _local9 + _local14;
_local10 = _local10 + _local13;
_local4 = 0;
while (_local4 < arrParticles.length) {
var _local7 = (_root[arrParticles[_local4]]._width / 2) + 7.5;
var _local3 = _root[arrParticles[_local4]]._x - _local9;
var _local2 = _root[arrParticles[_local4]]._y - _local10;
_local6 = Math.sqrt((_local3 * _local3) + (_local2 * _local2));
if (_local6 <= _local7) {
_local5[_local4] = 1;
}
_local4++;
}
_local8++;
}
_local4 = 0;
while (_local4 < _local5.length) {
if (_local5[_local4] == 1) {
_root[arrParticles[_local4]].ArrowsOn(arrowDepth, _root.projectile._x, _root.projectile._y);
} else {
_root[arrParticles[_local4]].ArrowsOff();
}
_local4++;
}
}
function TurnOffAllArrows() {
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].ArrowsOff();
_local2++;
}
}
function NextArrowDepth() {
arrowDepth++;
if (arrowDepth > 39999) {
arrowDepth = 15000;
}
}
function DrawLines() {
_root.clear();
_root.lineStyle(2, 16777215, 50);
var _local2 = new Object();
var _local3 = new Object();
_local2.x = _root.projectile._x;
_local2.y = _root.projectile._y;
_local3.x = _xmouse;
_local3.y = _ymouse;
_root.moveTo(_local2.x, _local2.y);
_root.lineTo(_local3.x, _local3.y);
}
function Shoot() {
if ((intState == 1) && (_global.latestLevel != -1)) {
trace("in");
_root.clear();
saveX = _root.projectile._x;
saveY = _root.projectile._y;
var _local4 = new Vector();
_local4._x = (Stage.width / 2) - _root.projectile._x;
_local4._y = (Stage.height / 2) - _root.projectile._y;
var _local5 = Math.atan2(_local4._y, _local4._x);
vecShootDir._x = Math.cos(_local5) * 11;
vecShootDir._y = Math.sin(_local5) * 11;
var _local3 = 100;
do {
if (ProjectileOffScreen() != false) {
break;
}
_root.projectile._x = _root.projectile._x - vecShootDir._x;
_root.projectile._y = _root.projectile._y - vecShootDir._y;
_local3--;
} while (_local3 != 0);
var _local6 = (360 * _local5) / (Math.PI*2);
_root.projectile.gotoAndStop(2);
_root.projectile._rotation = _local6;
_root.gameBackground.gotoAndPlay("hide");
TurnOffAllArrows();
intState = 2;
}
}
function ProjectileOffScreen() {
var _local2 = false;
if (((_root.projectile._x + _root.projectile._width) < 0) || ((_root.projectile._x - _root.projectile._width) > Stage.width)) {
_local2 = true;
}
if (((_root.projectile._y + _root.projectile._height) < 0) || ((_root.projectile._y - _root.projectile._height) > Stage.height)) {
_local2 = true;
}
return(_local2);
}
function MoveProjectilesAndCollide() {
var _local4 = 0;
while (_local4 < arrProjectiles.length) {
_root[arrProjectiles[_local4].name]._x = _root[arrProjectiles[_local4].name]._x + (arrProjectiles[_local4].dX / 2);
_root[arrProjectiles[_local4].name]._y = _root[arrProjectiles[_local4].name]._y + (arrProjectiles[_local4].dY / 2);
if (((_root[arrProjectiles[_local4].name]._x + _root[arrProjectiles[_local4].name]._width) < 0) || ((_root[arrProjectiles[_local4].name]._x - _root[arrProjectiles[_local4].name]._width) > Stage.width)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
if (((_root[arrProjectiles[_local4].name]._y + _root[arrProjectiles[_local4].name]._height) < 0) || ((_root[arrProjectiles[_local4].name]._y - _root[arrProjectiles[_local4].name]._height) > Stage.height)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
_local4++;
}
var _local5 = new Array();
var _local3 = 0;
while (_local3 < arrProjectiles.length) {
_local4 = 0;
while (_local4 < arrParticles.length) {
if (_root[arrParticles[_local4]].hitTest(_root[arrProjectiles[_local3].name]._x, _root[arrProjectiles[_local3].name]._y, true) == true) {
_local5.push({name:arrParticles[_local4], X:arrProjectiles[_local3].X, Y:arrProjectiles[_local3].Y});
arrParticles.splice(_local4, 1);
_local4--;
_root[arrProjectiles[_local3].name].removeMovieClip();
arrProjectiles.splice(_local3, 1);
_local3--;
}
_local4++;
}
_local3++;
}
_local4 = 0;
while (_local4 < _local5.length) {
_root[_local5[_local4].name].Collision(_local5[_local4].X, _local5[_local4].Y);
_root[_local5[_local4].name].gotoAndStop(2);
_local4++;
}
_local4 = 0;
while (_local4 < arrProjectiles.length) {
_root[arrProjectiles[_local4].name]._x = _root[arrProjectiles[_local4].name]._x + (arrProjectiles[_local4].dX / 2);
_root[arrProjectiles[_local4].name]._y = _root[arrProjectiles[_local4].name]._y + (arrProjectiles[_local4].dY / 2);
if (((_root[arrProjectiles[_local4].name]._x + _root[arrProjectiles[_local4].name]._width) < 0) || ((_root[arrProjectiles[_local4].name]._x - _root[arrProjectiles[_local4].name]._width) > Stage.width)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
if (((_root[arrProjectiles[_local4].name]._y + _root[arrProjectiles[_local4].name]._height) < 0) || ((_root[arrProjectiles[_local4].name]._y - _root[arrProjectiles[_local4].name]._height) > Stage.height)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
_local4++;
}
_local5 = new Array();
_local3 = 0;
while (_local3 < arrProjectiles.length) {
_local4 = 0;
while (_local4 < arrParticles.length) {
if (_root[arrParticles[_local4]].hitTest(_root[arrProjectiles[_local3].name]._x, _root[arrProjectiles[_local3].name]._y, true) == true) {
_local5.push({name:arrParticles[_local4], X:arrProjectiles[_local3].X, Y:arrProjectiles[_local3].Y});
arrParticles.splice(_local4, 1);
_local4--;
_root[arrProjectiles[_local3].name].removeMovieClip();
arrProjectiles.splice(_local3, 1);
_local3--;
}
_local4++;
}
_local3++;
}
_local4 = 0;
while (_local4 < _local5.length) {
_root[_local5[_local4].name].Collision(_local5[_local4].X, _local5[_local4].Y);
_root[_local5[_local4].name].gotoAndStop(2);
_local4++;
}
if ((arrProjectiles.length == 0) && (projectileOver == true)) {
if (arrParticles.length != 0) {
intState = 3;
_root.messages_mc.gotoAndPlay("retry");
} else {
intState = 4;
var _local10 = ((_global.currentLevel + 5) - 15) / 5;
_global.levels[_local10] = 1;
var _local9 = SharedObject.getLocal("userData");
_local9.data.levelsCompleted = _global.levels;
_global.SoundManager.PlaySound("all");
_root.messages_mc.gotoAndPlay("next");
}
}
}
function LaunchProjectile(deltaX, deltaY, startX, startY, rot) {
var _local2 = "projectile_" + projectileDepth;
arrProjectiles.push({name:_local2, dX:deltaX, dY:deltaY, X:startX, Y:startY});
_root.attachMovie("shootingStar", _local2, projectileDepth);
_root[_local2]._x = startX;
_root[_local2]._y = startY;
_root[_local2]._rotation = rot;
projectileDepth++;
if (projectileDepth > 9999) {
projectileDepth = 5000;
}
}
stop();
var intState = 1;
var vecShootDir;
var arrParticles = new Array();
var arrProjectiles = new Array();
var arrParticlesReset = new Array();
var particleDepth = 1000;
var projectileDepth = 5000;
var arrowDepth = 15000;
var saveX = 0;
var saveY = 0;
var projectileOnScreen = false;
var projectileOver = false;
var saveDepth;
mouseListener = new Object();
mouseListener.onMouseDown = function () {
_root.Shoot();
};
Mouse.addListener(mouseListener);
Frame 155
function GameSetup() {
trace("%%%%%%%%");
trace((_global.currentLevel + " ----- ") + _global.latestLevel);
if (_global.latestLevel == -1) {
_root.gotoAndPlay("splash");
} else if ((_global.latestLevel != 0) && (_global.latestLevel != 20)) {
_global.currentLevel = _global.latestLevel;
_root.gotoAndPlay(_global.latestLevel);
_global.latestLevel = 0;
trace("go here");
} else if ((_global.latestLevel != 0) && (_global.latestLevel == 20)) {
_global.currentLevel = _global.latestLevel;
_global.latestLevel = 0;
}
if (_root.messages_mc.getDepth() != 50000) {
saveDepth = _root.messages_mc.getDepth();
}
vecShootDir = new Vector();
if (_global.musicOn == true) {
_global.myMusicPlayer.SetTrack("game");
_global.myMusicPlayer.SetMaxVolume(40);
_global.myMusicPlayer.PlayWithCrossFade(4);
}
}
function Mediator() {
_global.myMusicPlayer.RunPlayer();
switch (intState) {
case 1 :
AimProjectile();
if (_root.messages_mc.getDepth() != 50000) {
_root.messages_mc.swapDepths(50000);
trace(_root.messages_mc.getDepth());
}
break;
case 2 :
if (projectileOver == false) {
MoveProjectile();
}
DetectParticleCollisions();
MoveProjectilesAndCollide();
break;
case 3 :
if (Key.isDown(32)) {
Reset();
}
break;
case 4 :
if (!Key.isDown(32)) {
break;
}
Next();
}
}
function Reset() {
projectileDepth = 5000;
arrParticles = arrParticlesReset.slice();
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].gotoAndStop(1);
trace(arrParticles[_local2]);
_local2++;
}
trace("-----");
_root.projectile.gotoAndStop(1);
_root.gameBackground.gotoAndStop(1);
_root.messages_mc.gotoAndStop("hide");
projectileOver = false;
projectileOnScreen = false;
intState = 1;
}
function ExitGame() {
CleanupGame();
Mouse.removeListener(mouseListener);
_root.messages_mc.swapDepths(saveDepth);
_global.latestLevel = -1;
_root.gotoAndPlay("level1");
}
function Next() {
_global.currentLevel = _global.currentLevel + 5;
CleanupGame();
_root.messages_mc.swapDepths(saveDepth);
_root.gotoAndPlay(_global.currentLevel);
}
function CleanupGame() {
Mouse.removeListener(mouseListener);
Reset();
var _local3 = 10;
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].swapDepths(_local3);
_local3++;
_root[arrParticles[_local2]].removeMovieClip();
_local2++;
}
delete arrParticles;
arrParticles = new Array();
}
function DetectParticleCollisions() {
var _local3 = new Array();
var _local2 = 0;
while (_local2 < arrParticles.length) {
var _local4 = (_root[arrParticles[_local2]]._width / 2) + 7.5;
if (GetDistance(arrParticles[_local2], "projectile") <= _local4) {
_root[arrParticles[_local2]].Collision(saveX, saveY);
_local3.push(arrParticles[_local2]);
}
_local2++;
}
_local2 = 0;
while (_local2 < _local3.length) {
RemoveParticle(_local3[_local2]);
_root[_local3[_local2]].gotoAndStop(2);
_local2++;
}
}
function RemoveParticle(strName) {
var _local1 = 0;
while (_local1 < arrParticles.length) {
if (strName == arrParticles[_local1]) {
arrParticles.splice(_local1, 1);
break;
}
_local1++;
}
}
function GetDistance(targetA, targetB) {
var _local3 = _root[targetB]._x - _root[targetA]._x;
var _local2 = _root[targetB]._y - _root[targetA]._y;
return(Math.sqrt((_local3 * _local3) + (_local2 * _local2)));
}
function RegisterParticle(particleName) {
arrParticles.push(particleName);
arrParticlesReset.push(particleName);
particleDepth++;
return(particleDepth);
}
function MoveProjectile() {
if (ProjectileOffScreen() == false) {
projectileOnScreen = true;
_root.projectile._x = _root.projectile._x + vecShootDir._x;
_root.projectile._y = _root.projectile._y + vecShootDir._y;
} else if (projectileOnScreen == true) {
projectileOver = true;
} else {
_root.projectile._x = _root.projectile._x + vecShootDir._x;
_root.projectile._y = _root.projectile._y + vecShootDir._y;
}
}
function AimProjectile() {
var _local11 = new Vector();
_local11._x = _xmouse - (Stage.width / 2);
_local11._y = _ymouse - (Stage.height / 2);
var _local12 = Math.atan2(_local11._y, _local11._x);
var _local15 = (360 * _local12) / (Math.PI*2);
var _local6 = _root.gameBackground._width / 2;
_root.projectile._x = (_local6 * Math.cos(_local12)) + (Stage.width / 2);
_root.projectile._y = (_local6 * Math.sin(_local12)) + (Stage.height / 2);
_local11._x = (Stage.width / 2) - _root.projectile._x;
_local11._y = (Stage.height / 2) - _root.projectile._y;
_local12 = Math.atan2(_local11._y, _local11._x);
var _local14 = Math.cos(_local12) * 11;
var _local13 = Math.sin(_local12) * 11;
var _local9 = _root.projectile._x;
var _local10 = _root.projectile._y;
var _local5 = new Array(arrParticles.length);
var _local4 = 0;
while (_local4 < _local5.length) {
_local5[_local4] = 0;
_local4++;
}
var _local8 = 0;
while (_local8 < 70) {
_local9 = _local9 + _local14;
_local10 = _local10 + _local13;
_local4 = 0;
while (_local4 < arrParticles.length) {
var _local7 = (_root[arrParticles[_local4]]._width / 2) + 7.5;
var _local3 = _root[arrParticles[_local4]]._x - _local9;
var _local2 = _root[arrParticles[_local4]]._y - _local10;
_local6 = Math.sqrt((_local3 * _local3) + (_local2 * _local2));
if (_local6 <= _local7) {
_local5[_local4] = 1;
}
_local4++;
}
_local8++;
}
_local4 = 0;
while (_local4 < _local5.length) {
if (_local5[_local4] == 1) {
_root[arrParticles[_local4]].ArrowsOn(arrowDepth, _root.projectile._x, _root.projectile._y);
} else {
_root[arrParticles[_local4]].ArrowsOff();
}
_local4++;
}
}
function TurnOffAllArrows() {
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].ArrowsOff();
_local2++;
}
}
function NextArrowDepth() {
arrowDepth++;
if (arrowDepth > 39999) {
arrowDepth = 15000;
}
}
function DrawLines() {
_root.clear();
_root.lineStyle(2, 16777215, 50);
var _local2 = new Object();
var _local3 = new Object();
_local2.x = _root.projectile._x;
_local2.y = _root.projectile._y;
_local3.x = _xmouse;
_local3.y = _ymouse;
_root.moveTo(_local2.x, _local2.y);
_root.lineTo(_local3.x, _local3.y);
}
function Shoot() {
if ((intState == 1) && (_global.latestLevel != -1)) {
trace("in");
_root.clear();
saveX = _root.projectile._x;
saveY = _root.projectile._y;
var _local4 = new Vector();
_local4._x = (Stage.width / 2) - _root.projectile._x;
_local4._y = (Stage.height / 2) - _root.projectile._y;
var _local5 = Math.atan2(_local4._y, _local4._x);
vecShootDir._x = Math.cos(_local5) * 11;
vecShootDir._y = Math.sin(_local5) * 11;
var _local3 = 100;
do {
if (ProjectileOffScreen() != false) {
break;
}
_root.projectile._x = _root.projectile._x - vecShootDir._x;
_root.projectile._y = _root.projectile._y - vecShootDir._y;
_local3--;
} while (_local3 != 0);
var _local6 = (360 * _local5) / (Math.PI*2);
_root.projectile.gotoAndStop(2);
_root.projectile._rotation = _local6;
_root.gameBackground.gotoAndPlay("hide");
TurnOffAllArrows();
intState = 2;
}
}
function ProjectileOffScreen() {
var _local2 = false;
if (((_root.projectile._x + _root.projectile._width) < 0) || ((_root.projectile._x - _root.projectile._width) > Stage.width)) {
_local2 = true;
}
if (((_root.projectile._y + _root.projectile._height) < 0) || ((_root.projectile._y - _root.projectile._height) > Stage.height)) {
_local2 = true;
}
return(_local2);
}
function MoveProjectilesAndCollide() {
var _local4 = 0;
while (_local4 < arrProjectiles.length) {
_root[arrProjectiles[_local4].name]._x = _root[arrProjectiles[_local4].name]._x + (arrProjectiles[_local4].dX / 2);
_root[arrProjectiles[_local4].name]._y = _root[arrProjectiles[_local4].name]._y + (arrProjectiles[_local4].dY / 2);
if (((_root[arrProjectiles[_local4].name]._x + _root[arrProjectiles[_local4].name]._width) < 0) || ((_root[arrProjectiles[_local4].name]._x - _root[arrProjectiles[_local4].name]._width) > Stage.width)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
if (((_root[arrProjectiles[_local4].name]._y + _root[arrProjectiles[_local4].name]._height) < 0) || ((_root[arrProjectiles[_local4].name]._y - _root[arrProjectiles[_local4].name]._height) > Stage.height)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
_local4++;
}
var _local5 = new Array();
var _local3 = 0;
while (_local3 < arrProjectiles.length) {
_local4 = 0;
while (_local4 < arrParticles.length) {
if (_root[arrParticles[_local4]].hitTest(_root[arrProjectiles[_local3].name]._x, _root[arrProjectiles[_local3].name]._y, true) == true) {
_local5.push({name:arrParticles[_local4], X:arrProjectiles[_local3].X, Y:arrProjectiles[_local3].Y});
arrParticles.splice(_local4, 1);
_local4--;
_root[arrProjectiles[_local3].name].removeMovieClip();
arrProjectiles.splice(_local3, 1);
_local3--;
}
_local4++;
}
_local3++;
}
_local4 = 0;
while (_local4 < _local5.length) {
_root[_local5[_local4].name].Collision(_local5[_local4].X, _local5[_local4].Y);
_root[_local5[_local4].name].gotoAndStop(2);
_local4++;
}
_local4 = 0;
while (_local4 < arrProjectiles.length) {
_root[arrProjectiles[_local4].name]._x = _root[arrProjectiles[_local4].name]._x + (arrProjectiles[_local4].dX / 2);
_root[arrProjectiles[_local4].name]._y = _root[arrProjectiles[_local4].name]._y + (arrProjectiles[_local4].dY / 2);
if (((_root[arrProjectiles[_local4].name]._x + _root[arrProjectiles[_local4].name]._width) < 0) || ((_root[arrProjectiles[_local4].name]._x - _root[arrProjectiles[_local4].name]._width) > Stage.width)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
if (((_root[arrProjectiles[_local4].name]._y + _root[arrProjectiles[_local4].name]._height) < 0) || ((_root[arrProjectiles[_local4].name]._y - _root[arrProjectiles[_local4].name]._height) > Stage.height)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
_local4++;
}
_local5 = new Array();
_local3 = 0;
while (_local3 < arrProjectiles.length) {
_local4 = 0;
while (_local4 < arrParticles.length) {
if (_root[arrParticles[_local4]].hitTest(_root[arrProjectiles[_local3].name]._x, _root[arrProjectiles[_local3].name]._y, true) == true) {
_local5.push({name:arrParticles[_local4], X:arrProjectiles[_local3].X, Y:arrProjectiles[_local3].Y});
arrParticles.splice(_local4, 1);
_local4--;
_root[arrProjectiles[_local3].name].removeMovieClip();
arrProjectiles.splice(_local3, 1);
_local3--;
}
_local4++;
}
_local3++;
}
_local4 = 0;
while (_local4 < _local5.length) {
_root[_local5[_local4].name].Collision(_local5[_local4].X, _local5[_local4].Y);
_root[_local5[_local4].name].gotoAndStop(2);
_local4++;
}
if ((arrProjectiles.length == 0) && (projectileOver == true)) {
if (arrParticles.length != 0) {
intState = 3;
_root.messages_mc.gotoAndPlay("retry");
} else {
intState = 4;
var _local10 = ((_global.currentLevel + 5) - 15) / 5;
_global.levels[_local10] = 1;
var _local9 = SharedObject.getLocal("userData");
_local9.data.levelsCompleted = _global.levels;
_global.SoundManager.PlaySound("all");
_root.messages_mc.gotoAndPlay("next");
}
}
}
function LaunchProjectile(deltaX, deltaY, startX, startY, rot) {
var _local2 = "projectile_" + projectileDepth;
arrProjectiles.push({name:_local2, dX:deltaX, dY:deltaY, X:startX, Y:startY});
_root.attachMovie("shootingStar", _local2, projectileDepth);
_root[_local2]._x = startX;
_root[_local2]._y = startY;
_root[_local2]._rotation = rot;
projectileDepth++;
if (projectileDepth > 9999) {
projectileDepth = 5000;
}
}
stop();
var intState = 1;
var vecShootDir;
var arrParticles = new Array();
var arrProjectiles = new Array();
var arrParticlesReset = new Array();
var particleDepth = 1000;
var projectileDepth = 5000;
var arrowDepth = 15000;
var saveX = 0;
var saveY = 0;
var projectileOnScreen = false;
var projectileOver = false;
var saveDepth;
mouseListener = new Object();
mouseListener.onMouseDown = function () {
_root.Shoot();
};
Mouse.addListener(mouseListener);
Frame 160
function GameSetup() {
trace("%%%%%%%%");
trace((_global.currentLevel + " ----- ") + _global.latestLevel);
if (_global.latestLevel == -1) {
_root.gotoAndPlay("splash");
} else if ((_global.latestLevel != 0) && (_global.latestLevel != 20)) {
_global.currentLevel = _global.latestLevel;
_root.gotoAndPlay(_global.latestLevel);
_global.latestLevel = 0;
trace("go here");
} else if ((_global.latestLevel != 0) && (_global.latestLevel == 20)) {
_global.currentLevel = _global.latestLevel;
_global.latestLevel = 0;
}
if (_root.messages_mc.getDepth() != 50000) {
saveDepth = _root.messages_mc.getDepth();
}
vecShootDir = new Vector();
if (_global.musicOn == true) {
_global.myMusicPlayer.SetTrack("game");
_global.myMusicPlayer.SetMaxVolume(40);
_global.myMusicPlayer.PlayWithCrossFade(4);
}
}
function Mediator() {
_global.myMusicPlayer.RunPlayer();
switch (intState) {
case 1 :
AimProjectile();
if (_root.messages_mc.getDepth() != 50000) {
_root.messages_mc.swapDepths(50000);
trace(_root.messages_mc.getDepth());
}
break;
case 2 :
if (projectileOver == false) {
MoveProjectile();
}
DetectParticleCollisions();
MoveProjectilesAndCollide();
break;
case 3 :
if (Key.isDown(32)) {
Reset();
}
break;
case 4 :
if (!Key.isDown(32)) {
break;
}
Next();
}
}
function Reset() {
projectileDepth = 5000;
arrParticles = arrParticlesReset.slice();
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].gotoAndStop(1);
trace(arrParticles[_local2]);
_local2++;
}
trace("-----");
_root.projectile.gotoAndStop(1);
_root.gameBackground.gotoAndStop(1);
_root.messages_mc.gotoAndStop("hide");
projectileOver = false;
projectileOnScreen = false;
intState = 1;
}
function ExitGame() {
CleanupGame();
Mouse.removeListener(mouseListener);
_root.messages_mc.swapDepths(saveDepth);
_global.latestLevel = -1;
_root.gotoAndPlay("level1");
}
function Next() {
_global.currentLevel = _global.currentLevel + 5;
CleanupGame();
_root.messages_mc.swapDepths(saveDepth);
_root.gotoAndPlay(_global.currentLevel);
}
function CleanupGame() {
Mouse.removeListener(mouseListener);
Reset();
var _local3 = 10;
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].swapDepths(_local3);
_local3++;
_root[arrParticles[_local2]].removeMovieClip();
_local2++;
}
delete arrParticles;
arrParticles = new Array();
}
function DetectParticleCollisions() {
var _local3 = new Array();
var _local2 = 0;
while (_local2 < arrParticles.length) {
var _local4 = (_root[arrParticles[_local2]]._width / 2) + 7.5;
if (GetDistance(arrParticles[_local2], "projectile") <= _local4) {
_root[arrParticles[_local2]].Collision(saveX, saveY);
_local3.push(arrParticles[_local2]);
}
_local2++;
}
_local2 = 0;
while (_local2 < _local3.length) {
RemoveParticle(_local3[_local2]);
_root[_local3[_local2]].gotoAndStop(2);
_local2++;
}
}
function RemoveParticle(strName) {
var _local1 = 0;
while (_local1 < arrParticles.length) {
if (strName == arrParticles[_local1]) {
arrParticles.splice(_local1, 1);
break;
}
_local1++;
}
}
function GetDistance(targetA, targetB) {
var _local3 = _root[targetB]._x - _root[targetA]._x;
var _local2 = _root[targetB]._y - _root[targetA]._y;
return(Math.sqrt((_local3 * _local3) + (_local2 * _local2)));
}
function RegisterParticle(particleName) {
arrParticles.push(particleName);
arrParticlesReset.push(particleName);
particleDepth++;
return(particleDepth);
}
function MoveProjectile() {
if (ProjectileOffScreen() == false) {
projectileOnScreen = true;
_root.projectile._x = _root.projectile._x + vecShootDir._x;
_root.projectile._y = _root.projectile._y + vecShootDir._y;
} else if (projectileOnScreen == true) {
projectileOver = true;
} else {
_root.projectile._x = _root.projectile._x + vecShootDir._x;
_root.projectile._y = _root.projectile._y + vecShootDir._y;
}
}
function AimProjectile() {
var _local11 = new Vector();
_local11._x = _xmouse - (Stage.width / 2);
_local11._y = _ymouse - (Stage.height / 2);
var _local12 = Math.atan2(_local11._y, _local11._x);
var _local15 = (360 * _local12) / (Math.PI*2);
var _local6 = _root.gameBackground._width / 2;
_root.projectile._x = (_local6 * Math.cos(_local12)) + (Stage.width / 2);
_root.projectile._y = (_local6 * Math.sin(_local12)) + (Stage.height / 2);
_local11._x = (Stage.width / 2) - _root.projectile._x;
_local11._y = (Stage.height / 2) - _root.projectile._y;
_local12 = Math.atan2(_local11._y, _local11._x);
var _local14 = Math.cos(_local12) * 11;
var _local13 = Math.sin(_local12) * 11;
var _local9 = _root.projectile._x;
var _local10 = _root.projectile._y;
var _local5 = new Array(arrParticles.length);
var _local4 = 0;
while (_local4 < _local5.length) {
_local5[_local4] = 0;
_local4++;
}
var _local8 = 0;
while (_local8 < 70) {
_local9 = _local9 + _local14;
_local10 = _local10 + _local13;
_local4 = 0;
while (_local4 < arrParticles.length) {
var _local7 = (_root[arrParticles[_local4]]._width / 2) + 7.5;
var _local3 = _root[arrParticles[_local4]]._x - _local9;
var _local2 = _root[arrParticles[_local4]]._y - _local10;
_local6 = Math.sqrt((_local3 * _local3) + (_local2 * _local2));
if (_local6 <= _local7) {
_local5[_local4] = 1;
}
_local4++;
}
_local8++;
}
_local4 = 0;
while (_local4 < _local5.length) {
if (_local5[_local4] == 1) {
_root[arrParticles[_local4]].ArrowsOn(arrowDepth, _root.projectile._x, _root.projectile._y);
} else {
_root[arrParticles[_local4]].ArrowsOff();
}
_local4++;
}
}
function TurnOffAllArrows() {
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].ArrowsOff();
_local2++;
}
}
function NextArrowDepth() {
arrowDepth++;
if (arrowDepth > 39999) {
arrowDepth = 15000;
}
}
function DrawLines() {
_root.clear();
_root.lineStyle(2, 16777215, 50);
var _local2 = new Object();
var _local3 = new Object();
_local2.x = _root.projectile._x;
_local2.y = _root.projectile._y;
_local3.x = _xmouse;
_local3.y = _ymouse;
_root.moveTo(_local2.x, _local2.y);
_root.lineTo(_local3.x, _local3.y);
}
function Shoot() {
if ((intState == 1) && (_global.latestLevel != -1)) {
trace("in");
_root.clear();
saveX = _root.projectile._x;
saveY = _root.projectile._y;
var _local4 = new Vector();
_local4._x = (Stage.width / 2) - _root.projectile._x;
_local4._y = (Stage.height / 2) - _root.projectile._y;
var _local5 = Math.atan2(_local4._y, _local4._x);
vecShootDir._x = Math.cos(_local5) * 11;
vecShootDir._y = Math.sin(_local5) * 11;
var _local3 = 100;
do {
if (ProjectileOffScreen() != false) {
break;
}
_root.projectile._x = _root.projectile._x - vecShootDir._x;
_root.projectile._y = _root.projectile._y - vecShootDir._y;
_local3--;
} while (_local3 != 0);
var _local6 = (360 * _local5) / (Math.PI*2);
_root.projectile.gotoAndStop(2);
_root.projectile._rotation = _local6;
_root.gameBackground.gotoAndPlay("hide");
TurnOffAllArrows();
intState = 2;
}
}
function ProjectileOffScreen() {
var _local2 = false;
if (((_root.projectile._x + _root.projectile._width) < 0) || ((_root.projectile._x - _root.projectile._width) > Stage.width)) {
_local2 = true;
}
if (((_root.projectile._y + _root.projectile._height) < 0) || ((_root.projectile._y - _root.projectile._height) > Stage.height)) {
_local2 = true;
}
return(_local2);
}
function MoveProjectilesAndCollide() {
var _local4 = 0;
while (_local4 < arrProjectiles.length) {
_root[arrProjectiles[_local4].name]._x = _root[arrProjectiles[_local4].name]._x + (arrProjectiles[_local4].dX / 2);
_root[arrProjectiles[_local4].name]._y = _root[arrProjectiles[_local4].name]._y + (arrProjectiles[_local4].dY / 2);
if (((_root[arrProjectiles[_local4].name]._x + _root[arrProjectiles[_local4].name]._width) < 0) || ((_root[arrProjectiles[_local4].name]._x - _root[arrProjectiles[_local4].name]._width) > Stage.width)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
if (((_root[arrProjectiles[_local4].name]._y + _root[arrProjectiles[_local4].name]._height) < 0) || ((_root[arrProjectiles[_local4].name]._y - _root[arrProjectiles[_local4].name]._height) > Stage.height)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
_local4++;
}
var _local5 = new Array();
var _local3 = 0;
while (_local3 < arrProjectiles.length) {
_local4 = 0;
while (_local4 < arrParticles.length) {
if (_root[arrParticles[_local4]].hitTest(_root[arrProjectiles[_local3].name]._x, _root[arrProjectiles[_local3].name]._y, true) == true) {
_local5.push({name:arrParticles[_local4], X:arrProjectiles[_local3].X, Y:arrProjectiles[_local3].Y});
arrParticles.splice(_local4, 1);
_local4--;
_root[arrProjectiles[_local3].name].removeMovieClip();
arrProjectiles.splice(_local3, 1);
_local3--;
}
_local4++;
}
_local3++;
}
_local4 = 0;
while (_local4 < _local5.length) {
_root[_local5[_local4].name].Collision(_local5[_local4].X, _local5[_local4].Y);
_root[_local5[_local4].name].gotoAndStop(2);
_local4++;
}
_local4 = 0;
while (_local4 < arrProjectiles.length) {
_root[arrProjectiles[_local4].name]._x = _root[arrProjectiles[_local4].name]._x + (arrProjectiles[_local4].dX / 2);
_root[arrProjectiles[_local4].name]._y = _root[arrProjectiles[_local4].name]._y + (arrProjectiles[_local4].dY / 2);
if (((_root[arrProjectiles[_local4].name]._x + _root[arrProjectiles[_local4].name]._width) < 0) || ((_root[arrProjectiles[_local4].name]._x - _root[arrProjectiles[_local4].name]._width) > Stage.width)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
if (((_root[arrProjectiles[_local4].name]._y + _root[arrProjectiles[_local4].name]._height) < 0) || ((_root[arrProjectiles[_local4].name]._y - _root[arrProjectiles[_local4].name]._height) > Stage.height)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
_local4++;
}
_local5 = new Array();
_local3 = 0;
while (_local3 < arrProjectiles.length) {
_local4 = 0;
while (_local4 < arrParticles.length) {
if (_root[arrParticles[_local4]].hitTest(_root[arrProjectiles[_local3].name]._x, _root[arrProjectiles[_local3].name]._y, true) == true) {
_local5.push({name:arrParticles[_local4], X:arrProjectiles[_local3].X, Y:arrProjectiles[_local3].Y});
arrParticles.splice(_local4, 1);
_local4--;
_root[arrProjectiles[_local3].name].removeMovieClip();
arrProjectiles.splice(_local3, 1);
_local3--;
}
_local4++;
}
_local3++;
}
_local4 = 0;
while (_local4 < _local5.length) {
_root[_local5[_local4].name].Collision(_local5[_local4].X, _local5[_local4].Y);
_root[_local5[_local4].name].gotoAndStop(2);
_local4++;
}
if ((arrProjectiles.length == 0) && (projectileOver == true)) {
if (arrParticles.length != 0) {
intState = 3;
_root.messages_mc.gotoAndPlay("retry");
} else {
intState = 4;
var _local10 = ((_global.currentLevel + 5) - 15) / 5;
_global.levels[_local10] = 1;
var _local9 = SharedObject.getLocal("userData");
_local9.data.levelsCompleted = _global.levels;
_global.SoundManager.PlaySound("all");
_root.messages_mc.gotoAndPlay("next");
}
}
}
function LaunchProjectile(deltaX, deltaY, startX, startY, rot) {
var _local2 = "projectile_" + projectileDepth;
arrProjectiles.push({name:_local2, dX:deltaX, dY:deltaY, X:startX, Y:startY});
_root.attachMovie("shootingStar", _local2, projectileDepth);
_root[_local2]._x = startX;
_root[_local2]._y = startY;
_root[_local2]._rotation = rot;
projectileDepth++;
if (projectileDepth > 9999) {
projectileDepth = 5000;
}
}
stop();
var intState = 1;
var vecShootDir;
var arrParticles = new Array();
var arrProjectiles = new Array();
var arrParticlesReset = new Array();
var particleDepth = 1000;
var projectileDepth = 5000;
var arrowDepth = 15000;
var saveX = 0;
var saveY = 0;
var projectileOnScreen = false;
var projectileOver = false;
var saveDepth;
mouseListener = new Object();
mouseListener.onMouseDown = function () {
_root.Shoot();
};
Mouse.addListener(mouseListener);
Frame 165
function GameSetup() {
trace("%%%%%%%%");
trace((_global.currentLevel + " ----- ") + _global.latestLevel);
if (_global.latestLevel == -1) {
_root.gotoAndPlay("splash");
} else if ((_global.latestLevel != 0) && (_global.latestLevel != 20)) {
_global.currentLevel = _global.latestLevel;
_root.gotoAndPlay(_global.latestLevel);
_global.latestLevel = 0;
trace("go here");
} else if ((_global.latestLevel != 0) && (_global.latestLevel == 20)) {
_global.currentLevel = _global.latestLevel;
_global.latestLevel = 0;
}
if (_root.messages_mc.getDepth() != 50000) {
saveDepth = _root.messages_mc.getDepth();
}
vecShootDir = new Vector();
if (_global.musicOn == true) {
_global.myMusicPlayer.SetTrack("game");
_global.myMusicPlayer.SetMaxVolume(40);
_global.myMusicPlayer.PlayWithCrossFade(4);
}
}
function Mediator() {
_global.myMusicPlayer.RunPlayer();
switch (intState) {
case 1 :
AimProjectile();
if (_root.messages_mc.getDepth() != 50000) {
_root.messages_mc.swapDepths(50000);
trace(_root.messages_mc.getDepth());
}
break;
case 2 :
if (projectileOver == false) {
MoveProjectile();
}
DetectParticleCollisions();
MoveProjectilesAndCollide();
break;
case 3 :
if (Key.isDown(32)) {
Reset();
}
break;
case 4 :
if (!Key.isDown(32)) {
break;
}
Next();
}
}
function Reset() {
projectileDepth = 5000;
arrParticles = arrParticlesReset.slice();
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].gotoAndStop(1);
trace(arrParticles[_local2]);
_local2++;
}
trace("-----");
_root.projectile.gotoAndStop(1);
_root.gameBackground.gotoAndStop(1);
_root.messages_mc.gotoAndStop("hide");
projectileOver = false;
projectileOnScreen = false;
intState = 1;
}
function ExitGame() {
CleanupGame();
Mouse.removeListener(mouseListener);
_root.messages_mc.swapDepths(saveDepth);
_global.latestLevel = -1;
_root.gotoAndPlay("level1");
}
function Next() {
_global.currentLevel = _global.currentLevel + 5;
CleanupGame();
_root.messages_mc.swapDepths(saveDepth);
_root.gotoAndPlay(_global.currentLevel);
}
function CleanupGame() {
Mouse.removeListener(mouseListener);
Reset();
var _local3 = 10;
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].swapDepths(_local3);
_local3++;
_root[arrParticles[_local2]].removeMovieClip();
_local2++;
}
delete arrParticles;
arrParticles = new Array();
}
function DetectParticleCollisions() {
var _local3 = new Array();
var _local2 = 0;
while (_local2 < arrParticles.length) {
var _local4 = (_root[arrParticles[_local2]]._width / 2) + 7.5;
if (GetDistance(arrParticles[_local2], "projectile") <= _local4) {
_root[arrParticles[_local2]].Collision(saveX, saveY);
_local3.push(arrParticles[_local2]);
}
_local2++;
}
_local2 = 0;
while (_local2 < _local3.length) {
RemoveParticle(_local3[_local2]);
_root[_local3[_local2]].gotoAndStop(2);
_local2++;
}
}
function RemoveParticle(strName) {
var _local1 = 0;
while (_local1 < arrParticles.length) {
if (strName == arrParticles[_local1]) {
arrParticles.splice(_local1, 1);
break;
}
_local1++;
}
}
function GetDistance(targetA, targetB) {
var _local3 = _root[targetB]._x - _root[targetA]._x;
var _local2 = _root[targetB]._y - _root[targetA]._y;
return(Math.sqrt((_local3 * _local3) + (_local2 * _local2)));
}
function RegisterParticle(particleName) {
arrParticles.push(particleName);
arrParticlesReset.push(particleName);
particleDepth++;
return(particleDepth);
}
function MoveProjectile() {
if (ProjectileOffScreen() == false) {
projectileOnScreen = true;
_root.projectile._x = _root.projectile._x + vecShootDir._x;
_root.projectile._y = _root.projectile._y + vecShootDir._y;
} else if (projectileOnScreen == true) {
projectileOver = true;
} else {
_root.projectile._x = _root.projectile._x + vecShootDir._x;
_root.projectile._y = _root.projectile._y + vecShootDir._y;
}
}
function AimProjectile() {
var _local11 = new Vector();
_local11._x = _xmouse - (Stage.width / 2);
_local11._y = _ymouse - (Stage.height / 2);
var _local12 = Math.atan2(_local11._y, _local11._x);
var _local15 = (360 * _local12) / (Math.PI*2);
var _local6 = _root.gameBackground._width / 2;
_root.projectile._x = (_local6 * Math.cos(_local12)) + (Stage.width / 2);
_root.projectile._y = (_local6 * Math.sin(_local12)) + (Stage.height / 2);
_local11._x = (Stage.width / 2) - _root.projectile._x;
_local11._y = (Stage.height / 2) - _root.projectile._y;
_local12 = Math.atan2(_local11._y, _local11._x);
var _local14 = Math.cos(_local12) * 11;
var _local13 = Math.sin(_local12) * 11;
var _local9 = _root.projectile._x;
var _local10 = _root.projectile._y;
var _local5 = new Array(arrParticles.length);
var _local4 = 0;
while (_local4 < _local5.length) {
_local5[_local4] = 0;
_local4++;
}
var _local8 = 0;
while (_local8 < 70) {
_local9 = _local9 + _local14;
_local10 = _local10 + _local13;
_local4 = 0;
while (_local4 < arrParticles.length) {
var _local7 = (_root[arrParticles[_local4]]._width / 2) + 7.5;
var _local3 = _root[arrParticles[_local4]]._x - _local9;
var _local2 = _root[arrParticles[_local4]]._y - _local10;
_local6 = Math.sqrt((_local3 * _local3) + (_local2 * _local2));
if (_local6 <= _local7) {
_local5[_local4] = 1;
}
_local4++;
}
_local8++;
}
_local4 = 0;
while (_local4 < _local5.length) {
if (_local5[_local4] == 1) {
_root[arrParticles[_local4]].ArrowsOn(arrowDepth, _root.projectile._x, _root.projectile._y);
} else {
_root[arrParticles[_local4]].ArrowsOff();
}
_local4++;
}
}
function TurnOffAllArrows() {
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].ArrowsOff();
_local2++;
}
}
function NextArrowDepth() {
arrowDepth++;
if (arrowDepth > 39999) {
arrowDepth = 15000;
}
}
function DrawLines() {
_root.clear();
_root.lineStyle(2, 16777215, 50);
var _local2 = new Object();
var _local3 = new Object();
_local2.x = _root.projectile._x;
_local2.y = _root.projectile._y;
_local3.x = _xmouse;
_local3.y = _ymouse;
_root.moveTo(_local2.x, _local2.y);
_root.lineTo(_local3.x, _local3.y);
}
function Shoot() {
if ((intState == 1) && (_global.latestLevel != -1)) {
trace("in");
_root.clear();
saveX = _root.projectile._x;
saveY = _root.projectile._y;
var _local4 = new Vector();
_local4._x = (Stage.width / 2) - _root.projectile._x;
_local4._y = (Stage.height / 2) - _root.projectile._y;
var _local5 = Math.atan2(_local4._y, _local4._x);
vecShootDir._x = Math.cos(_local5) * 11;
vecShootDir._y = Math.sin(_local5) * 11;
var _local3 = 100;
do {
if (ProjectileOffScreen() != false) {
break;
}
_root.projectile._x = _root.projectile._x - vecShootDir._x;
_root.projectile._y = _root.projectile._y - vecShootDir._y;
_local3--;
} while (_local3 != 0);
var _local6 = (360 * _local5) / (Math.PI*2);
_root.projectile.gotoAndStop(2);
_root.projectile._rotation = _local6;
_root.gameBackground.gotoAndPlay("hide");
TurnOffAllArrows();
intState = 2;
}
}
function ProjectileOffScreen() {
var _local2 = false;
if (((_root.projectile._x + _root.projectile._width) < 0) || ((_root.projectile._x - _root.projectile._width) > Stage.width)) {
_local2 = true;
}
if (((_root.projectile._y + _root.projectile._height) < 0) || ((_root.projectile._y - _root.projectile._height) > Stage.height)) {
_local2 = true;
}
return(_local2);
}
function MoveProjectilesAndCollide() {
var _local4 = 0;
while (_local4 < arrProjectiles.length) {
_root[arrProjectiles[_local4].name]._x = _root[arrProjectiles[_local4].name]._x + (arrProjectiles[_local4].dX / 2);
_root[arrProjectiles[_local4].name]._y = _root[arrProjectiles[_local4].name]._y + (arrProjectiles[_local4].dY / 2);
if (((_root[arrProjectiles[_local4].name]._x + _root[arrProjectiles[_local4].name]._width) < 0) || ((_root[arrProjectiles[_local4].name]._x - _root[arrProjectiles[_local4].name]._width) > Stage.width)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
if (((_root[arrProjectiles[_local4].name]._y + _root[arrProjectiles[_local4].name]._height) < 0) || ((_root[arrProjectiles[_local4].name]._y - _root[arrProjectiles[_local4].name]._height) > Stage.height)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
_local4++;
}
var _local5 = new Array();
var _local3 = 0;
while (_local3 < arrProjectiles.length) {
_local4 = 0;
while (_local4 < arrParticles.length) {
if (_root[arrParticles[_local4]].hitTest(_root[arrProjectiles[_local3].name]._x, _root[arrProjectiles[_local3].name]._y, true) == true) {
_local5.push({name:arrParticles[_local4], X:arrProjectiles[_local3].X, Y:arrProjectiles[_local3].Y});
arrParticles.splice(_local4, 1);
_local4--;
_root[arrProjectiles[_local3].name].removeMovieClip();
arrProjectiles.splice(_local3, 1);
_local3--;
}
_local4++;
}
_local3++;
}
_local4 = 0;
while (_local4 < _local5.length) {
_root[_local5[_local4].name].Collision(_local5[_local4].X, _local5[_local4].Y);
_root[_local5[_local4].name].gotoAndStop(2);
_local4++;
}
_local4 = 0;
while (_local4 < arrProjectiles.length) {
_root[arrProjectiles[_local4].name]._x = _root[arrProjectiles[_local4].name]._x + (arrProjectiles[_local4].dX / 2);
_root[arrProjectiles[_local4].name]._y = _root[arrProjectiles[_local4].name]._y + (arrProjectiles[_local4].dY / 2);
if (((_root[arrProjectiles[_local4].name]._x + _root[arrProjectiles[_local4].name]._width) < 0) || ((_root[arrProjectiles[_local4].name]._x - _root[arrProjectiles[_local4].name]._width) > Stage.width)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
if (((_root[arrProjectiles[_local4].name]._y + _root[arrProjectiles[_local4].name]._height) < 0) || ((_root[arrProjectiles[_local4].name]._y - _root[arrProjectiles[_local4].name]._height) > Stage.height)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
_local4++;
}
_local5 = new Array();
_local3 = 0;
while (_local3 < arrProjectiles.length) {
_local4 = 0;
while (_local4 < arrParticles.length) {
if (_root[arrParticles[_local4]].hitTest(_root[arrProjectiles[_local3].name]._x, _root[arrProjectiles[_local3].name]._y, true) == true) {
_local5.push({name:arrParticles[_local4], X:arrProjectiles[_local3].X, Y:arrProjectiles[_local3].Y});
arrParticles.splice(_local4, 1);
_local4--;
_root[arrProjectiles[_local3].name].removeMovieClip();
arrProjectiles.splice(_local3, 1);
_local3--;
}
_local4++;
}
_local3++;
}
_local4 = 0;
while (_local4 < _local5.length) {
_root[_local5[_local4].name].Collision(_local5[_local4].X, _local5[_local4].Y);
_root[_local5[_local4].name].gotoAndStop(2);
_local4++;
}
if ((arrProjectiles.length == 0) && (projectileOver == true)) {
if (arrParticles.length != 0) {
intState = 3;
_root.messages_mc.gotoAndPlay("retry");
} else {
intState = 4;
var _local10 = ((_global.currentLevel + 5) - 15) / 5;
_global.levels[_local10] = 1;
var _local9 = SharedObject.getLocal("userData");
_local9.data.levelsCompleted = _global.levels;
_global.SoundManager.PlaySound("all");
_root.messages_mc.gotoAndPlay("next");
}
}
}
function LaunchProjectile(deltaX, deltaY, startX, startY, rot) {
var _local2 = "projectile_" + projectileDepth;
arrProjectiles.push({name:_local2, dX:deltaX, dY:deltaY, X:startX, Y:startY});
_root.attachMovie("shootingStar", _local2, projectileDepth);
_root[_local2]._x = startX;
_root[_local2]._y = startY;
_root[_local2]._rotation = rot;
projectileDepth++;
if (projectileDepth > 9999) {
projectileDepth = 5000;
}
}
stop();
var intState = 1;
var vecShootDir;
var arrParticles = new Array();
var arrProjectiles = new Array();
var arrParticlesReset = new Array();
var particleDepth = 1000;
var projectileDepth = 5000;
var arrowDepth = 15000;
var saveX = 0;
var saveY = 0;
var projectileOnScreen = false;
var projectileOver = false;
var saveDepth;
mouseListener = new Object();
mouseListener.onMouseDown = function () {
_root.Shoot();
};
Mouse.addListener(mouseListener);
Frame 170
function GameSetup() {
trace("%%%%%%%%");
trace((_global.currentLevel + " ----- ") + _global.latestLevel);
if (_global.latestLevel == -1) {
_root.gotoAndPlay("splash");
} else if ((_global.latestLevel != 0) && (_global.latestLevel != 20)) {
_global.currentLevel = _global.latestLevel;
_root.gotoAndPlay(_global.latestLevel);
_global.latestLevel = 0;
trace("go here");
} else if ((_global.latestLevel != 0) && (_global.latestLevel == 20)) {
_global.currentLevel = _global.latestLevel;
_global.latestLevel = 0;
}
if (_root.messages_mc.getDepth() != 50000) {
saveDepth = _root.messages_mc.getDepth();
}
vecShootDir = new Vector();
if (_global.musicOn == true) {
_global.myMusicPlayer.SetTrack("game");
_global.myMusicPlayer.SetMaxVolume(40);
_global.myMusicPlayer.PlayWithCrossFade(4);
}
}
function Mediator() {
_global.myMusicPlayer.RunPlayer();
switch (intState) {
case 1 :
AimProjectile();
if (_root.messages_mc.getDepth() != 50000) {
_root.messages_mc.swapDepths(50000);
trace(_root.messages_mc.getDepth());
}
break;
case 2 :
if (projectileOver == false) {
MoveProjectile();
}
DetectParticleCollisions();
MoveProjectilesAndCollide();
break;
case 3 :
if (Key.isDown(32)) {
Reset();
}
break;
case 4 :
if (!Key.isDown(32)) {
break;
}
Next();
}
}
function Reset() {
projectileDepth = 5000;
arrParticles = arrParticlesReset.slice();
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].gotoAndStop(1);
trace(arrParticles[_local2]);
_local2++;
}
trace("-----");
_root.projectile.gotoAndStop(1);
_root.gameBackground.gotoAndStop(1);
_root.messages_mc.gotoAndStop("hide");
projectileOver = false;
projectileOnScreen = false;
intState = 1;
}
function ExitGame() {
CleanupGame();
Mouse.removeListener(mouseListener);
_root.messages_mc.swapDepths(saveDepth);
_global.latestLevel = -1;
_root.gotoAndPlay("level1");
}
function Next() {
_global.currentLevel = _global.currentLevel + 5;
CleanupGame();
_root.messages_mc.swapDepths(saveDepth);
_root.gotoAndPlay(_global.currentLevel);
}
function CleanupGame() {
Mouse.removeListener(mouseListener);
Reset();
var _local3 = 10;
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].swapDepths(_local3);
_local3++;
_root[arrParticles[_local2]].removeMovieClip();
_local2++;
}
delete arrParticles;
arrParticles = new Array();
}
function DetectParticleCollisions() {
var _local3 = new Array();
var _local2 = 0;
while (_local2 < arrParticles.length) {
var _local4 = (_root[arrParticles[_local2]]._width / 2) + 7.5;
if (GetDistance(arrParticles[_local2], "projectile") <= _local4) {
_root[arrParticles[_local2]].Collision(saveX, saveY);
_local3.push(arrParticles[_local2]);
}
_local2++;
}
_local2 = 0;
while (_local2 < _local3.length) {
RemoveParticle(_local3[_local2]);
_root[_local3[_local2]].gotoAndStop(2);
_local2++;
}
}
function RemoveParticle(strName) {
var _local1 = 0;
while (_local1 < arrParticles.length) {
if (strName == arrParticles[_local1]) {
arrParticles.splice(_local1, 1);
break;
}
_local1++;
}
}
function GetDistance(targetA, targetB) {
var _local3 = _root[targetB]._x - _root[targetA]._x;
var _local2 = _root[targetB]._y - _root[targetA]._y;
return(Math.sqrt((_local3 * _local3) + (_local2 * _local2)));
}
function RegisterParticle(particleName) {
arrParticles.push(particleName);
arrParticlesReset.push(particleName);
particleDepth++;
return(particleDepth);
}
function MoveProjectile() {
if (ProjectileOffScreen() == false) {
projectileOnScreen = true;
_root.projectile._x = _root.projectile._x + vecShootDir._x;
_root.projectile._y = _root.projectile._y + vecShootDir._y;
} else if (projectileOnScreen == true) {
projectileOver = true;
} else {
_root.projectile._x = _root.projectile._x + vecShootDir._x;
_root.projectile._y = _root.projectile._y + vecShootDir._y;
}
}
function AimProjectile() {
var _local11 = new Vector();
_local11._x = _xmouse - (Stage.width / 2);
_local11._y = _ymouse - (Stage.height / 2);
var _local12 = Math.atan2(_local11._y, _local11._x);
var _local15 = (360 * _local12) / (Math.PI*2);
var _local6 = _root.gameBackground._width / 2;
_root.projectile._x = (_local6 * Math.cos(_local12)) + (Stage.width / 2);
_root.projectile._y = (_local6 * Math.sin(_local12)) + (Stage.height / 2);
_local11._x = (Stage.width / 2) - _root.projectile._x;
_local11._y = (Stage.height / 2) - _root.projectile._y;
_local12 = Math.atan2(_local11._y, _local11._x);
var _local14 = Math.cos(_local12) * 11;
var _local13 = Math.sin(_local12) * 11;
var _local9 = _root.projectile._x;
var _local10 = _root.projectile._y;
var _local5 = new Array(arrParticles.length);
var _local4 = 0;
while (_local4 < _local5.length) {
_local5[_local4] = 0;
_local4++;
}
var _local8 = 0;
while (_local8 < 70) {
_local9 = _local9 + _local14;
_local10 = _local10 + _local13;
_local4 = 0;
while (_local4 < arrParticles.length) {
var _local7 = (_root[arrParticles[_local4]]._width / 2) + 7.5;
var _local3 = _root[arrParticles[_local4]]._x - _local9;
var _local2 = _root[arrParticles[_local4]]._y - _local10;
_local6 = Math.sqrt((_local3 * _local3) + (_local2 * _local2));
if (_local6 <= _local7) {
_local5[_local4] = 1;
}
_local4++;
}
_local8++;
}
_local4 = 0;
while (_local4 < _local5.length) {
if (_local5[_local4] == 1) {
_root[arrParticles[_local4]].ArrowsOn(arrowDepth, _root.projectile._x, _root.projectile._y);
} else {
_root[arrParticles[_local4]].ArrowsOff();
}
_local4++;
}
}
function TurnOffAllArrows() {
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].ArrowsOff();
_local2++;
}
}
function NextArrowDepth() {
arrowDepth++;
if (arrowDepth > 39999) {
arrowDepth = 15000;
}
}
function DrawLines() {
_root.clear();
_root.lineStyle(2, 16777215, 50);
var _local2 = new Object();
var _local3 = new Object();
_local2.x = _root.projectile._x;
_local2.y = _root.projectile._y;
_local3.x = _xmouse;
_local3.y = _ymouse;
_root.moveTo(_local2.x, _local2.y);
_root.lineTo(_local3.x, _local3.y);
}
function Shoot() {
if ((intState == 1) && (_global.latestLevel != -1)) {
trace("in");
_root.clear();
saveX = _root.projectile._x;
saveY = _root.projectile._y;
var _local4 = new Vector();
_local4._x = (Stage.width / 2) - _root.projectile._x;
_local4._y = (Stage.height / 2) - _root.projectile._y;
var _local5 = Math.atan2(_local4._y, _local4._x);
vecShootDir._x = Math.cos(_local5) * 11;
vecShootDir._y = Math.sin(_local5) * 11;
var _local3 = 100;
do {
if (ProjectileOffScreen() != false) {
break;
}
_root.projectile._x = _root.projectile._x - vecShootDir._x;
_root.projectile._y = _root.projectile._y - vecShootDir._y;
_local3--;
} while (_local3 != 0);
var _local6 = (360 * _local5) / (Math.PI*2);
_root.projectile.gotoAndStop(2);
_root.projectile._rotation = _local6;
_root.gameBackground.gotoAndPlay("hide");
TurnOffAllArrows();
intState = 2;
}
}
function ProjectileOffScreen() {
var _local2 = false;
if (((_root.projectile._x + _root.projectile._width) < 0) || ((_root.projectile._x - _root.projectile._width) > Stage.width)) {
_local2 = true;
}
if (((_root.projectile._y + _root.projectile._height) < 0) || ((_root.projectile._y - _root.projectile._height) > Stage.height)) {
_local2 = true;
}
return(_local2);
}
function MoveProjectilesAndCollide() {
var _local4 = 0;
while (_local4 < arrProjectiles.length) {
_root[arrProjectiles[_local4].name]._x = _root[arrProjectiles[_local4].name]._x + (arrProjectiles[_local4].dX / 2);
_root[arrProjectiles[_local4].name]._y = _root[arrProjectiles[_local4].name]._y + (arrProjectiles[_local4].dY / 2);
if (((_root[arrProjectiles[_local4].name]._x + _root[arrProjectiles[_local4].name]._width) < 0) || ((_root[arrProjectiles[_local4].name]._x - _root[arrProjectiles[_local4].name]._width) > Stage.width)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
if (((_root[arrProjectiles[_local4].name]._y + _root[arrProjectiles[_local4].name]._height) < 0) || ((_root[arrProjectiles[_local4].name]._y - _root[arrProjectiles[_local4].name]._height) > Stage.height)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
_local4++;
}
var _local5 = new Array();
var _local3 = 0;
while (_local3 < arrProjectiles.length) {
_local4 = 0;
while (_local4 < arrParticles.length) {
if (_root[arrParticles[_local4]].hitTest(_root[arrProjectiles[_local3].name]._x, _root[arrProjectiles[_local3].name]._y, true) == true) {
_local5.push({name:arrParticles[_local4], X:arrProjectiles[_local3].X, Y:arrProjectiles[_local3].Y});
arrParticles.splice(_local4, 1);
_local4--;
_root[arrProjectiles[_local3].name].removeMovieClip();
arrProjectiles.splice(_local3, 1);
_local3--;
}
_local4++;
}
_local3++;
}
_local4 = 0;
while (_local4 < _local5.length) {
_root[_local5[_local4].name].Collision(_local5[_local4].X, _local5[_local4].Y);
_root[_local5[_local4].name].gotoAndStop(2);
_local4++;
}
_local4 = 0;
while (_local4 < arrProjectiles.length) {
_root[arrProjectiles[_local4].name]._x = _root[arrProjectiles[_local4].name]._x + (arrProjectiles[_local4].dX / 2);
_root[arrProjectiles[_local4].name]._y = _root[arrProjectiles[_local4].name]._y + (arrProjectiles[_local4].dY / 2);
if (((_root[arrProjectiles[_local4].name]._x + _root[arrProjectiles[_local4].name]._width) < 0) || ((_root[arrProjectiles[_local4].name]._x - _root[arrProjectiles[_local4].name]._width) > Stage.width)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
if (((_root[arrProjectiles[_local4].name]._y + _root[arrProjectiles[_local4].name]._height) < 0) || ((_root[arrProjectiles[_local4].name]._y - _root[arrProjectiles[_local4].name]._height) > Stage.height)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
_local4++;
}
_local5 = new Array();
_local3 = 0;
while (_local3 < arrProjectiles.length) {
_local4 = 0;
while (_local4 < arrParticles.length) {
if (_root[arrParticles[_local4]].hitTest(_root[arrProjectiles[_local3].name]._x, _root[arrProjectiles[_local3].name]._y, true) == true) {
_local5.push({name:arrParticles[_local4], X:arrProjectiles[_local3].X, Y:arrProjectiles[_local3].Y});
arrParticles.splice(_local4, 1);
_local4--;
_root[arrProjectiles[_local3].name].removeMovieClip();
arrProjectiles.splice(_local3, 1);
_local3--;
}
_local4++;
}
_local3++;
}
_local4 = 0;
while (_local4 < _local5.length) {
_root[_local5[_local4].name].Collision(_local5[_local4].X, _local5[_local4].Y);
_root[_local5[_local4].name].gotoAndStop(2);
_local4++;
}
if ((arrProjectiles.length == 0) && (projectileOver == true)) {
if (arrParticles.length != 0) {
intState = 3;
_root.messages_mc.gotoAndPlay("retry");
} else {
intState = 4;
var _local10 = ((_global.currentLevel + 5) - 15) / 5;
_global.levels[_local10] = 1;
var _local9 = SharedObject.getLocal("userData");
_local9.data.levelsCompleted = _global.levels;
_global.SoundManager.PlaySound("all");
_root.messages_mc.gotoAndPlay("next");
}
}
}
function LaunchProjectile(deltaX, deltaY, startX, startY, rot) {
var _local2 = "projectile_" + projectileDepth;
arrProjectiles.push({name:_local2, dX:deltaX, dY:deltaY, X:startX, Y:startY});
_root.attachMovie("shootingStar", _local2, projectileDepth);
_root[_local2]._x = startX;
_root[_local2]._y = startY;
_root[_local2]._rotation = rot;
projectileDepth++;
if (projectileDepth > 9999) {
projectileDepth = 5000;
}
}
stop();
var intState = 1;
var vecShootDir;
var arrParticles = new Array();
var arrProjectiles = new Array();
var arrParticlesReset = new Array();
var particleDepth = 1000;
var projectileDepth = 5000;
var arrowDepth = 15000;
var saveX = 0;
var saveY = 0;
var projectileOnScreen = false;
var projectileOver = false;
var saveDepth;
mouseListener = new Object();
mouseListener.onMouseDown = function () {
_root.Shoot();
};
Mouse.addListener(mouseListener);
Frame 175
function GameSetup() {
trace("%%%%%%%%");
trace((_global.currentLevel + " ----- ") + _global.latestLevel);
if (_global.latestLevel == -1) {
_root.gotoAndPlay("splash");
} else if ((_global.latestLevel != 0) && (_global.latestLevel != 20)) {
_global.currentLevel = _global.latestLevel;
_root.gotoAndPlay(_global.latestLevel);
_global.latestLevel = 0;
trace("go here");
} else if ((_global.latestLevel != 0) && (_global.latestLevel == 20)) {
_global.currentLevel = _global.latestLevel;
_global.latestLevel = 0;
}
if (_root.messages_mc.getDepth() != 50000) {
saveDepth = _root.messages_mc.getDepth();
}
vecShootDir = new Vector();
if (_global.musicOn == true) {
_global.myMusicPlayer.SetTrack("game");
_global.myMusicPlayer.SetMaxVolume(40);
_global.myMusicPlayer.PlayWithCrossFade(4);
}
}
function Mediator() {
_global.myMusicPlayer.RunPlayer();
switch (intState) {
case 1 :
AimProjectile();
if (_root.messages_mc.getDepth() != 50000) {
_root.messages_mc.swapDepths(50000);
trace(_root.messages_mc.getDepth());
}
break;
case 2 :
if (projectileOver == false) {
MoveProjectile();
}
DetectParticleCollisions();
MoveProjectilesAndCollide();
break;
case 3 :
if (Key.isDown(32)) {
Reset();
}
break;
case 4 :
if (!Key.isDown(32)) {
break;
}
Next();
}
}
function Reset() {
projectileDepth = 5000;
arrParticles = arrParticlesReset.slice();
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].gotoAndStop(1);
trace(arrParticles[_local2]);
_local2++;
}
trace("-----");
_root.projectile.gotoAndStop(1);
_root.gameBackground.gotoAndStop(1);
_root.messages_mc.gotoAndStop("hide");
projectileOver = false;
projectileOnScreen = false;
intState = 1;
}
function ExitGame() {
CleanupGame();
Mouse.removeListener(mouseListener);
_root.messages_mc.swapDepths(saveDepth);
_global.latestLevel = -1;
_root.gotoAndPlay("level1");
}
function Next() {
_global.currentLevel = _global.currentLevel + 5;
CleanupGame();
_root.messages_mc.swapDepths(saveDepth);
_root.gotoAndPlay(_global.currentLevel);
}
function CleanupGame() {
Mouse.removeListener(mouseListener);
Reset();
var _local3 = 10;
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].swapDepths(_local3);
_local3++;
_root[arrParticles[_local2]].removeMovieClip();
_local2++;
}
delete arrParticles;
arrParticles = new Array();
}
function DetectParticleCollisions() {
var _local3 = new Array();
var _local2 = 0;
while (_local2 < arrParticles.length) {
var _local4 = (_root[arrParticles[_local2]]._width / 2) + 7.5;
if (GetDistance(arrParticles[_local2], "projectile") <= _local4) {
_root[arrParticles[_local2]].Collision(saveX, saveY);
_local3.push(arrParticles[_local2]);
}
_local2++;
}
_local2 = 0;
while (_local2 < _local3.length) {
RemoveParticle(_local3[_local2]);
_root[_local3[_local2]].gotoAndStop(2);
_local2++;
}
}
function RemoveParticle(strName) {
var _local1 = 0;
while (_local1 < arrParticles.length) {
if (strName == arrParticles[_local1]) {
arrParticles.splice(_local1, 1);
break;
}
_local1++;
}
}
function GetDistance(targetA, targetB) {
var _local3 = _root[targetB]._x - _root[targetA]._x;
var _local2 = _root[targetB]._y - _root[targetA]._y;
return(Math.sqrt((_local3 * _local3) + (_local2 * _local2)));
}
function RegisterParticle(particleName) {
arrParticles.push(particleName);
arrParticlesReset.push(particleName);
particleDepth++;
return(particleDepth);
}
function MoveProjectile() {
if (ProjectileOffScreen() == false) {
projectileOnScreen = true;
_root.projectile._x = _root.projectile._x + vecShootDir._x;
_root.projectile._y = _root.projectile._y + vecShootDir._y;
} else if (projectileOnScreen == true) {
projectileOver = true;
} else {
_root.projectile._x = _root.projectile._x + vecShootDir._x;
_root.projectile._y = _root.projectile._y + vecShootDir._y;
}
}
function AimProjectile() {
var _local11 = new Vector();
_local11._x = _xmouse - (Stage.width / 2);
_local11._y = _ymouse - (Stage.height / 2);
var _local12 = Math.atan2(_local11._y, _local11._x);
var _local15 = (360 * _local12) / (Math.PI*2);
var _local6 = _root.gameBackground._width / 2;
_root.projectile._x = (_local6 * Math.cos(_local12)) + (Stage.width / 2);
_root.projectile._y = (_local6 * Math.sin(_local12)) + (Stage.height / 2);
_local11._x = (Stage.width / 2) - _root.projectile._x;
_local11._y = (Stage.height / 2) - _root.projectile._y;
_local12 = Math.atan2(_local11._y, _local11._x);
var _local14 = Math.cos(_local12) * 11;
var _local13 = Math.sin(_local12) * 11;
var _local9 = _root.projectile._x;
var _local10 = _root.projectile._y;
var _local5 = new Array(arrParticles.length);
var _local4 = 0;
while (_local4 < _local5.length) {
_local5[_local4] = 0;
_local4++;
}
var _local8 = 0;
while (_local8 < 70) {
_local9 = _local9 + _local14;
_local10 = _local10 + _local13;
_local4 = 0;
while (_local4 < arrParticles.length) {
var _local7 = (_root[arrParticles[_local4]]._width / 2) + 7.5;
var _local3 = _root[arrParticles[_local4]]._x - _local9;
var _local2 = _root[arrParticles[_local4]]._y - _local10;
_local6 = Math.sqrt((_local3 * _local3) + (_local2 * _local2));
if (_local6 <= _local7) {
_local5[_local4] = 1;
}
_local4++;
}
_local8++;
}
_local4 = 0;
while (_local4 < _local5.length) {
if (_local5[_local4] == 1) {
_root[arrParticles[_local4]].ArrowsOn(arrowDepth, _root.projectile._x, _root.projectile._y);
} else {
_root[arrParticles[_local4]].ArrowsOff();
}
_local4++;
}
}
function TurnOffAllArrows() {
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].ArrowsOff();
_local2++;
}
}
function NextArrowDepth() {
arrowDepth++;
if (arrowDepth > 39999) {
arrowDepth = 15000;
}
}
function DrawLines() {
_root.clear();
_root.lineStyle(2, 16777215, 50);
var _local2 = new Object();
var _local3 = new Object();
_local2.x = _root.projectile._x;
_local2.y = _root.projectile._y;
_local3.x = _xmouse;
_local3.y = _ymouse;
_root.moveTo(_local2.x, _local2.y);
_root.lineTo(_local3.x, _local3.y);
}
function Shoot() {
if ((intState == 1) && (_global.latestLevel != -1)) {
trace("in");
_root.clear();
saveX = _root.projectile._x;
saveY = _root.projectile._y;
var _local4 = new Vector();
_local4._x = (Stage.width / 2) - _root.projectile._x;
_local4._y = (Stage.height / 2) - _root.projectile._y;
var _local5 = Math.atan2(_local4._y, _local4._x);
vecShootDir._x = Math.cos(_local5) * 11;
vecShootDir._y = Math.sin(_local5) * 11;
var _local3 = 100;
do {
if (ProjectileOffScreen() != false) {
break;
}
_root.projectile._x = _root.projectile._x - vecShootDir._x;
_root.projectile._y = _root.projectile._y - vecShootDir._y;
_local3--;
} while (_local3 != 0);
var _local6 = (360 * _local5) / (Math.PI*2);
_root.projectile.gotoAndStop(2);
_root.projectile._rotation = _local6;
_root.gameBackground.gotoAndPlay("hide");
TurnOffAllArrows();
intState = 2;
}
}
function ProjectileOffScreen() {
var _local2 = false;
if (((_root.projectile._x + _root.projectile._width) < 0) || ((_root.projectile._x - _root.projectile._width) > Stage.width)) {
_local2 = true;
}
if (((_root.projectile._y + _root.projectile._height) < 0) || ((_root.projectile._y - _root.projectile._height) > Stage.height)) {
_local2 = true;
}
return(_local2);
}
function MoveProjectilesAndCollide() {
var _local4 = 0;
while (_local4 < arrProjectiles.length) {
_root[arrProjectiles[_local4].name]._x = _root[arrProjectiles[_local4].name]._x + (arrProjectiles[_local4].dX / 2);
_root[arrProjectiles[_local4].name]._y = _root[arrProjectiles[_local4].name]._y + (arrProjectiles[_local4].dY / 2);
if (((_root[arrProjectiles[_local4].name]._x + _root[arrProjectiles[_local4].name]._width) < 0) || ((_root[arrProjectiles[_local4].name]._x - _root[arrProjectiles[_local4].name]._width) > Stage.width)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
if (((_root[arrProjectiles[_local4].name]._y + _root[arrProjectiles[_local4].name]._height) < 0) || ((_root[arrProjectiles[_local4].name]._y - _root[arrProjectiles[_local4].name]._height) > Stage.height)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
_local4++;
}
var _local5 = new Array();
var _local3 = 0;
while (_local3 < arrProjectiles.length) {
_local4 = 0;
while (_local4 < arrParticles.length) {
if (_root[arrParticles[_local4]].hitTest(_root[arrProjectiles[_local3].name]._x, _root[arrProjectiles[_local3].name]._y, true) == true) {
_local5.push({name:arrParticles[_local4], X:arrProjectiles[_local3].X, Y:arrProjectiles[_local3].Y});
arrParticles.splice(_local4, 1);
_local4--;
_root[arrProjectiles[_local3].name].removeMovieClip();
arrProjectiles.splice(_local3, 1);
_local3--;
}
_local4++;
}
_local3++;
}
_local4 = 0;
while (_local4 < _local5.length) {
_root[_local5[_local4].name].Collision(_local5[_local4].X, _local5[_local4].Y);
_root[_local5[_local4].name].gotoAndStop(2);
_local4++;
}
_local4 = 0;
while (_local4 < arrProjectiles.length) {
_root[arrProjectiles[_local4].name]._x = _root[arrProjectiles[_local4].name]._x + (arrProjectiles[_local4].dX / 2);
_root[arrProjectiles[_local4].name]._y = _root[arrProjectiles[_local4].name]._y + (arrProjectiles[_local4].dY / 2);
if (((_root[arrProjectiles[_local4].name]._x + _root[arrProjectiles[_local4].name]._width) < 0) || ((_root[arrProjectiles[_local4].name]._x - _root[arrProjectiles[_local4].name]._width) > Stage.width)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
if (((_root[arrProjectiles[_local4].name]._y + _root[arrProjectiles[_local4].name]._height) < 0) || ((_root[arrProjectiles[_local4].name]._y - _root[arrProjectiles[_local4].name]._height) > Stage.height)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
_local4++;
}
_local5 = new Array();
_local3 = 0;
while (_local3 < arrProjectiles.length) {
_local4 = 0;
while (_local4 < arrParticles.length) {
if (_root[arrParticles[_local4]].hitTest(_root[arrProjectiles[_local3].name]._x, _root[arrProjectiles[_local3].name]._y, true) == true) {
_local5.push({name:arrParticles[_local4], X:arrProjectiles[_local3].X, Y:arrProjectiles[_local3].Y});
arrParticles.splice(_local4, 1);
_local4--;
_root[arrProjectiles[_local3].name].removeMovieClip();
arrProjectiles.splice(_local3, 1);
_local3--;
}
_local4++;
}
_local3++;
}
_local4 = 0;
while (_local4 < _local5.length) {
_root[_local5[_local4].name].Collision(_local5[_local4].X, _local5[_local4].Y);
_root[_local5[_local4].name].gotoAndStop(2);
_local4++;
}
if ((arrProjectiles.length == 0) && (projectileOver == true)) {
if (arrParticles.length != 0) {
intState = 3;
_root.messages_mc.gotoAndPlay("retry");
} else {
intState = 4;
var _local10 = ((_global.currentLevel + 5) - 15) / 5;
_global.levels[_local10] = 1;
var _local9 = SharedObject.getLocal("userData");
_local9.data.levelsCompleted = _global.levels;
_global.SoundManager.PlaySound("all");
_root.messages_mc.gotoAndPlay("next");
}
}
}
function LaunchProjectile(deltaX, deltaY, startX, startY, rot) {
var _local2 = "projectile_" + projectileDepth;
arrProjectiles.push({name:_local2, dX:deltaX, dY:deltaY, X:startX, Y:startY});
_root.attachMovie("shootingStar", _local2, projectileDepth);
_root[_local2]._x = startX;
_root[_local2]._y = startY;
_root[_local2]._rotation = rot;
projectileDepth++;
if (projectileDepth > 9999) {
projectileDepth = 5000;
}
}
stop();
var intState = 1;
var vecShootDir;
var arrParticles = new Array();
var arrProjectiles = new Array();
var arrParticlesReset = new Array();
var particleDepth = 1000;
var projectileDepth = 5000;
var arrowDepth = 15000;
var saveX = 0;
var saveY = 0;
var projectileOnScreen = false;
var projectileOver = false;
var saveDepth;
mouseListener = new Object();
mouseListener.onMouseDown = function () {
_root.Shoot();
};
Mouse.addListener(mouseListener);
Frame 180
function GameSetup() {
trace("%%%%%%%%");
trace((_global.currentLevel + " ----- ") + _global.latestLevel);
if (_global.latestLevel == -1) {
_root.gotoAndPlay("splash");
} else if ((_global.latestLevel != 0) && (_global.latestLevel != 20)) {
_global.currentLevel = _global.latestLevel;
_root.gotoAndPlay(_global.latestLevel);
_global.latestLevel = 0;
trace("go here");
} else if ((_global.latestLevel != 0) && (_global.latestLevel == 20)) {
_global.currentLevel = _global.latestLevel;
_global.latestLevel = 0;
}
if (_root.messages_mc.getDepth() != 50000) {
saveDepth = _root.messages_mc.getDepth();
}
vecShootDir = new Vector();
if (_global.musicOn == true) {
_global.myMusicPlayer.SetTrack("game");
_global.myMusicPlayer.SetMaxVolume(40);
_global.myMusicPlayer.PlayWithCrossFade(4);
}
}
function Mediator() {
_global.myMusicPlayer.RunPlayer();
switch (intState) {
case 1 :
AimProjectile();
if (_root.messages_mc.getDepth() != 50000) {
_root.messages_mc.swapDepths(50000);
trace(_root.messages_mc.getDepth());
}
break;
case 2 :
if (projectileOver == false) {
MoveProjectile();
}
DetectParticleCollisions();
MoveProjectilesAndCollide();
break;
case 3 :
if (Key.isDown(32)) {
Reset();
}
break;
case 4 :
if (!Key.isDown(32)) {
break;
}
Next();
}
}
function Reset() {
projectileDepth = 5000;
arrParticles = arrParticlesReset.slice();
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].gotoAndStop(1);
trace(arrParticles[_local2]);
_local2++;
}
trace("-----");
_root.projectile.gotoAndStop(1);
_root.gameBackground.gotoAndStop(1);
_root.messages_mc.gotoAndStop("hide");
projectileOver = false;
projectileOnScreen = false;
intState = 1;
}
function ExitGame() {
CleanupGame();
Mouse.removeListener(mouseListener);
_root.messages_mc.swapDepths(saveDepth);
_global.latestLevel = -1;
_root.gotoAndPlay("level1");
}
function Next() {
_global.currentLevel = _global.currentLevel + 5;
CleanupGame();
_root.messages_mc.swapDepths(saveDepth);
_root.gotoAndPlay(_global.currentLevel);
}
function CleanupGame() {
Mouse.removeListener(mouseListener);
Reset();
var _local3 = 10;
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].swapDepths(_local3);
_local3++;
_root[arrParticles[_local2]].removeMovieClip();
_local2++;
}
delete arrParticles;
arrParticles = new Array();
}
function DetectParticleCollisions() {
var _local3 = new Array();
var _local2 = 0;
while (_local2 < arrParticles.length) {
var _local4 = (_root[arrParticles[_local2]]._width / 2) + 7.5;
if (GetDistance(arrParticles[_local2], "projectile") <= _local4) {
_root[arrParticles[_local2]].Collision(saveX, saveY);
_local3.push(arrParticles[_local2]);
}
_local2++;
}
_local2 = 0;
while (_local2 < _local3.length) {
RemoveParticle(_local3[_local2]);
_root[_local3[_local2]].gotoAndStop(2);
_local2++;
}
}
function RemoveParticle(strName) {
var _local1 = 0;
while (_local1 < arrParticles.length) {
if (strName == arrParticles[_local1]) {
arrParticles.splice(_local1, 1);
break;
}
_local1++;
}
}
function GetDistance(targetA, targetB) {
var _local3 = _root[targetB]._x - _root[targetA]._x;
var _local2 = _root[targetB]._y - _root[targetA]._y;
return(Math.sqrt((_local3 * _local3) + (_local2 * _local2)));
}
function RegisterParticle(particleName) {
arrParticles.push(particleName);
arrParticlesReset.push(particleName);
particleDepth++;
return(particleDepth);
}
function MoveProjectile() {
if (ProjectileOffScreen() == false) {
projectileOnScreen = true;
_root.projectile._x = _root.projectile._x + vecShootDir._x;
_root.projectile._y = _root.projectile._y + vecShootDir._y;
} else if (projectileOnScreen == true) {
projectileOver = true;
} else {
_root.projectile._x = _root.projectile._x + vecShootDir._x;
_root.projectile._y = _root.projectile._y + vecShootDir._y;
}
}
function AimProjectile() {
var _local11 = new Vector();
_local11._x = _xmouse - (Stage.width / 2);
_local11._y = _ymouse - (Stage.height / 2);
var _local12 = Math.atan2(_local11._y, _local11._x);
var _local15 = (360 * _local12) / (Math.PI*2);
var _local6 = _root.gameBackground._width / 2;
_root.projectile._x = (_local6 * Math.cos(_local12)) + (Stage.width / 2);
_root.projectile._y = (_local6 * Math.sin(_local12)) + (Stage.height / 2);
_local11._x = (Stage.width / 2) - _root.projectile._x;
_local11._y = (Stage.height / 2) - _root.projectile._y;
_local12 = Math.atan2(_local11._y, _local11._x);
var _local14 = Math.cos(_local12) * 11;
var _local13 = Math.sin(_local12) * 11;
var _local9 = _root.projectile._x;
var _local10 = _root.projectile._y;
var _local5 = new Array(arrParticles.length);
var _local4 = 0;
while (_local4 < _local5.length) {
_local5[_local4] = 0;
_local4++;
}
var _local8 = 0;
while (_local8 < 70) {
_local9 = _local9 + _local14;
_local10 = _local10 + _local13;
_local4 = 0;
while (_local4 < arrParticles.length) {
var _local7 = (_root[arrParticles[_local4]]._width / 2) + 7.5;
var _local3 = _root[arrParticles[_local4]]._x - _local9;
var _local2 = _root[arrParticles[_local4]]._y - _local10;
_local6 = Math.sqrt((_local3 * _local3) + (_local2 * _local2));
if (_local6 <= _local7) {
_local5[_local4] = 1;
}
_local4++;
}
_local8++;
}
_local4 = 0;
while (_local4 < _local5.length) {
if (_local5[_local4] == 1) {
_root[arrParticles[_local4]].ArrowsOn(arrowDepth, _root.projectile._x, _root.projectile._y);
} else {
_root[arrParticles[_local4]].ArrowsOff();
}
_local4++;
}
}
function TurnOffAllArrows() {
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].ArrowsOff();
_local2++;
}
}
function NextArrowDepth() {
arrowDepth++;
if (arrowDepth > 39999) {
arrowDepth = 15000;
}
}
function DrawLines() {
_root.clear();
_root.lineStyle(2, 16777215, 50);
var _local2 = new Object();
var _local3 = new Object();
_local2.x = _root.projectile._x;
_local2.y = _root.projectile._y;
_local3.x = _xmouse;
_local3.y = _ymouse;
_root.moveTo(_local2.x, _local2.y);
_root.lineTo(_local3.x, _local3.y);
}
function Shoot() {
if ((intState == 1) && (_global.latestLevel != -1)) {
trace("in");
_root.clear();
saveX = _root.projectile._x;
saveY = _root.projectile._y;
var _local4 = new Vector();
_local4._x = (Stage.width / 2) - _root.projectile._x;
_local4._y = (Stage.height / 2) - _root.projectile._y;
var _local5 = Math.atan2(_local4._y, _local4._x);
vecShootDir._x = Math.cos(_local5) * 11;
vecShootDir._y = Math.sin(_local5) * 11;
var _local3 = 100;
do {
if (ProjectileOffScreen() != false) {
break;
}
_root.projectile._x = _root.projectile._x - vecShootDir._x;
_root.projectile._y = _root.projectile._y - vecShootDir._y;
_local3--;
} while (_local3 != 0);
var _local6 = (360 * _local5) / (Math.PI*2);
_root.projectile.gotoAndStop(2);
_root.projectile._rotation = _local6;
_root.gameBackground.gotoAndPlay("hide");
TurnOffAllArrows();
intState = 2;
}
}
function ProjectileOffScreen() {
var _local2 = false;
if (((_root.projectile._x + _root.projectile._width) < 0) || ((_root.projectile._x - _root.projectile._width) > Stage.width)) {
_local2 = true;
}
if (((_root.projectile._y + _root.projectile._height) < 0) || ((_root.projectile._y - _root.projectile._height) > Stage.height)) {
_local2 = true;
}
return(_local2);
}
function MoveProjectilesAndCollide() {
var _local4 = 0;
while (_local4 < arrProjectiles.length) {
_root[arrProjectiles[_local4].name]._x = _root[arrProjectiles[_local4].name]._x + (arrProjectiles[_local4].dX / 2);
_root[arrProjectiles[_local4].name]._y = _root[arrProjectiles[_local4].name]._y + (arrProjectiles[_local4].dY / 2);
if (((_root[arrProjectiles[_local4].name]._x + _root[arrProjectiles[_local4].name]._width) < 0) || ((_root[arrProjectiles[_local4].name]._x - _root[arrProjectiles[_local4].name]._width) > Stage.width)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
if (((_root[arrProjectiles[_local4].name]._y + _root[arrProjectiles[_local4].name]._height) < 0) || ((_root[arrProjectiles[_local4].name]._y - _root[arrProjectiles[_local4].name]._height) > Stage.height)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
_local4++;
}
var _local5 = new Array();
var _local3 = 0;
while (_local3 < arrProjectiles.length) {
_local4 = 0;
while (_local4 < arrParticles.length) {
if (_root[arrParticles[_local4]].hitTest(_root[arrProjectiles[_local3].name]._x, _root[arrProjectiles[_local3].name]._y, true) == true) {
_local5.push({name:arrParticles[_local4], X:arrProjectiles[_local3].X, Y:arrProjectiles[_local3].Y});
arrParticles.splice(_local4, 1);
_local4--;
_root[arrProjectiles[_local3].name].removeMovieClip();
arrProjectiles.splice(_local3, 1);
_local3--;
}
_local4++;
}
_local3++;
}
_local4 = 0;
while (_local4 < _local5.length) {
_root[_local5[_local4].name].Collision(_local5[_local4].X, _local5[_local4].Y);
_root[_local5[_local4].name].gotoAndStop(2);
_local4++;
}
_local4 = 0;
while (_local4 < arrProjectiles.length) {
_root[arrProjectiles[_local4].name]._x = _root[arrProjectiles[_local4].name]._x + (arrProjectiles[_local4].dX / 2);
_root[arrProjectiles[_local4].name]._y = _root[arrProjectiles[_local4].name]._y + (arrProjectiles[_local4].dY / 2);
if (((_root[arrProjectiles[_local4].name]._x + _root[arrProjectiles[_local4].name]._width) < 0) || ((_root[arrProjectiles[_local4].name]._x - _root[arrProjectiles[_local4].name]._width) > Stage.width)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
if (((_root[arrProjectiles[_local4].name]._y + _root[arrProjectiles[_local4].name]._height) < 0) || ((_root[arrProjectiles[_local4].name]._y - _root[arrProjectiles[_local4].name]._height) > Stage.height)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
_local4++;
}
_local5 = new Array();
_local3 = 0;
while (_local3 < arrProjectiles.length) {
_local4 = 0;
while (_local4 < arrParticles.length) {
if (_root[arrParticles[_local4]].hitTest(_root[arrProjectiles[_local3].name]._x, _root[arrProjectiles[_local3].name]._y, true) == true) {
_local5.push({name:arrParticles[_local4], X:arrProjectiles[_local3].X, Y:arrProjectiles[_local3].Y});
arrParticles.splice(_local4, 1);
_local4--;
_root[arrProjectiles[_local3].name].removeMovieClip();
arrProjectiles.splice(_local3, 1);
_local3--;
}
_local4++;
}
_local3++;
}
_local4 = 0;
while (_local4 < _local5.length) {
_root[_local5[_local4].name].Collision(_local5[_local4].X, _local5[_local4].Y);
_root[_local5[_local4].name].gotoAndStop(2);
_local4++;
}
if ((arrProjectiles.length == 0) && (projectileOver == true)) {
if (arrParticles.length != 0) {
intState = 3;
_root.messages_mc.gotoAndPlay("retry");
} else {
intState = 4;
var _local10 = ((_global.currentLevel + 5) - 15) / 5;
_global.levels[_local10] = 1;
var _local9 = SharedObject.getLocal("userData");
_local9.data.levelsCompleted = _global.levels;
_global.SoundManager.PlaySound("all");
_root.messages_mc.gotoAndPlay("next");
}
}
}
function LaunchProjectile(deltaX, deltaY, startX, startY, rot) {
var _local2 = "projectile_" + projectileDepth;
arrProjectiles.push({name:_local2, dX:deltaX, dY:deltaY, X:startX, Y:startY});
_root.attachMovie("shootingStar", _local2, projectileDepth);
_root[_local2]._x = startX;
_root[_local2]._y = startY;
_root[_local2]._rotation = rot;
projectileDepth++;
if (projectileDepth > 9999) {
projectileDepth = 5000;
}
}
stop();
var intState = 1;
var vecShootDir;
var arrParticles = new Array();
var arrProjectiles = new Array();
var arrParticlesReset = new Array();
var particleDepth = 1000;
var projectileDepth = 5000;
var arrowDepth = 15000;
var saveX = 0;
var saveY = 0;
var projectileOnScreen = false;
var projectileOver = false;
var saveDepth;
mouseListener = new Object();
mouseListener.onMouseDown = function () {
_root.Shoot();
};
Mouse.addListener(mouseListener);
Frame 185
function GameSetup() {
trace("%%%%%%%%");
trace((_global.currentLevel + " ----- ") + _global.latestLevel);
if (_global.latestLevel == -1) {
_root.gotoAndPlay("splash");
} else if ((_global.latestLevel != 0) && (_global.latestLevel != 20)) {
_global.currentLevel = _global.latestLevel;
_root.gotoAndPlay(_global.latestLevel);
_global.latestLevel = 0;
trace("go here");
} else if ((_global.latestLevel != 0) && (_global.latestLevel == 20)) {
_global.currentLevel = _global.latestLevel;
_global.latestLevel = 0;
}
if (_root.messages_mc.getDepth() != 50000) {
saveDepth = _root.messages_mc.getDepth();
}
vecShootDir = new Vector();
if (_global.musicOn == true) {
_global.myMusicPlayer.SetTrack("game");
_global.myMusicPlayer.SetMaxVolume(40);
_global.myMusicPlayer.PlayWithCrossFade(4);
}
}
function Mediator() {
_global.myMusicPlayer.RunPlayer();
switch (intState) {
case 1 :
AimProjectile();
if (_root.messages_mc.getDepth() != 50000) {
_root.messages_mc.swapDepths(50000);
trace(_root.messages_mc.getDepth());
}
break;
case 2 :
if (projectileOver == false) {
MoveProjectile();
}
DetectParticleCollisions();
MoveProjectilesAndCollide();
break;
case 3 :
if (Key.isDown(32)) {
Reset();
}
break;
case 4 :
if (!Key.isDown(32)) {
break;
}
Next();
}
}
function Reset() {
projectileDepth = 5000;
arrParticles = arrParticlesReset.slice();
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].gotoAndStop(1);
trace(arrParticles[_local2]);
_local2++;
}
trace("-----");
_root.projectile.gotoAndStop(1);
_root.gameBackground.gotoAndStop(1);
_root.messages_mc.gotoAndStop("hide");
projectileOver = false;
projectileOnScreen = false;
intState = 1;
}
function ExitGame() {
CleanupGame();
Mouse.removeListener(mouseListener);
_root.messages_mc.swapDepths(saveDepth);
_global.latestLevel = -1;
_root.gotoAndPlay("level1");
}
function Next() {
_global.currentLevel = _global.currentLevel + 5;
CleanupGame();
_root.messages_mc.swapDepths(saveDepth);
_root.gotoAndPlay(_global.currentLevel);
}
function CleanupGame() {
Mouse.removeListener(mouseListener);
Reset();
var _local3 = 10;
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].swapDepths(_local3);
_local3++;
_root[arrParticles[_local2]].removeMovieClip();
_local2++;
}
delete arrParticles;
arrParticles = new Array();
}
function DetectParticleCollisions() {
var _local3 = new Array();
var _local2 = 0;
while (_local2 < arrParticles.length) {
var _local4 = (_root[arrParticles[_local2]]._width / 2) + 7.5;
if (GetDistance(arrParticles[_local2], "projectile") <= _local4) {
_root[arrParticles[_local2]].Collision(saveX, saveY);
_local3.push(arrParticles[_local2]);
}
_local2++;
}
_local2 = 0;
while (_local2 < _local3.length) {
RemoveParticle(_local3[_local2]);
_root[_local3[_local2]].gotoAndStop(2);
_local2++;
}
}
function RemoveParticle(strName) {
var _local1 = 0;
while (_local1 < arrParticles.length) {
if (strName == arrParticles[_local1]) {
arrParticles.splice(_local1, 1);
break;
}
_local1++;
}
}
function GetDistance(targetA, targetB) {
var _local3 = _root[targetB]._x - _root[targetA]._x;
var _local2 = _root[targetB]._y - _root[targetA]._y;
return(Math.sqrt((_local3 * _local3) + (_local2 * _local2)));
}
function RegisterParticle(particleName) {
arrParticles.push(particleName);
arrParticlesReset.push(particleName);
particleDepth++;
return(particleDepth);
}
function MoveProjectile() {
if (ProjectileOffScreen() == false) {
projectileOnScreen = true;
_root.projectile._x = _root.projectile._x + vecShootDir._x;
_root.projectile._y = _root.projectile._y + vecShootDir._y;
} else if (projectileOnScreen == true) {
projectileOver = true;
} else {
_root.projectile._x = _root.projectile._x + vecShootDir._x;
_root.projectile._y = _root.projectile._y + vecShootDir._y;
}
}
function AimProjectile() {
var _local11 = new Vector();
_local11._x = _xmouse - (Stage.width / 2);
_local11._y = _ymouse - (Stage.height / 2);
var _local12 = Math.atan2(_local11._y, _local11._x);
var _local15 = (360 * _local12) / (Math.PI*2);
var _local6 = _root.gameBackground._width / 2;
_root.projectile._x = (_local6 * Math.cos(_local12)) + (Stage.width / 2);
_root.projectile._y = (_local6 * Math.sin(_local12)) + (Stage.height / 2);
_local11._x = (Stage.width / 2) - _root.projectile._x;
_local11._y = (Stage.height / 2) - _root.projectile._y;
_local12 = Math.atan2(_local11._y, _local11._x);
var _local14 = Math.cos(_local12) * 11;
var _local13 = Math.sin(_local12) * 11;
var _local9 = _root.projectile._x;
var _local10 = _root.projectile._y;
var _local5 = new Array(arrParticles.length);
var _local4 = 0;
while (_local4 < _local5.length) {
_local5[_local4] = 0;
_local4++;
}
var _local8 = 0;
while (_local8 < 70) {
_local9 = _local9 + _local14;
_local10 = _local10 + _local13;
_local4 = 0;
while (_local4 < arrParticles.length) {
var _local7 = (_root[arrParticles[_local4]]._width / 2) + 7.5;
var _local3 = _root[arrParticles[_local4]]._x - _local9;
var _local2 = _root[arrParticles[_local4]]._y - _local10;
_local6 = Math.sqrt((_local3 * _local3) + (_local2 * _local2));
if (_local6 <= _local7) {
_local5[_local4] = 1;
}
_local4++;
}
_local8++;
}
_local4 = 0;
while (_local4 < _local5.length) {
if (_local5[_local4] == 1) {
_root[arrParticles[_local4]].ArrowsOn(arrowDepth, _root.projectile._x, _root.projectile._y);
} else {
_root[arrParticles[_local4]].ArrowsOff();
}
_local4++;
}
}
function TurnOffAllArrows() {
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].ArrowsOff();
_local2++;
}
}
function NextArrowDepth() {
arrowDepth++;
if (arrowDepth > 39999) {
arrowDepth = 15000;
}
}
function DrawLines() {
_root.clear();
_root.lineStyle(2, 16777215, 50);
var _local2 = new Object();
var _local3 = new Object();
_local2.x = _root.projectile._x;
_local2.y = _root.projectile._y;
_local3.x = _xmouse;
_local3.y = _ymouse;
_root.moveTo(_local2.x, _local2.y);
_root.lineTo(_local3.x, _local3.y);
}
function Shoot() {
if ((intState == 1) && (_global.latestLevel != -1)) {
trace("in");
_root.clear();
saveX = _root.projectile._x;
saveY = _root.projectile._y;
var _local4 = new Vector();
_local4._x = (Stage.width / 2) - _root.projectile._x;
_local4._y = (Stage.height / 2) - _root.projectile._y;
var _local5 = Math.atan2(_local4._y, _local4._x);
vecShootDir._x = Math.cos(_local5) * 11;
vecShootDir._y = Math.sin(_local5) * 11;
var _local3 = 100;
do {
if (ProjectileOffScreen() != false) {
break;
}
_root.projectile._x = _root.projectile._x - vecShootDir._x;
_root.projectile._y = _root.projectile._y - vecShootDir._y;
_local3--;
} while (_local3 != 0);
var _local6 = (360 * _local5) / (Math.PI*2);
_root.projectile.gotoAndStop(2);
_root.projectile._rotation = _local6;
_root.gameBackground.gotoAndPlay("hide");
TurnOffAllArrows();
intState = 2;
}
}
function ProjectileOffScreen() {
var _local2 = false;
if (((_root.projectile._x + _root.projectile._width) < 0) || ((_root.projectile._x - _root.projectile._width) > Stage.width)) {
_local2 = true;
}
if (((_root.projectile._y + _root.projectile._height) < 0) || ((_root.projectile._y - _root.projectile._height) > Stage.height)) {
_local2 = true;
}
return(_local2);
}
function MoveProjectilesAndCollide() {
var _local4 = 0;
while (_local4 < arrProjectiles.length) {
_root[arrProjectiles[_local4].name]._x = _root[arrProjectiles[_local4].name]._x + (arrProjectiles[_local4].dX / 2);
_root[arrProjectiles[_local4].name]._y = _root[arrProjectiles[_local4].name]._y + (arrProjectiles[_local4].dY / 2);
if (((_root[arrProjectiles[_local4].name]._x + _root[arrProjectiles[_local4].name]._width) < 0) || ((_root[arrProjectiles[_local4].name]._x - _root[arrProjectiles[_local4].name]._width) > Stage.width)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
if (((_root[arrProjectiles[_local4].name]._y + _root[arrProjectiles[_local4].name]._height) < 0) || ((_root[arrProjectiles[_local4].name]._y - _root[arrProjectiles[_local4].name]._height) > Stage.height)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
_local4++;
}
var _local5 = new Array();
var _local3 = 0;
while (_local3 < arrProjectiles.length) {
_local4 = 0;
while (_local4 < arrParticles.length) {
if (_root[arrParticles[_local4]].hitTest(_root[arrProjectiles[_local3].name]._x, _root[arrProjectiles[_local3].name]._y, true) == true) {
_local5.push({name:arrParticles[_local4], X:arrProjectiles[_local3].X, Y:arrProjectiles[_local3].Y});
arrParticles.splice(_local4, 1);
_local4--;
_root[arrProjectiles[_local3].name].removeMovieClip();
arrProjectiles.splice(_local3, 1);
_local3--;
}
_local4++;
}
_local3++;
}
_local4 = 0;
while (_local4 < _local5.length) {
_root[_local5[_local4].name].Collision(_local5[_local4].X, _local5[_local4].Y);
_root[_local5[_local4].name].gotoAndStop(2);
_local4++;
}
_local4 = 0;
while (_local4 < arrProjectiles.length) {
_root[arrProjectiles[_local4].name]._x = _root[arrProjectiles[_local4].name]._x + (arrProjectiles[_local4].dX / 2);
_root[arrProjectiles[_local4].name]._y = _root[arrProjectiles[_local4].name]._y + (arrProjectiles[_local4].dY / 2);
if (((_root[arrProjectiles[_local4].name]._x + _root[arrProjectiles[_local4].name]._width) < 0) || ((_root[arrProjectiles[_local4].name]._x - _root[arrProjectiles[_local4].name]._width) > Stage.width)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
if (((_root[arrProjectiles[_local4].name]._y + _root[arrProjectiles[_local4].name]._height) < 0) || ((_root[arrProjectiles[_local4].name]._y - _root[arrProjectiles[_local4].name]._height) > Stage.height)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
_local4++;
}
_local5 = new Array();
_local3 = 0;
while (_local3 < arrProjectiles.length) {
_local4 = 0;
while (_local4 < arrParticles.length) {
if (_root[arrParticles[_local4]].hitTest(_root[arrProjectiles[_local3].name]._x, _root[arrProjectiles[_local3].name]._y, true) == true) {
_local5.push({name:arrParticles[_local4], X:arrProjectiles[_local3].X, Y:arrProjectiles[_local3].Y});
arrParticles.splice(_local4, 1);
_local4--;
_root[arrProjectiles[_local3].name].removeMovieClip();
arrProjectiles.splice(_local3, 1);
_local3--;
}
_local4++;
}
_local3++;
}
_local4 = 0;
while (_local4 < _local5.length) {
_root[_local5[_local4].name].Collision(_local5[_local4].X, _local5[_local4].Y);
_root[_local5[_local4].name].gotoAndStop(2);
_local4++;
}
if ((arrProjectiles.length == 0) && (projectileOver == true)) {
if (arrParticles.length != 0) {
intState = 3;
_root.messages_mc.gotoAndPlay("retry");
} else {
intState = 4;
var _local10 = ((_global.currentLevel + 5) - 15) / 5;
_global.levels[_local10] = 1;
var _local9 = SharedObject.getLocal("userData");
_local9.data.levelsCompleted = _global.levels;
_global.SoundManager.PlaySound("all");
_root.messages_mc.gotoAndPlay("next");
}
}
}
function LaunchProjectile(deltaX, deltaY, startX, startY, rot) {
var _local2 = "projectile_" + projectileDepth;
arrProjectiles.push({name:_local2, dX:deltaX, dY:deltaY, X:startX, Y:startY});
_root.attachMovie("shootingStar", _local2, projectileDepth);
_root[_local2]._x = startX;
_root[_local2]._y = startY;
_root[_local2]._rotation = rot;
projectileDepth++;
if (projectileDepth > 9999) {
projectileDepth = 5000;
}
}
stop();
var intState = 1;
var vecShootDir;
var arrParticles = new Array();
var arrProjectiles = new Array();
var arrParticlesReset = new Array();
var particleDepth = 1000;
var projectileDepth = 5000;
var arrowDepth = 15000;
var saveX = 0;
var saveY = 0;
var projectileOnScreen = false;
var projectileOver = false;
var saveDepth;
mouseListener = new Object();
mouseListener.onMouseDown = function () {
_root.Shoot();
};
Mouse.addListener(mouseListener);
Frame 190
function GameSetup() {
trace("%%%%%%%%");
trace((_global.currentLevel + " ----- ") + _global.latestLevel);
if (_global.latestLevel == -1) {
_root.gotoAndPlay("splash");
} else if ((_global.latestLevel != 0) && (_global.latestLevel != 20)) {
_global.currentLevel = _global.latestLevel;
_root.gotoAndPlay(_global.latestLevel);
_global.latestLevel = 0;
trace("go here");
} else if ((_global.latestLevel != 0) && (_global.latestLevel == 20)) {
_global.currentLevel = _global.latestLevel;
_global.latestLevel = 0;
}
if (_root.messages_mc.getDepth() != 50000) {
saveDepth = _root.messages_mc.getDepth();
}
vecShootDir = new Vector();
if (_global.musicOn == true) {
_global.myMusicPlayer.SetTrack("game");
_global.myMusicPlayer.SetMaxVolume(40);
_global.myMusicPlayer.PlayWithCrossFade(4);
}
}
function Mediator() {
_global.myMusicPlayer.RunPlayer();
switch (intState) {
case 1 :
AimProjectile();
if (_root.messages_mc.getDepth() != 50000) {
_root.messages_mc.swapDepths(50000);
trace(_root.messages_mc.getDepth());
}
break;
case 2 :
if (projectileOver == false) {
MoveProjectile();
}
DetectParticleCollisions();
MoveProjectilesAndCollide();
break;
case 3 :
if (Key.isDown(32)) {
Reset();
}
break;
case 4 :
if (!Key.isDown(32)) {
break;
}
Next();
}
}
function Reset() {
projectileDepth = 5000;
arrParticles = arrParticlesReset.slice();
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].gotoAndStop(1);
trace(arrParticles[_local2]);
_local2++;
}
trace("-----");
_root.projectile.gotoAndStop(1);
_root.gameBackground.gotoAndStop(1);
_root.messages_mc.gotoAndStop("hide");
projectileOver = false;
projectileOnScreen = false;
intState = 1;
}
function ExitGame() {
CleanupGame();
Mouse.removeListener(mouseListener);
_root.messages_mc.swapDepths(saveDepth);
_global.latestLevel = -1;
_root.gotoAndPlay("level1");
}
function Next() {
_global.currentLevel = _global.currentLevel + 5;
CleanupGame();
_root.messages_mc.swapDepths(saveDepth);
_root.gotoAndPlay(_global.currentLevel);
}
function CleanupGame() {
Mouse.removeListener(mouseListener);
Reset();
var _local3 = 10;
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].swapDepths(_local3);
_local3++;
_root[arrParticles[_local2]].removeMovieClip();
_local2++;
}
delete arrParticles;
arrParticles = new Array();
}
function DetectParticleCollisions() {
var _local3 = new Array();
var _local2 = 0;
while (_local2 < arrParticles.length) {
var _local4 = (_root[arrParticles[_local2]]._width / 2) + 7.5;
if (GetDistance(arrParticles[_local2], "projectile") <= _local4) {
_root[arrParticles[_local2]].Collision(saveX, saveY);
_local3.push(arrParticles[_local2]);
}
_local2++;
}
_local2 = 0;
while (_local2 < _local3.length) {
RemoveParticle(_local3[_local2]);
_root[_local3[_local2]].gotoAndStop(2);
_local2++;
}
}
function RemoveParticle(strName) {
var _local1 = 0;
while (_local1 < arrParticles.length) {
if (strName == arrParticles[_local1]) {
arrParticles.splice(_local1, 1);
break;
}
_local1++;
}
}
function GetDistance(targetA, targetB) {
var _local3 = _root[targetB]._x - _root[targetA]._x;
var _local2 = _root[targetB]._y - _root[targetA]._y;
return(Math.sqrt((_local3 * _local3) + (_local2 * _local2)));
}
function RegisterParticle(particleName) {
arrParticles.push(particleName);
arrParticlesReset.push(particleName);
particleDepth++;
return(particleDepth);
}
function MoveProjectile() {
if (ProjectileOffScreen() == false) {
projectileOnScreen = true;
_root.projectile._x = _root.projectile._x + vecShootDir._x;
_root.projectile._y = _root.projectile._y + vecShootDir._y;
} else if (projectileOnScreen == true) {
projectileOver = true;
} else {
_root.projectile._x = _root.projectile._x + vecShootDir._x;
_root.projectile._y = _root.projectile._y + vecShootDir._y;
}
}
function AimProjectile() {
var _local11 = new Vector();
_local11._x = _xmouse - (Stage.width / 2);
_local11._y = _ymouse - (Stage.height / 2);
var _local12 = Math.atan2(_local11._y, _local11._x);
var _local15 = (360 * _local12) / (Math.PI*2);
var _local6 = _root.gameBackground._width / 2;
_root.projectile._x = (_local6 * Math.cos(_local12)) + (Stage.width / 2);
_root.projectile._y = (_local6 * Math.sin(_local12)) + (Stage.height / 2);
_local11._x = (Stage.width / 2) - _root.projectile._x;
_local11._y = (Stage.height / 2) - _root.projectile._y;
_local12 = Math.atan2(_local11._y, _local11._x);
var _local14 = Math.cos(_local12) * 11;
var _local13 = Math.sin(_local12) * 11;
var _local9 = _root.projectile._x;
var _local10 = _root.projectile._y;
var _local5 = new Array(arrParticles.length);
var _local4 = 0;
while (_local4 < _local5.length) {
_local5[_local4] = 0;
_local4++;
}
var _local8 = 0;
while (_local8 < 70) {
_local9 = _local9 + _local14;
_local10 = _local10 + _local13;
_local4 = 0;
while (_local4 < arrParticles.length) {
var _local7 = (_root[arrParticles[_local4]]._width / 2) + 7.5;
var _local3 = _root[arrParticles[_local4]]._x - _local9;
var _local2 = _root[arrParticles[_local4]]._y - _local10;
_local6 = Math.sqrt((_local3 * _local3) + (_local2 * _local2));
if (_local6 <= _local7) {
_local5[_local4] = 1;
}
_local4++;
}
_local8++;
}
_local4 = 0;
while (_local4 < _local5.length) {
if (_local5[_local4] == 1) {
_root[arrParticles[_local4]].ArrowsOn(arrowDepth, _root.projectile._x, _root.projectile._y);
} else {
_root[arrParticles[_local4]].ArrowsOff();
}
_local4++;
}
}
function TurnOffAllArrows() {
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].ArrowsOff();
_local2++;
}
}
function NextArrowDepth() {
arrowDepth++;
if (arrowDepth > 39999) {
arrowDepth = 15000;
}
}
function DrawLines() {
_root.clear();
_root.lineStyle(2, 16777215, 50);
var _local2 = new Object();
var _local3 = new Object();
_local2.x = _root.projectile._x;
_local2.y = _root.projectile._y;
_local3.x = _xmouse;
_local3.y = _ymouse;
_root.moveTo(_local2.x, _local2.y);
_root.lineTo(_local3.x, _local3.y);
}
function Shoot() {
if ((intState == 1) && (_global.latestLevel != -1)) {
trace("in");
_root.clear();
saveX = _root.projectile._x;
saveY = _root.projectile._y;
var _local4 = new Vector();
_local4._x = (Stage.width / 2) - _root.projectile._x;
_local4._y = (Stage.height / 2) - _root.projectile._y;
var _local5 = Math.atan2(_local4._y, _local4._x);
vecShootDir._x = Math.cos(_local5) * 11;
vecShootDir._y = Math.sin(_local5) * 11;
var _local3 = 100;
do {
if (ProjectileOffScreen() != false) {
break;
}
_root.projectile._x = _root.projectile._x - vecShootDir._x;
_root.projectile._y = _root.projectile._y - vecShootDir._y;
_local3--;
} while (_local3 != 0);
var _local6 = (360 * _local5) / (Math.PI*2);
_root.projectile.gotoAndStop(2);
_root.projectile._rotation = _local6;
_root.gameBackground.gotoAndPlay("hide");
TurnOffAllArrows();
intState = 2;
}
}
function ProjectileOffScreen() {
var _local2 = false;
if (((_root.projectile._x + _root.projectile._width) < 0) || ((_root.projectile._x - _root.projectile._width) > Stage.width)) {
_local2 = true;
}
if (((_root.projectile._y + _root.projectile._height) < 0) || ((_root.projectile._y - _root.projectile._height) > Stage.height)) {
_local2 = true;
}
return(_local2);
}
function MoveProjectilesAndCollide() {
var _local4 = 0;
while (_local4 < arrProjectiles.length) {
_root[arrProjectiles[_local4].name]._x = _root[arrProjectiles[_local4].name]._x + (arrProjectiles[_local4].dX / 2);
_root[arrProjectiles[_local4].name]._y = _root[arrProjectiles[_local4].name]._y + (arrProjectiles[_local4].dY / 2);
if (((_root[arrProjectiles[_local4].name]._x + _root[arrProjectiles[_local4].name]._width) < 0) || ((_root[arrProjectiles[_local4].name]._x - _root[arrProjectiles[_local4].name]._width) > Stage.width)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
if (((_root[arrProjectiles[_local4].name]._y + _root[arrProjectiles[_local4].name]._height) < 0) || ((_root[arrProjectiles[_local4].name]._y - _root[arrProjectiles[_local4].name]._height) > Stage.height)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
_local4++;
}
var _local5 = new Array();
var _local3 = 0;
while (_local3 < arrProjectiles.length) {
_local4 = 0;
while (_local4 < arrParticles.length) {
if (_root[arrParticles[_local4]].hitTest(_root[arrProjectiles[_local3].name]._x, _root[arrProjectiles[_local3].name]._y, true) == true) {
_local5.push({name:arrParticles[_local4], X:arrProjectiles[_local3].X, Y:arrProjectiles[_local3].Y});
arrParticles.splice(_local4, 1);
_local4--;
_root[arrProjectiles[_local3].name].removeMovieClip();
arrProjectiles.splice(_local3, 1);
_local3--;
}
_local4++;
}
_local3++;
}
_local4 = 0;
while (_local4 < _local5.length) {
_root[_local5[_local4].name].Collision(_local5[_local4].X, _local5[_local4].Y);
_root[_local5[_local4].name].gotoAndStop(2);
_local4++;
}
_local4 = 0;
while (_local4 < arrProjectiles.length) {
_root[arrProjectiles[_local4].name]._x = _root[arrProjectiles[_local4].name]._x + (arrProjectiles[_local4].dX / 2);
_root[arrProjectiles[_local4].name]._y = _root[arrProjectiles[_local4].name]._y + (arrProjectiles[_local4].dY / 2);
if (((_root[arrProjectiles[_local4].name]._x + _root[arrProjectiles[_local4].name]._width) < 0) || ((_root[arrProjectiles[_local4].name]._x - _root[arrProjectiles[_local4].name]._width) > Stage.width)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
if (((_root[arrProjectiles[_local4].name]._y + _root[arrProjectiles[_local4].name]._height) < 0) || ((_root[arrProjectiles[_local4].name]._y - _root[arrProjectiles[_local4].name]._height) > Stage.height)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
_local4++;
}
_local5 = new Array();
_local3 = 0;
while (_local3 < arrProjectiles.length) {
_local4 = 0;
while (_local4 < arrParticles.length) {
if (_root[arrParticles[_local4]].hitTest(_root[arrProjectiles[_local3].name]._x, _root[arrProjectiles[_local3].name]._y, true) == true) {
_local5.push({name:arrParticles[_local4], X:arrProjectiles[_local3].X, Y:arrProjectiles[_local3].Y});
arrParticles.splice(_local4, 1);
_local4--;
_root[arrProjectiles[_local3].name].removeMovieClip();
arrProjectiles.splice(_local3, 1);
_local3--;
}
_local4++;
}
_local3++;
}
_local4 = 0;
while (_local4 < _local5.length) {
_root[_local5[_local4].name].Collision(_local5[_local4].X, _local5[_local4].Y);
_root[_local5[_local4].name].gotoAndStop(2);
_local4++;
}
if ((arrProjectiles.length == 0) && (projectileOver == true)) {
if (arrParticles.length != 0) {
intState = 3;
_root.messages_mc.gotoAndPlay("retry");
} else {
intState = 4;
var _local10 = ((_global.currentLevel + 5) - 15) / 5;
_global.levels[_local10] = 1;
var _local9 = SharedObject.getLocal("userData");
_local9.data.levelsCompleted = _global.levels;
_global.SoundManager.PlaySound("all");
_root.messages_mc.gotoAndPlay("next");
}
}
}
function LaunchProjectile(deltaX, deltaY, startX, startY, rot) {
var _local2 = "projectile_" + projectileDepth;
arrProjectiles.push({name:_local2, dX:deltaX, dY:deltaY, X:startX, Y:startY});
_root.attachMovie("shootingStar", _local2, projectileDepth);
_root[_local2]._x = startX;
_root[_local2]._y = startY;
_root[_local2]._rotation = rot;
projectileDepth++;
if (projectileDepth > 9999) {
projectileDepth = 5000;
}
}
stop();
var intState = 1;
var vecShootDir;
var arrParticles = new Array();
var arrProjectiles = new Array();
var arrParticlesReset = new Array();
var particleDepth = 1000;
var projectileDepth = 5000;
var arrowDepth = 15000;
var saveX = 0;
var saveY = 0;
var projectileOnScreen = false;
var projectileOver = false;
var saveDepth;
mouseListener = new Object();
mouseListener.onMouseDown = function () {
_root.Shoot();
};
Mouse.addListener(mouseListener);
Frame 195
function GameSetup() {
trace("%%%%%%%%");
trace((_global.currentLevel + " ----- ") + _global.latestLevel);
if (_global.latestLevel == -1) {
_root.gotoAndPlay("splash");
} else if ((_global.latestLevel != 0) && (_global.latestLevel != 20)) {
_global.currentLevel = _global.latestLevel;
_root.gotoAndPlay(_global.latestLevel);
_global.latestLevel = 0;
trace("go here");
} else if ((_global.latestLevel != 0) && (_global.latestLevel == 20)) {
_global.currentLevel = _global.latestLevel;
_global.latestLevel = 0;
}
if (_root.messages_mc.getDepth() != 50000) {
saveDepth = _root.messages_mc.getDepth();
}
vecShootDir = new Vector();
if (_global.musicOn == true) {
_global.myMusicPlayer.SetTrack("game");
_global.myMusicPlayer.SetMaxVolume(40);
_global.myMusicPlayer.PlayWithCrossFade(4);
}
}
function Mediator() {
_global.myMusicPlayer.RunPlayer();
switch (intState) {
case 1 :
AimProjectile();
if (_root.messages_mc.getDepth() != 50000) {
_root.messages_mc.swapDepths(50000);
trace(_root.messages_mc.getDepth());
}
break;
case 2 :
if (projectileOver == false) {
MoveProjectile();
}
DetectParticleCollisions();
MoveProjectilesAndCollide();
break;
case 3 :
if (Key.isDown(32)) {
Reset();
}
break;
case 4 :
if (!Key.isDown(32)) {
break;
}
Next();
}
}
function Reset() {
projectileDepth = 5000;
arrParticles = arrParticlesReset.slice();
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].gotoAndStop(1);
trace(arrParticles[_local2]);
_local2++;
}
trace("-----");
_root.projectile.gotoAndStop(1);
_root.gameBackground.gotoAndStop(1);
_root.messages_mc.gotoAndStop("hide");
projectileOver = false;
projectileOnScreen = false;
intState = 1;
}
function ExitGame() {
CleanupGame();
Mouse.removeListener(mouseListener);
_root.messages_mc.swapDepths(saveDepth);
_global.latestLevel = -1;
_root.gotoAndPlay("level1");
}
function Next() {
_global.currentLevel = _global.currentLevel + 5;
CleanupGame();
_root.messages_mc.swapDepths(saveDepth);
_root.gotoAndPlay(_global.currentLevel);
}
function CleanupGame() {
Mouse.removeListener(mouseListener);
Reset();
var _local3 = 10;
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].swapDepths(_local3);
_local3++;
_root[arrParticles[_local2]].removeMovieClip();
_local2++;
}
delete arrParticles;
arrParticles = new Array();
}
function DetectParticleCollisions() {
var _local3 = new Array();
var _local2 = 0;
while (_local2 < arrParticles.length) {
var _local4 = (_root[arrParticles[_local2]]._width / 2) + 7.5;
if (GetDistance(arrParticles[_local2], "projectile") <= _local4) {
_root[arrParticles[_local2]].Collision(saveX, saveY);
_local3.push(arrParticles[_local2]);
}
_local2++;
}
_local2 = 0;
while (_local2 < _local3.length) {
RemoveParticle(_local3[_local2]);
_root[_local3[_local2]].gotoAndStop(2);
_local2++;
}
}
function RemoveParticle(strName) {
var _local1 = 0;
while (_local1 < arrParticles.length) {
if (strName == arrParticles[_local1]) {
arrParticles.splice(_local1, 1);
break;
}
_local1++;
}
}
function GetDistance(targetA, targetB) {
var _local3 = _root[targetB]._x - _root[targetA]._x;
var _local2 = _root[targetB]._y - _root[targetA]._y;
return(Math.sqrt((_local3 * _local3) + (_local2 * _local2)));
}
function RegisterParticle(particleName) {
arrParticles.push(particleName);
arrParticlesReset.push(particleName);
particleDepth++;
return(particleDepth);
}
function MoveProjectile() {
if (ProjectileOffScreen() == false) {
projectileOnScreen = true;
_root.projectile._x = _root.projectile._x + vecShootDir._x;
_root.projectile._y = _root.projectile._y + vecShootDir._y;
} else if (projectileOnScreen == true) {
projectileOver = true;
} else {
_root.projectile._x = _root.projectile._x + vecShootDir._x;
_root.projectile._y = _root.projectile._y + vecShootDir._y;
}
}
function AimProjectile() {
var _local11 = new Vector();
_local11._x = _xmouse - (Stage.width / 2);
_local11._y = _ymouse - (Stage.height / 2);
var _local12 = Math.atan2(_local11._y, _local11._x);
var _local15 = (360 * _local12) / (Math.PI*2);
var _local6 = _root.gameBackground._width / 2;
_root.projectile._x = (_local6 * Math.cos(_local12)) + (Stage.width / 2);
_root.projectile._y = (_local6 * Math.sin(_local12)) + (Stage.height / 2);
_local11._x = (Stage.width / 2) - _root.projectile._x;
_local11._y = (Stage.height / 2) - _root.projectile._y;
_local12 = Math.atan2(_local11._y, _local11._x);
var _local14 = Math.cos(_local12) * 11;
var _local13 = Math.sin(_local12) * 11;
var _local9 = _root.projectile._x;
var _local10 = _root.projectile._y;
var _local5 = new Array(arrParticles.length);
var _local4 = 0;
while (_local4 < _local5.length) {
_local5[_local4] = 0;
_local4++;
}
var _local8 = 0;
while (_local8 < 70) {
_local9 = _local9 + _local14;
_local10 = _local10 + _local13;
_local4 = 0;
while (_local4 < arrParticles.length) {
var _local7 = (_root[arrParticles[_local4]]._width / 2) + 7.5;
var _local3 = _root[arrParticles[_local4]]._x - _local9;
var _local2 = _root[arrParticles[_local4]]._y - _local10;
_local6 = Math.sqrt((_local3 * _local3) + (_local2 * _local2));
if (_local6 <= _local7) {
_local5[_local4] = 1;
}
_local4++;
}
_local8++;
}
_local4 = 0;
while (_local4 < _local5.length) {
if (_local5[_local4] == 1) {
_root[arrParticles[_local4]].ArrowsOn(arrowDepth, _root.projectile._x, _root.projectile._y);
} else {
_root[arrParticles[_local4]].ArrowsOff();
}
_local4++;
}
}
function TurnOffAllArrows() {
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].ArrowsOff();
_local2++;
}
}
function NextArrowDepth() {
arrowDepth++;
if (arrowDepth > 39999) {
arrowDepth = 15000;
}
}
function DrawLines() {
_root.clear();
_root.lineStyle(2, 16777215, 50);
var _local2 = new Object();
var _local3 = new Object();
_local2.x = _root.projectile._x;
_local2.y = _root.projectile._y;
_local3.x = _xmouse;
_local3.y = _ymouse;
_root.moveTo(_local2.x, _local2.y);
_root.lineTo(_local3.x, _local3.y);
}
function Shoot() {
if ((intState == 1) && (_global.latestLevel != -1)) {
trace("in");
_root.clear();
saveX = _root.projectile._x;
saveY = _root.projectile._y;
var _local4 = new Vector();
_local4._x = (Stage.width / 2) - _root.projectile._x;
_local4._y = (Stage.height / 2) - _root.projectile._y;
var _local5 = Math.atan2(_local4._y, _local4._x);
vecShootDir._x = Math.cos(_local5) * 11;
vecShootDir._y = Math.sin(_local5) * 11;
var _local3 = 100;
do {
if (ProjectileOffScreen() != false) {
break;
}
_root.projectile._x = _root.projectile._x - vecShootDir._x;
_root.projectile._y = _root.projectile._y - vecShootDir._y;
_local3--;
} while (_local3 != 0);
var _local6 = (360 * _local5) / (Math.PI*2);
_root.projectile.gotoAndStop(2);
_root.projectile._rotation = _local6;
_root.gameBackground.gotoAndPlay("hide");
TurnOffAllArrows();
intState = 2;
}
}
function ProjectileOffScreen() {
var _local2 = false;
if (((_root.projectile._x + _root.projectile._width) < 0) || ((_root.projectile._x - _root.projectile._width) > Stage.width)) {
_local2 = true;
}
if (((_root.projectile._y + _root.projectile._height) < 0) || ((_root.projectile._y - _root.projectile._height) > Stage.height)) {
_local2 = true;
}
return(_local2);
}
function MoveProjectilesAndCollide() {
var _local4 = 0;
while (_local4 < arrProjectiles.length) {
_root[arrProjectiles[_local4].name]._x = _root[arrProjectiles[_local4].name]._x + (arrProjectiles[_local4].dX / 2);
_root[arrProjectiles[_local4].name]._y = _root[arrProjectiles[_local4].name]._y + (arrProjectiles[_local4].dY / 2);
if (((_root[arrProjectiles[_local4].name]._x + _root[arrProjectiles[_local4].name]._width) < 0) || ((_root[arrProjectiles[_local4].name]._x - _root[arrProjectiles[_local4].name]._width) > Stage.width)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
if (((_root[arrProjectiles[_local4].name]._y + _root[arrProjectiles[_local4].name]._height) < 0) || ((_root[arrProjectiles[_local4].name]._y - _root[arrProjectiles[_local4].name]._height) > Stage.height)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
_local4++;
}
var _local5 = new Array();
var _local3 = 0;
while (_local3 < arrProjectiles.length) {
_local4 = 0;
while (_local4 < arrParticles.length) {
if (_root[arrParticles[_local4]].hitTest(_root[arrProjectiles[_local3].name]._x, _root[arrProjectiles[_local3].name]._y, true) == true) {
_local5.push({name:arrParticles[_local4], X:arrProjectiles[_local3].X, Y:arrProjectiles[_local3].Y});
arrParticles.splice(_local4, 1);
_local4--;
_root[arrProjectiles[_local3].name].removeMovieClip();
arrProjectiles.splice(_local3, 1);
_local3--;
}
_local4++;
}
_local3++;
}
_local4 = 0;
while (_local4 < _local5.length) {
_root[_local5[_local4].name].Collision(_local5[_local4].X, _local5[_local4].Y);
_root[_local5[_local4].name].gotoAndStop(2);
_local4++;
}
_local4 = 0;
while (_local4 < arrProjectiles.length) {
_root[arrProjectiles[_local4].name]._x = _root[arrProjectiles[_local4].name]._x + (arrProjectiles[_local4].dX / 2);
_root[arrProjectiles[_local4].name]._y = _root[arrProjectiles[_local4].name]._y + (arrProjectiles[_local4].dY / 2);
if (((_root[arrProjectiles[_local4].name]._x + _root[arrProjectiles[_local4].name]._width) < 0) || ((_root[arrProjectiles[_local4].name]._x - _root[arrProjectiles[_local4].name]._width) > Stage.width)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
if (((_root[arrProjectiles[_local4].name]._y + _root[arrProjectiles[_local4].name]._height) < 0) || ((_root[arrProjectiles[_local4].name]._y - _root[arrProjectiles[_local4].name]._height) > Stage.height)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
_local4++;
}
_local5 = new Array();
_local3 = 0;
while (_local3 < arrProjectiles.length) {
_local4 = 0;
while (_local4 < arrParticles.length) {
if (_root[arrParticles[_local4]].hitTest(_root[arrProjectiles[_local3].name]._x, _root[arrProjectiles[_local3].name]._y, true) == true) {
_local5.push({name:arrParticles[_local4], X:arrProjectiles[_local3].X, Y:arrProjectiles[_local3].Y});
arrParticles.splice(_local4, 1);
_local4--;
_root[arrProjectiles[_local3].name].removeMovieClip();
arrProjectiles.splice(_local3, 1);
_local3--;
}
_local4++;
}
_local3++;
}
_local4 = 0;
while (_local4 < _local5.length) {
_root[_local5[_local4].name].Collision(_local5[_local4].X, _local5[_local4].Y);
_root[_local5[_local4].name].gotoAndStop(2);
_local4++;
}
if ((arrProjectiles.length == 0) && (projectileOver == true)) {
if (arrParticles.length != 0) {
intState = 3;
_root.messages_mc.gotoAndPlay("retry");
} else {
intState = 4;
var _local10 = ((_global.currentLevel + 5) - 15) / 5;
_global.levels[_local10] = 1;
var _local9 = SharedObject.getLocal("userData");
_local9.data.levelsCompleted = _global.levels;
_global.SoundManager.PlaySound("all");
_root.messages_mc.gotoAndPlay("next");
}
}
}
function LaunchProjectile(deltaX, deltaY, startX, startY, rot) {
var _local2 = "projectile_" + projectileDepth;
arrProjectiles.push({name:_local2, dX:deltaX, dY:deltaY, X:startX, Y:startY});
_root.attachMovie("shootingStar", _local2, projectileDepth);
_root[_local2]._x = startX;
_root[_local2]._y = startY;
_root[_local2]._rotation = rot;
projectileDepth++;
if (projectileDepth > 9999) {
projectileDepth = 5000;
}
}
stop();
var intState = 1;
var vecShootDir;
var arrParticles = new Array();
var arrProjectiles = new Array();
var arrParticlesReset = new Array();
var particleDepth = 1000;
var projectileDepth = 5000;
var arrowDepth = 15000;
var saveX = 0;
var saveY = 0;
var projectileOnScreen = false;
var projectileOver = false;
var saveDepth;
mouseListener = new Object();
mouseListener.onMouseDown = function () {
_root.Shoot();
};
Mouse.addListener(mouseListener);
Frame 200
function GameSetup() {
trace("%%%%%%%%");
trace((_global.currentLevel + " ----- ") + _global.latestLevel);
if (_global.latestLevel == -1) {
_root.gotoAndPlay("splash");
} else if ((_global.latestLevel != 0) && (_global.latestLevel != 20)) {
_global.currentLevel = _global.latestLevel;
_root.gotoAndPlay(_global.latestLevel);
_global.latestLevel = 0;
trace("go here");
} else if ((_global.latestLevel != 0) && (_global.latestLevel == 20)) {
_global.currentLevel = _global.latestLevel;
_global.latestLevel = 0;
}
if (_root.messages_mc.getDepth() != 50000) {
saveDepth = _root.messages_mc.getDepth();
}
vecShootDir = new Vector();
if (_global.musicOn == true) {
_global.myMusicPlayer.SetTrack("game");
_global.myMusicPlayer.SetMaxVolume(40);
_global.myMusicPlayer.PlayWithCrossFade(4);
}
}
function Mediator() {
_global.myMusicPlayer.RunPlayer();
switch (intState) {
case 1 :
AimProjectile();
if (_root.messages_mc.getDepth() != 50000) {
_root.messages_mc.swapDepths(50000);
trace(_root.messages_mc.getDepth());
}
break;
case 2 :
if (projectileOver == false) {
MoveProjectile();
}
DetectParticleCollisions();
MoveProjectilesAndCollide();
break;
case 3 :
if (Key.isDown(32)) {
Reset();
}
break;
case 4 :
if (!Key.isDown(32)) {
break;
}
Next();
}
}
function Reset() {
projectileDepth = 5000;
arrParticles = arrParticlesReset.slice();
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].gotoAndStop(1);
trace(arrParticles[_local2]);
_local2++;
}
trace("-----");
_root.projectile.gotoAndStop(1);
_root.gameBackground.gotoAndStop(1);
_root.messages_mc.gotoAndStop("hide");
projectileOver = false;
projectileOnScreen = false;
intState = 1;
}
function ExitGame() {
CleanupGame();
Mouse.removeListener(mouseListener);
_root.messages_mc.swapDepths(saveDepth);
_global.latestLevel = -1;
_root.gotoAndPlay("level1");
}
function Next() {
_global.currentLevel = _global.currentLevel + 5;
CleanupGame();
_root.messages_mc.swapDepths(saveDepth);
_root.gotoAndPlay(_global.currentLevel);
}
function CleanupGame() {
Mouse.removeListener(mouseListener);
Reset();
var _local3 = 10;
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].swapDepths(_local3);
_local3++;
_root[arrParticles[_local2]].removeMovieClip();
_local2++;
}
delete arrParticles;
arrParticles = new Array();
}
function DetectParticleCollisions() {
var _local3 = new Array();
var _local2 = 0;
while (_local2 < arrParticles.length) {
var _local4 = (_root[arrParticles[_local2]]._width / 2) + 7.5;
if (GetDistance(arrParticles[_local2], "projectile") <= _local4) {
_root[arrParticles[_local2]].Collision(saveX, saveY);
_local3.push(arrParticles[_local2]);
}
_local2++;
}
_local2 = 0;
while (_local2 < _local3.length) {
RemoveParticle(_local3[_local2]);
_root[_local3[_local2]].gotoAndStop(2);
_local2++;
}
}
function RemoveParticle(strName) {
var _local1 = 0;
while (_local1 < arrParticles.length) {
if (strName == arrParticles[_local1]) {
arrParticles.splice(_local1, 1);
break;
}
_local1++;
}
}
function GetDistance(targetA, targetB) {
var _local3 = _root[targetB]._x - _root[targetA]._x;
var _local2 = _root[targetB]._y - _root[targetA]._y;
return(Math.sqrt((_local3 * _local3) + (_local2 * _local2)));
}
function RegisterParticle(particleName) {
arrParticles.push(particleName);
arrParticlesReset.push(particleName);
particleDepth++;
return(particleDepth);
}
function MoveProjectile() {
if (ProjectileOffScreen() == false) {
projectileOnScreen = true;
_root.projectile._x = _root.projectile._x + vecShootDir._x;
_root.projectile._y = _root.projectile._y + vecShootDir._y;
} else if (projectileOnScreen == true) {
projectileOver = true;
} else {
_root.projectile._x = _root.projectile._x + vecShootDir._x;
_root.projectile._y = _root.projectile._y + vecShootDir._y;
}
}
function AimProjectile() {
var _local11 = new Vector();
_local11._x = _xmouse - (Stage.width / 2);
_local11._y = _ymouse - (Stage.height / 2);
var _local12 = Math.atan2(_local11._y, _local11._x);
var _local15 = (360 * _local12) / (Math.PI*2);
var _local6 = _root.gameBackground._width / 2;
_root.projectile._x = (_local6 * Math.cos(_local12)) + (Stage.width / 2);
_root.projectile._y = (_local6 * Math.sin(_local12)) + (Stage.height / 2);
_local11._x = (Stage.width / 2) - _root.projectile._x;
_local11._y = (Stage.height / 2) - _root.projectile._y;
_local12 = Math.atan2(_local11._y, _local11._x);
var _local14 = Math.cos(_local12) * 11;
var _local13 = Math.sin(_local12) * 11;
var _local9 = _root.projectile._x;
var _local10 = _root.projectile._y;
var _local5 = new Array(arrParticles.length);
var _local4 = 0;
while (_local4 < _local5.length) {
_local5[_local4] = 0;
_local4++;
}
var _local8 = 0;
while (_local8 < 70) {
_local9 = _local9 + _local14;
_local10 = _local10 + _local13;
_local4 = 0;
while (_local4 < arrParticles.length) {
var _local7 = (_root[arrParticles[_local4]]._width / 2) + 7.5;
var _local3 = _root[arrParticles[_local4]]._x - _local9;
var _local2 = _root[arrParticles[_local4]]._y - _local10;
_local6 = Math.sqrt((_local3 * _local3) + (_local2 * _local2));
if (_local6 <= _local7) {
_local5[_local4] = 1;
}
_local4++;
}
_local8++;
}
_local4 = 0;
while (_local4 < _local5.length) {
if (_local5[_local4] == 1) {
_root[arrParticles[_local4]].ArrowsOn(arrowDepth, _root.projectile._x, _root.projectile._y);
} else {
_root[arrParticles[_local4]].ArrowsOff();
}
_local4++;
}
}
function TurnOffAllArrows() {
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].ArrowsOff();
_local2++;
}
}
function NextArrowDepth() {
arrowDepth++;
if (arrowDepth > 39999) {
arrowDepth = 15000;
}
}
function DrawLines() {
_root.clear();
_root.lineStyle(2, 16777215, 50);
var _local2 = new Object();
var _local3 = new Object();
_local2.x = _root.projectile._x;
_local2.y = _root.projectile._y;
_local3.x = _xmouse;
_local3.y = _ymouse;
_root.moveTo(_local2.x, _local2.y);
_root.lineTo(_local3.x, _local3.y);
}
function Shoot() {
if ((intState == 1) && (_global.latestLevel != -1)) {
trace("in");
_root.clear();
saveX = _root.projectile._x;
saveY = _root.projectile._y;
var _local4 = new Vector();
_local4._x = (Stage.width / 2) - _root.projectile._x;
_local4._y = (Stage.height / 2) - _root.projectile._y;
var _local5 = Math.atan2(_local4._y, _local4._x);
vecShootDir._x = Math.cos(_local5) * 11;
vecShootDir._y = Math.sin(_local5) * 11;
var _local3 = 100;
do {
if (ProjectileOffScreen() != false) {
break;
}
_root.projectile._x = _root.projectile._x - vecShootDir._x;
_root.projectile._y = _root.projectile._y - vecShootDir._y;
_local3--;
} while (_local3 != 0);
var _local6 = (360 * _local5) / (Math.PI*2);
_root.projectile.gotoAndStop(2);
_root.projectile._rotation = _local6;
_root.gameBackground.gotoAndPlay("hide");
TurnOffAllArrows();
intState = 2;
}
}
function ProjectileOffScreen() {
var _local2 = false;
if (((_root.projectile._x + _root.projectile._width) < 0) || ((_root.projectile._x - _root.projectile._width) > Stage.width)) {
_local2 = true;
}
if (((_root.projectile._y + _root.projectile._height) < 0) || ((_root.projectile._y - _root.projectile._height) > Stage.height)) {
_local2 = true;
}
return(_local2);
}
function MoveProjectilesAndCollide() {
var _local4 = 0;
while (_local4 < arrProjectiles.length) {
_root[arrProjectiles[_local4].name]._x = _root[arrProjectiles[_local4].name]._x + (arrProjectiles[_local4].dX / 2);
_root[arrProjectiles[_local4].name]._y = _root[arrProjectiles[_local4].name]._y + (arrProjectiles[_local4].dY / 2);
if (((_root[arrProjectiles[_local4].name]._x + _root[arrProjectiles[_local4].name]._width) < 0) || ((_root[arrProjectiles[_local4].name]._x - _root[arrProjectiles[_local4].name]._width) > Stage.width)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
if (((_root[arrProjectiles[_local4].name]._y + _root[arrProjectiles[_local4].name]._height) < 0) || ((_root[arrProjectiles[_local4].name]._y - _root[arrProjectiles[_local4].name]._height) > Stage.height)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
_local4++;
}
var _local5 = new Array();
var _local3 = 0;
while (_local3 < arrProjectiles.length) {
_local4 = 0;
while (_local4 < arrParticles.length) {
if (_root[arrParticles[_local4]].hitTest(_root[arrProjectiles[_local3].name]._x, _root[arrProjectiles[_local3].name]._y, true) == true) {
_local5.push({name:arrParticles[_local4], X:arrProjectiles[_local3].X, Y:arrProjectiles[_local3].Y});
arrParticles.splice(_local4, 1);
_local4--;
_root[arrProjectiles[_local3].name].removeMovieClip();
arrProjectiles.splice(_local3, 1);
_local3--;
}
_local4++;
}
_local3++;
}
_local4 = 0;
while (_local4 < _local5.length) {
_root[_local5[_local4].name].Collision(_local5[_local4].X, _local5[_local4].Y);
_root[_local5[_local4].name].gotoAndStop(2);
_local4++;
}
_local4 = 0;
while (_local4 < arrProjectiles.length) {
_root[arrProjectiles[_local4].name]._x = _root[arrProjectiles[_local4].name]._x + (arrProjectiles[_local4].dX / 2);
_root[arrProjectiles[_local4].name]._y = _root[arrProjectiles[_local4].name]._y + (arrProjectiles[_local4].dY / 2);
if (((_root[arrProjectiles[_local4].name]._x + _root[arrProjectiles[_local4].name]._width) < 0) || ((_root[arrProjectiles[_local4].name]._x - _root[arrProjectiles[_local4].name]._width) > Stage.width)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
if (((_root[arrProjectiles[_local4].name]._y + _root[arrProjectiles[_local4].name]._height) < 0) || ((_root[arrProjectiles[_local4].name]._y - _root[arrProjectiles[_local4].name]._height) > Stage.height)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
_local4++;
}
_local5 = new Array();
_local3 = 0;
while (_local3 < arrProjectiles.length) {
_local4 = 0;
while (_local4 < arrParticles.length) {
if (_root[arrParticles[_local4]].hitTest(_root[arrProjectiles[_local3].name]._x, _root[arrProjectiles[_local3].name]._y, true) == true) {
_local5.push({name:arrParticles[_local4], X:arrProjectiles[_local3].X, Y:arrProjectiles[_local3].Y});
arrParticles.splice(_local4, 1);
_local4--;
_root[arrProjectiles[_local3].name].removeMovieClip();
arrProjectiles.splice(_local3, 1);
_local3--;
}
_local4++;
}
_local3++;
}
_local4 = 0;
while (_local4 < _local5.length) {
_root[_local5[_local4].name].Collision(_local5[_local4].X, _local5[_local4].Y);
_root[_local5[_local4].name].gotoAndStop(2);
_local4++;
}
if ((arrProjectiles.length == 0) && (projectileOver == true)) {
if (arrParticles.length != 0) {
intState = 3;
_root.messages_mc.gotoAndPlay("retry");
} else {
intState = 4;
var _local10 = ((_global.currentLevel + 5) - 15) / 5;
_global.levels[_local10] = 1;
var _local9 = SharedObject.getLocal("userData");
_local9.data.levelsCompleted = _global.levels;
_global.SoundManager.PlaySound("all");
_root.messages_mc.gotoAndPlay("next");
}
}
}
function LaunchProjectile(deltaX, deltaY, startX, startY, rot) {
var _local2 = "projectile_" + projectileDepth;
arrProjectiles.push({name:_local2, dX:deltaX, dY:deltaY, X:startX, Y:startY});
_root.attachMovie("shootingStar", _local2, projectileDepth);
_root[_local2]._x = startX;
_root[_local2]._y = startY;
_root[_local2]._rotation = rot;
projectileDepth++;
if (projectileDepth > 9999) {
projectileDepth = 5000;
}
}
stop();
var intState = 1;
var vecShootDir;
var arrParticles = new Array();
var arrProjectiles = new Array();
var arrParticlesReset = new Array();
var particleDepth = 1000;
var projectileDepth = 5000;
var arrowDepth = 15000;
var saveX = 0;
var saveY = 0;
var projectileOnScreen = false;
var projectileOver = false;
var saveDepth;
mouseListener = new Object();
mouseListener.onMouseDown = function () {
_root.Shoot();
};
Mouse.addListener(mouseListener);
Frame 205
function GameSetup() {
trace("%%%%%%%%");
trace((_global.currentLevel + " ----- ") + _global.latestLevel);
if (_global.latestLevel == -1) {
_root.gotoAndPlay("splash");
} else if ((_global.latestLevel != 0) && (_global.latestLevel != 20)) {
_global.currentLevel = _global.latestLevel;
_root.gotoAndPlay(_global.latestLevel);
_global.latestLevel = 0;
trace("go here");
} else if ((_global.latestLevel != 0) && (_global.latestLevel == 20)) {
_global.currentLevel = _global.latestLevel;
_global.latestLevel = 0;
}
if (_root.messages_mc.getDepth() != 50000) {
saveDepth = _root.messages_mc.getDepth();
}
vecShootDir = new Vector();
if (_global.musicOn == true) {
_global.myMusicPlayer.SetTrack("game");
_global.myMusicPlayer.SetMaxVolume(40);
_global.myMusicPlayer.PlayWithCrossFade(4);
}
}
function Mediator() {
_global.myMusicPlayer.RunPlayer();
switch (intState) {
case 1 :
AimProjectile();
if (_root.messages_mc.getDepth() != 50000) {
_root.messages_mc.swapDepths(50000);
trace(_root.messages_mc.getDepth());
}
break;
case 2 :
if (projectileOver == false) {
MoveProjectile();
}
DetectParticleCollisions();
MoveProjectilesAndCollide();
break;
case 3 :
if (Key.isDown(32)) {
Reset();
}
break;
case 4 :
if (!Key.isDown(32)) {
break;
}
Next();
}
}
function Reset() {
projectileDepth = 5000;
arrParticles = arrParticlesReset.slice();
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].gotoAndStop(1);
trace(arrParticles[_local2]);
_local2++;
}
trace("-----");
_root.projectile.gotoAndStop(1);
_root.gameBackground.gotoAndStop(1);
_root.messages_mc.gotoAndStop("hide");
projectileOver = false;
projectileOnScreen = false;
intState = 1;
}
function ExitGame() {
CleanupGame();
Mouse.removeListener(mouseListener);
_root.messages_mc.swapDepths(saveDepth);
_global.latestLevel = -1;
_root.gotoAndPlay("level1");
}
function Next() {
_global.currentLevel = _global.currentLevel + 5;
CleanupGame();
_root.messages_mc.swapDepths(saveDepth);
_root.gotoAndPlay(_global.currentLevel);
}
function CleanupGame() {
Mouse.removeListener(mouseListener);
Reset();
var _local3 = 10;
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].swapDepths(_local3);
_local3++;
_root[arrParticles[_local2]].removeMovieClip();
_local2++;
}
delete arrParticles;
arrParticles = new Array();
}
function DetectParticleCollisions() {
var _local3 = new Array();
var _local2 = 0;
while (_local2 < arrParticles.length) {
var _local4 = (_root[arrParticles[_local2]]._width / 2) + 7.5;
if (GetDistance(arrParticles[_local2], "projectile") <= _local4) {
_root[arrParticles[_local2]].Collision(saveX, saveY);
_local3.push(arrParticles[_local2]);
}
_local2++;
}
_local2 = 0;
while (_local2 < _local3.length) {
RemoveParticle(_local3[_local2]);
_root[_local3[_local2]].gotoAndStop(2);
_local2++;
}
}
function RemoveParticle(strName) {
var _local1 = 0;
while (_local1 < arrParticles.length) {
if (strName == arrParticles[_local1]) {
arrParticles.splice(_local1, 1);
break;
}
_local1++;
}
}
function GetDistance(targetA, targetB) {
var _local3 = _root[targetB]._x - _root[targetA]._x;
var _local2 = _root[targetB]._y - _root[targetA]._y;
return(Math.sqrt((_local3 * _local3) + (_local2 * _local2)));
}
function RegisterParticle(particleName) {
arrParticles.push(particleName);
arrParticlesReset.push(particleName);
particleDepth++;
return(particleDepth);
}
function MoveProjectile() {
if (ProjectileOffScreen() == false) {
projectileOnScreen = true;
_root.projectile._x = _root.projectile._x + vecShootDir._x;
_root.projectile._y = _root.projectile._y + vecShootDir._y;
} else if (projectileOnScreen == true) {
projectileOver = true;
} else {
_root.projectile._x = _root.projectile._x + vecShootDir._x;
_root.projectile._y = _root.projectile._y + vecShootDir._y;
}
}
function AimProjectile() {
var _local11 = new Vector();
_local11._x = _xmouse - (Stage.width / 2);
_local11._y = _ymouse - (Stage.height / 2);
var _local12 = Math.atan2(_local11._y, _local11._x);
var _local15 = (360 * _local12) / (Math.PI*2);
var _local6 = _root.gameBackground._width / 2;
_root.projectile._x = (_local6 * Math.cos(_local12)) + (Stage.width / 2);
_root.projectile._y = (_local6 * Math.sin(_local12)) + (Stage.height / 2);
_local11._x = (Stage.width / 2) - _root.projectile._x;
_local11._y = (Stage.height / 2) - _root.projectile._y;
_local12 = Math.atan2(_local11._y, _local11._x);
var _local14 = Math.cos(_local12) * 11;
var _local13 = Math.sin(_local12) * 11;
var _local9 = _root.projectile._x;
var _local10 = _root.projectile._y;
var _local5 = new Array(arrParticles.length);
var _local4 = 0;
while (_local4 < _local5.length) {
_local5[_local4] = 0;
_local4++;
}
var _local8 = 0;
while (_local8 < 70) {
_local9 = _local9 + _local14;
_local10 = _local10 + _local13;
_local4 = 0;
while (_local4 < arrParticles.length) {
var _local7 = (_root[arrParticles[_local4]]._width / 2) + 7.5;
var _local3 = _root[arrParticles[_local4]]._x - _local9;
var _local2 = _root[arrParticles[_local4]]._y - _local10;
_local6 = Math.sqrt((_local3 * _local3) + (_local2 * _local2));
if (_local6 <= _local7) {
_local5[_local4] = 1;
}
_local4++;
}
_local8++;
}
_local4 = 0;
while (_local4 < _local5.length) {
if (_local5[_local4] == 1) {
_root[arrParticles[_local4]].ArrowsOn(arrowDepth, _root.projectile._x, _root.projectile._y);
} else {
_root[arrParticles[_local4]].ArrowsOff();
}
_local4++;
}
}
function TurnOffAllArrows() {
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].ArrowsOff();
_local2++;
}
}
function NextArrowDepth() {
arrowDepth++;
if (arrowDepth > 39999) {
arrowDepth = 15000;
}
}
function DrawLines() {
_root.clear();
_root.lineStyle(2, 16777215, 50);
var _local2 = new Object();
var _local3 = new Object();
_local2.x = _root.projectile._x;
_local2.y = _root.projectile._y;
_local3.x = _xmouse;
_local3.y = _ymouse;
_root.moveTo(_local2.x, _local2.y);
_root.lineTo(_local3.x, _local3.y);
}
function Shoot() {
if ((intState == 1) && (_global.latestLevel != -1)) {
trace("in");
_root.clear();
saveX = _root.projectile._x;
saveY = _root.projectile._y;
var _local4 = new Vector();
_local4._x = (Stage.width / 2) - _root.projectile._x;
_local4._y = (Stage.height / 2) - _root.projectile._y;
var _local5 = Math.atan2(_local4._y, _local4._x);
vecShootDir._x = Math.cos(_local5) * 11;
vecShootDir._y = Math.sin(_local5) * 11;
var _local3 = 100;
do {
if (ProjectileOffScreen() != false) {
break;
}
_root.projectile._x = _root.projectile._x - vecShootDir._x;
_root.projectile._y = _root.projectile._y - vecShootDir._y;
_local3--;
} while (_local3 != 0);
var _local6 = (360 * _local5) / (Math.PI*2);
_root.projectile.gotoAndStop(2);
_root.projectile._rotation = _local6;
_root.gameBackground.gotoAndPlay("hide");
TurnOffAllArrows();
intState = 2;
}
}
function ProjectileOffScreen() {
var _local2 = false;
if (((_root.projectile._x + _root.projectile._width) < 0) || ((_root.projectile._x - _root.projectile._width) > Stage.width)) {
_local2 = true;
}
if (((_root.projectile._y + _root.projectile._height) < 0) || ((_root.projectile._y - _root.projectile._height) > Stage.height)) {
_local2 = true;
}
return(_local2);
}
function MoveProjectilesAndCollide() {
var _local4 = 0;
while (_local4 < arrProjectiles.length) {
_root[arrProjectiles[_local4].name]._x = _root[arrProjectiles[_local4].name]._x + (arrProjectiles[_local4].dX / 2);
_root[arrProjectiles[_local4].name]._y = _root[arrProjectiles[_local4].name]._y + (arrProjectiles[_local4].dY / 2);
if (((_root[arrProjectiles[_local4].name]._x + _root[arrProjectiles[_local4].name]._width) < 0) || ((_root[arrProjectiles[_local4].name]._x - _root[arrProjectiles[_local4].name]._width) > Stage.width)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
if (((_root[arrProjectiles[_local4].name]._y + _root[arrProjectiles[_local4].name]._height) < 0) || ((_root[arrProjectiles[_local4].name]._y - _root[arrProjectiles[_local4].name]._height) > Stage.height)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
_local4++;
}
var _local5 = new Array();
var _local3 = 0;
while (_local3 < arrProjectiles.length) {
_local4 = 0;
while (_local4 < arrParticles.length) {
if (_root[arrParticles[_local4]].hitTest(_root[arrProjectiles[_local3].name]._x, _root[arrProjectiles[_local3].name]._y, true) == true) {
_local5.push({name:arrParticles[_local4], X:arrProjectiles[_local3].X, Y:arrProjectiles[_local3].Y});
arrParticles.splice(_local4, 1);
_local4--;
_root[arrProjectiles[_local3].name].removeMovieClip();
arrProjectiles.splice(_local3, 1);
_local3--;
}
_local4++;
}
_local3++;
}
_local4 = 0;
while (_local4 < _local5.length) {
_root[_local5[_local4].name].Collision(_local5[_local4].X, _local5[_local4].Y);
_root[_local5[_local4].name].gotoAndStop(2);
_local4++;
}
_local4 = 0;
while (_local4 < arrProjectiles.length) {
_root[arrProjectiles[_local4].name]._x = _root[arrProjectiles[_local4].name]._x + (arrProjectiles[_local4].dX / 2);
_root[arrProjectiles[_local4].name]._y = _root[arrProjectiles[_local4].name]._y + (arrProjectiles[_local4].dY / 2);
if (((_root[arrProjectiles[_local4].name]._x + _root[arrProjectiles[_local4].name]._width) < 0) || ((_root[arrProjectiles[_local4].name]._x - _root[arrProjectiles[_local4].name]._width) > Stage.width)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
if (((_root[arrProjectiles[_local4].name]._y + _root[arrProjectiles[_local4].name]._height) < 0) || ((_root[arrProjectiles[_local4].name]._y - _root[arrProjectiles[_local4].name]._height) > Stage.height)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
_local4++;
}
_local5 = new Array();
_local3 = 0;
while (_local3 < arrProjectiles.length) {
_local4 = 0;
while (_local4 < arrParticles.length) {
if (_root[arrParticles[_local4]].hitTest(_root[arrProjectiles[_local3].name]._x, _root[arrProjectiles[_local3].name]._y, true) == true) {
_local5.push({name:arrParticles[_local4], X:arrProjectiles[_local3].X, Y:arrProjectiles[_local3].Y});
arrParticles.splice(_local4, 1);
_local4--;
_root[arrProjectiles[_local3].name].removeMovieClip();
arrProjectiles.splice(_local3, 1);
_local3--;
}
_local4++;
}
_local3++;
}
_local4 = 0;
while (_local4 < _local5.length) {
_root[_local5[_local4].name].Collision(_local5[_local4].X, _local5[_local4].Y);
_root[_local5[_local4].name].gotoAndStop(2);
_local4++;
}
if ((arrProjectiles.length == 0) && (projectileOver == true)) {
if (arrParticles.length != 0) {
intState = 3;
_root.messages_mc.gotoAndPlay("retry");
} else {
intState = 4;
var _local10 = ((_global.currentLevel + 5) - 15) / 5;
_global.levels[_local10] = 1;
var _local9 = SharedObject.getLocal("userData");
_local9.data.levelsCompleted = _global.levels;
_global.SoundManager.PlaySound("all");
_root.messages_mc.gotoAndPlay("next");
}
}
}
function LaunchProjectile(deltaX, deltaY, startX, startY, rot) {
var _local2 = "projectile_" + projectileDepth;
arrProjectiles.push({name:_local2, dX:deltaX, dY:deltaY, X:startX, Y:startY});
_root.attachMovie("shootingStar", _local2, projectileDepth);
_root[_local2]._x = startX;
_root[_local2]._y = startY;
_root[_local2]._rotation = rot;
projectileDepth++;
if (projectileDepth > 9999) {
projectileDepth = 5000;
}
}
stop();
var intState = 1;
var vecShootDir;
var arrParticles = new Array();
var arrProjectiles = new Array();
var arrParticlesReset = new Array();
var particleDepth = 1000;
var projectileDepth = 5000;
var arrowDepth = 15000;
var saveX = 0;
var saveY = 0;
var projectileOnScreen = false;
var projectileOver = false;
var saveDepth;
mouseListener = new Object();
mouseListener.onMouseDown = function () {
_root.Shoot();
};
Mouse.addListener(mouseListener);
Frame 210
function GameSetup() {
trace("%%%%%%%%");
trace((_global.currentLevel + " ----- ") + _global.latestLevel);
if (_global.latestLevel == -1) {
_root.gotoAndPlay("splash");
} else if ((_global.latestLevel != 0) && (_global.latestLevel != 20)) {
_global.currentLevel = _global.latestLevel;
_root.gotoAndPlay(_global.latestLevel);
_global.latestLevel = 0;
trace("go here");
} else if ((_global.latestLevel != 0) && (_global.latestLevel == 20)) {
_global.currentLevel = _global.latestLevel;
_global.latestLevel = 0;
}
if (_root.messages_mc.getDepth() != 50000) {
saveDepth = _root.messages_mc.getDepth();
}
vecShootDir = new Vector();
if (_global.musicOn == true) {
_global.myMusicPlayer.SetTrack("game");
_global.myMusicPlayer.SetMaxVolume(40);
_global.myMusicPlayer.PlayWithCrossFade(4);
}
}
function Mediator() {
_global.myMusicPlayer.RunPlayer();
switch (intState) {
case 1 :
AimProjectile();
if (_root.messages_mc.getDepth() != 50000) {
_root.messages_mc.swapDepths(50000);
trace(_root.messages_mc.getDepth());
}
break;
case 2 :
if (projectileOver == false) {
MoveProjectile();
}
DetectParticleCollisions();
MoveProjectilesAndCollide();
break;
case 3 :
if (Key.isDown(32)) {
Reset();
}
break;
case 4 :
if (!Key.isDown(32)) {
break;
}
Next();
}
}
function Reset() {
projectileDepth = 5000;
arrParticles = arrParticlesReset.slice();
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].gotoAndStop(1);
trace(arrParticles[_local2]);
_local2++;
}
trace("-----");
_root.projectile.gotoAndStop(1);
_root.gameBackground.gotoAndStop(1);
_root.messages_mc.gotoAndStop("hide");
projectileOver = false;
projectileOnScreen = false;
intState = 1;
}
function ExitGame() {
CleanupGame();
Mouse.removeListener(mouseListener);
_root.messages_mc.swapDepths(saveDepth);
_global.latestLevel = -1;
_root.gotoAndPlay("level1");
}
function Next() {
_global.currentLevel = _global.currentLevel + 5;
CleanupGame();
_root.messages_mc.swapDepths(saveDepth);
_root.gotoAndPlay(_global.currentLevel);
}
function CleanupGame() {
Mouse.removeListener(mouseListener);
Reset();
var _local3 = 10;
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].swapDepths(_local3);
_local3++;
_root[arrParticles[_local2]].removeMovieClip();
_local2++;
}
delete arrParticles;
arrParticles = new Array();
}
function DetectParticleCollisions() {
var _local3 = new Array();
var _local2 = 0;
while (_local2 < arrParticles.length) {
var _local4 = (_root[arrParticles[_local2]]._width / 2) + 7.5;
if (GetDistance(arrParticles[_local2], "projectile") <= _local4) {
_root[arrParticles[_local2]].Collision(saveX, saveY);
_local3.push(arrParticles[_local2]);
}
_local2++;
}
_local2 = 0;
while (_local2 < _local3.length) {
RemoveParticle(_local3[_local2]);
_root[_local3[_local2]].gotoAndStop(2);
_local2++;
}
}
function RemoveParticle(strName) {
var _local1 = 0;
while (_local1 < arrParticles.length) {
if (strName == arrParticles[_local1]) {
arrParticles.splice(_local1, 1);
break;
}
_local1++;
}
}
function GetDistance(targetA, targetB) {
var _local3 = _root[targetB]._x - _root[targetA]._x;
var _local2 = _root[targetB]._y - _root[targetA]._y;
return(Math.sqrt((_local3 * _local3) + (_local2 * _local2)));
}
function RegisterParticle(particleName) {
arrParticles.push(particleName);
arrParticlesReset.push(particleName);
particleDepth++;
return(particleDepth);
}
function MoveProjectile() {
if (ProjectileOffScreen() == false) {
projectileOnScreen = true;
_root.projectile._x = _root.projectile._x + vecShootDir._x;
_root.projectile._y = _root.projectile._y + vecShootDir._y;
} else if (projectileOnScreen == true) {
projectileOver = true;
} else {
_root.projectile._x = _root.projectile._x + vecShootDir._x;
_root.projectile._y = _root.projectile._y + vecShootDir._y;
}
}
function AimProjectile() {
var _local11 = new Vector();
_local11._x = _xmouse - (Stage.width / 2);
_local11._y = _ymouse - (Stage.height / 2);
var _local12 = Math.atan2(_local11._y, _local11._x);
var _local15 = (360 * _local12) / (Math.PI*2);
var _local6 = _root.gameBackground._width / 2;
_root.projectile._x = (_local6 * Math.cos(_local12)) + (Stage.width / 2);
_root.projectile._y = (_local6 * Math.sin(_local12)) + (Stage.height / 2);
_local11._x = (Stage.width / 2) - _root.projectile._x;
_local11._y = (Stage.height / 2) - _root.projectile._y;
_local12 = Math.atan2(_local11._y, _local11._x);
var _local14 = Math.cos(_local12) * 11;
var _local13 = Math.sin(_local12) * 11;
var _local9 = _root.projectile._x;
var _local10 = _root.projectile._y;
var _local5 = new Array(arrParticles.length);
var _local4 = 0;
while (_local4 < _local5.length) {
_local5[_local4] = 0;
_local4++;
}
var _local8 = 0;
while (_local8 < 70) {
_local9 = _local9 + _local14;
_local10 = _local10 + _local13;
_local4 = 0;
while (_local4 < arrParticles.length) {
var _local7 = (_root[arrParticles[_local4]]._width / 2) + 7.5;
var _local3 = _root[arrParticles[_local4]]._x - _local9;
var _local2 = _root[arrParticles[_local4]]._y - _local10;
_local6 = Math.sqrt((_local3 * _local3) + (_local2 * _local2));
if (_local6 <= _local7) {
_local5[_local4] = 1;
}
_local4++;
}
_local8++;
}
_local4 = 0;
while (_local4 < _local5.length) {
if (_local5[_local4] == 1) {
_root[arrParticles[_local4]].ArrowsOn(arrowDepth, _root.projectile._x, _root.projectile._y);
} else {
_root[arrParticles[_local4]].ArrowsOff();
}
_local4++;
}
}
function TurnOffAllArrows() {
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].ArrowsOff();
_local2++;
}
}
function NextArrowDepth() {
arrowDepth++;
if (arrowDepth > 39999) {
arrowDepth = 15000;
}
}
function DrawLines() {
_root.clear();
_root.lineStyle(2, 16777215, 50);
var _local2 = new Object();
var _local3 = new Object();
_local2.x = _root.projectile._x;
_local2.y = _root.projectile._y;
_local3.x = _xmouse;
_local3.y = _ymouse;
_root.moveTo(_local2.x, _local2.y);
_root.lineTo(_local3.x, _local3.y);
}
function Shoot() {
if ((intState == 1) && (_global.latestLevel != -1)) {
trace("in");
_root.clear();
saveX = _root.projectile._x;
saveY = _root.projectile._y;
var _local4 = new Vector();
_local4._x = (Stage.width / 2) - _root.projectile._x;
_local4._y = (Stage.height / 2) - _root.projectile._y;
var _local5 = Math.atan2(_local4._y, _local4._x);
vecShootDir._x = Math.cos(_local5) * 11;
vecShootDir._y = Math.sin(_local5) * 11;
var _local3 = 100;
do {
if (ProjectileOffScreen() != false) {
break;
}
_root.projectile._x = _root.projectile._x - vecShootDir._x;
_root.projectile._y = _root.projectile._y - vecShootDir._y;
_local3--;
} while (_local3 != 0);
var _local6 = (360 * _local5) / (Math.PI*2);
_root.projectile.gotoAndStop(2);
_root.projectile._rotation = _local6;
_root.gameBackground.gotoAndPlay("hide");
TurnOffAllArrows();
intState = 2;
}
}
function ProjectileOffScreen() {
var _local2 = false;
if (((_root.projectile._x + _root.projectile._width) < 0) || ((_root.projectile._x - _root.projectile._width) > Stage.width)) {
_local2 = true;
}
if (((_root.projectile._y + _root.projectile._height) < 0) || ((_root.projectile._y - _root.projectile._height) > Stage.height)) {
_local2 = true;
}
return(_local2);
}
function MoveProjectilesAndCollide() {
var _local4 = 0;
while (_local4 < arrProjectiles.length) {
_root[arrProjectiles[_local4].name]._x = _root[arrProjectiles[_local4].name]._x + (arrProjectiles[_local4].dX / 2);
_root[arrProjectiles[_local4].name]._y = _root[arrProjectiles[_local4].name]._y + (arrProjectiles[_local4].dY / 2);
if (((_root[arrProjectiles[_local4].name]._x + _root[arrProjectiles[_local4].name]._width) < 0) || ((_root[arrProjectiles[_local4].name]._x - _root[arrProjectiles[_local4].name]._width) > Stage.width)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
if (((_root[arrProjectiles[_local4].name]._y + _root[arrProjectiles[_local4].name]._height) < 0) || ((_root[arrProjectiles[_local4].name]._y - _root[arrProjectiles[_local4].name]._height) > Stage.height)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
_local4++;
}
var _local5 = new Array();
var _local3 = 0;
while (_local3 < arrProjectiles.length) {
_local4 = 0;
while (_local4 < arrParticles.length) {
if (_root[arrParticles[_local4]].hitTest(_root[arrProjectiles[_local3].name]._x, _root[arrProjectiles[_local3].name]._y, true) == true) {
_local5.push({name:arrParticles[_local4], X:arrProjectiles[_local3].X, Y:arrProjectiles[_local3].Y});
arrParticles.splice(_local4, 1);
_local4--;
_root[arrProjectiles[_local3].name].removeMovieClip();
arrProjectiles.splice(_local3, 1);
_local3--;
}
_local4++;
}
_local3++;
}
_local4 = 0;
while (_local4 < _local5.length) {
_root[_local5[_local4].name].Collision(_local5[_local4].X, _local5[_local4].Y);
_root[_local5[_local4].name].gotoAndStop(2);
_local4++;
}
_local4 = 0;
while (_local4 < arrProjectiles.length) {
_root[arrProjectiles[_local4].name]._x = _root[arrProjectiles[_local4].name]._x + (arrProjectiles[_local4].dX / 2);
_root[arrProjectiles[_local4].name]._y = _root[arrProjectiles[_local4].name]._y + (arrProjectiles[_local4].dY / 2);
if (((_root[arrProjectiles[_local4].name]._x + _root[arrProjectiles[_local4].name]._width) < 0) || ((_root[arrProjectiles[_local4].name]._x - _root[arrProjectiles[_local4].name]._width) > Stage.width)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
if (((_root[arrProjectiles[_local4].name]._y + _root[arrProjectiles[_local4].name]._height) < 0) || ((_root[arrProjectiles[_local4].name]._y - _root[arrProjectiles[_local4].name]._height) > Stage.height)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
_local4++;
}
_local5 = new Array();
_local3 = 0;
while (_local3 < arrProjectiles.length) {
_local4 = 0;
while (_local4 < arrParticles.length) {
if (_root[arrParticles[_local4]].hitTest(_root[arrProjectiles[_local3].name]._x, _root[arrProjectiles[_local3].name]._y, true) == true) {
_local5.push({name:arrParticles[_local4], X:arrProjectiles[_local3].X, Y:arrProjectiles[_local3].Y});
arrParticles.splice(_local4, 1);
_local4--;
_root[arrProjectiles[_local3].name].removeMovieClip();
arrProjectiles.splice(_local3, 1);
_local3--;
}
_local4++;
}
_local3++;
}
_local4 = 0;
while (_local4 < _local5.length) {
_root[_local5[_local4].name].Collision(_local5[_local4].X, _local5[_local4].Y);
_root[_local5[_local4].name].gotoAndStop(2);
_local4++;
}
if ((arrProjectiles.length == 0) && (projectileOver == true)) {
if (arrParticles.length != 0) {
intState = 3;
_root.messages_mc.gotoAndPlay("retry");
} else {
intState = 4;
var _local10 = ((_global.currentLevel + 5) - 15) / 5;
_global.levels[_local10] = 1;
var _local9 = SharedObject.getLocal("userData");
_local9.data.levelsCompleted = _global.levels;
_global.SoundManager.PlaySound("all");
_root.messages_mc.gotoAndPlay("next");
}
}
}
function LaunchProjectile(deltaX, deltaY, startX, startY, rot) {
var _local2 = "projectile_" + projectileDepth;
arrProjectiles.push({name:_local2, dX:deltaX, dY:deltaY, X:startX, Y:startY});
_root.attachMovie("shootingStar", _local2, projectileDepth);
_root[_local2]._x = startX;
_root[_local2]._y = startY;
_root[_local2]._rotation = rot;
projectileDepth++;
if (projectileDepth > 9999) {
projectileDepth = 5000;
}
}
stop();
var intState = 1;
var vecShootDir;
var arrParticles = new Array();
var arrProjectiles = new Array();
var arrParticlesReset = new Array();
var particleDepth = 1000;
var projectileDepth = 5000;
var arrowDepth = 15000;
var saveX = 0;
var saveY = 0;
var projectileOnScreen = false;
var projectileOver = false;
var saveDepth;
mouseListener = new Object();
mouseListener.onMouseDown = function () {
_root.Shoot();
};
Mouse.addListener(mouseListener);
Frame 215
function GameSetup() {
trace("%%%%%%%%");
trace((_global.currentLevel + " ----- ") + _global.latestLevel);
if (_global.latestLevel == -1) {
_root.gotoAndPlay("splash");
} else if ((_global.latestLevel != 0) && (_global.latestLevel != 20)) {
_global.currentLevel = _global.latestLevel;
_root.gotoAndPlay(_global.latestLevel);
_global.latestLevel = 0;
trace("go here");
} else if ((_global.latestLevel != 0) && (_global.latestLevel == 20)) {
_global.currentLevel = _global.latestLevel;
_global.latestLevel = 0;
}
if (_root.messages_mc.getDepth() != 50000) {
saveDepth = _root.messages_mc.getDepth();
}
vecShootDir = new Vector();
if (_global.musicOn == true) {
_global.myMusicPlayer.SetTrack("game");
_global.myMusicPlayer.SetMaxVolume(40);
_global.myMusicPlayer.PlayWithCrossFade(4);
}
}
function Mediator() {
_global.myMusicPlayer.RunPlayer();
switch (intState) {
case 1 :
AimProjectile();
if (_root.messages_mc.getDepth() != 50000) {
_root.messages_mc.swapDepths(50000);
trace(_root.messages_mc.getDepth());
}
break;
case 2 :
if (projectileOver == false) {
MoveProjectile();
}
DetectParticleCollisions();
MoveProjectilesAndCollide();
break;
case 3 :
if (Key.isDown(32)) {
Reset();
}
break;
case 4 :
if (!Key.isDown(32)) {
break;
}
Next();
}
}
function Reset() {
projectileDepth = 5000;
arrParticles = arrParticlesReset.slice();
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].gotoAndStop(1);
trace(arrParticles[_local2]);
_local2++;
}
trace("-----");
_root.projectile.gotoAndStop(1);
_root.gameBackground.gotoAndStop(1);
_root.messages_mc.gotoAndStop("hide");
projectileOver = false;
projectileOnScreen = false;
intState = 1;
}
function ExitGame() {
CleanupGame();
Mouse.removeListener(mouseListener);
_root.messages_mc.swapDepths(saveDepth);
_global.latestLevel = -1;
_root.gotoAndPlay("level1");
}
function Next() {
_global.currentLevel = _global.currentLevel + 5;
CleanupGame();
_root.messages_mc.swapDepths(saveDepth);
_root.gotoAndPlay(_global.currentLevel);
}
function CleanupGame() {
Mouse.removeListener(mouseListener);
Reset();
var _local3 = 10;
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].swapDepths(_local3);
_local3++;
_root[arrParticles[_local2]].removeMovieClip();
_local2++;
}
delete arrParticles;
arrParticles = new Array();
}
function DetectParticleCollisions() {
var _local3 = new Array();
var _local2 = 0;
while (_local2 < arrParticles.length) {
var _local4 = (_root[arrParticles[_local2]]._width / 2) + 7.5;
if (GetDistance(arrParticles[_local2], "projectile") <= _local4) {
_root[arrParticles[_local2]].Collision(saveX, saveY);
_local3.push(arrParticles[_local2]);
}
_local2++;
}
_local2 = 0;
while (_local2 < _local3.length) {
RemoveParticle(_local3[_local2]);
_root[_local3[_local2]].gotoAndStop(2);
_local2++;
}
}
function RemoveParticle(strName) {
var _local1 = 0;
while (_local1 < arrParticles.length) {
if (strName == arrParticles[_local1]) {
arrParticles.splice(_local1, 1);
break;
}
_local1++;
}
}
function GetDistance(targetA, targetB) {
var _local3 = _root[targetB]._x - _root[targetA]._x;
var _local2 = _root[targetB]._y - _root[targetA]._y;
return(Math.sqrt((_local3 * _local3) + (_local2 * _local2)));
}
function RegisterParticle(particleName) {
arrParticles.push(particleName);
arrParticlesReset.push(particleName);
particleDepth++;
return(particleDepth);
}
function MoveProjectile() {
if (ProjectileOffScreen() == false) {
projectileOnScreen = true;
_root.projectile._x = _root.projectile._x + vecShootDir._x;
_root.projectile._y = _root.projectile._y + vecShootDir._y;
} else if (projectileOnScreen == true) {
projectileOver = true;
} else {
_root.projectile._x = _root.projectile._x + vecShootDir._x;
_root.projectile._y = _root.projectile._y + vecShootDir._y;
}
}
function AimProjectile() {
var _local11 = new Vector();
_local11._x = _xmouse - (Stage.width / 2);
_local11._y = _ymouse - (Stage.height / 2);
var _local12 = Math.atan2(_local11._y, _local11._x);
var _local15 = (360 * _local12) / (Math.PI*2);
var _local6 = _root.gameBackground._width / 2;
_root.projectile._x = (_local6 * Math.cos(_local12)) + (Stage.width / 2);
_root.projectile._y = (_local6 * Math.sin(_local12)) + (Stage.height / 2);
_local11._x = (Stage.width / 2) - _root.projectile._x;
_local11._y = (Stage.height / 2) - _root.projectile._y;
_local12 = Math.atan2(_local11._y, _local11._x);
var _local14 = Math.cos(_local12) * 11;
var _local13 = Math.sin(_local12) * 11;
var _local9 = _root.projectile._x;
var _local10 = _root.projectile._y;
var _local5 = new Array(arrParticles.length);
var _local4 = 0;
while (_local4 < _local5.length) {
_local5[_local4] = 0;
_local4++;
}
var _local8 = 0;
while (_local8 < 70) {
_local9 = _local9 + _local14;
_local10 = _local10 + _local13;
_local4 = 0;
while (_local4 < arrParticles.length) {
var _local7 = (_root[arrParticles[_local4]]._width / 2) + 7.5;
var _local3 = _root[arrParticles[_local4]]._x - _local9;
var _local2 = _root[arrParticles[_local4]]._y - _local10;
_local6 = Math.sqrt((_local3 * _local3) + (_local2 * _local2));
if (_local6 <= _local7) {
_local5[_local4] = 1;
}
_local4++;
}
_local8++;
}
_local4 = 0;
while (_local4 < _local5.length) {
if (_local5[_local4] == 1) {
_root[arrParticles[_local4]].ArrowsOn(arrowDepth, _root.projectile._x, _root.projectile._y);
} else {
_root[arrParticles[_local4]].ArrowsOff();
}
_local4++;
}
}
function TurnOffAllArrows() {
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].ArrowsOff();
_local2++;
}
}
function NextArrowDepth() {
arrowDepth++;
if (arrowDepth > 39999) {
arrowDepth = 15000;
}
}
function DrawLines() {
_root.clear();
_root.lineStyle(2, 16777215, 50);
var _local2 = new Object();
var _local3 = new Object();
_local2.x = _root.projectile._x;
_local2.y = _root.projectile._y;
_local3.x = _xmouse;
_local3.y = _ymouse;
_root.moveTo(_local2.x, _local2.y);
_root.lineTo(_local3.x, _local3.y);
}
function Shoot() {
if ((intState == 1) && (_global.latestLevel != -1)) {
trace("in");
_root.clear();
saveX = _root.projectile._x;
saveY = _root.projectile._y;
var _local4 = new Vector();
_local4._x = (Stage.width / 2) - _root.projectile._x;
_local4._y = (Stage.height / 2) - _root.projectile._y;
var _local5 = Math.atan2(_local4._y, _local4._x);
vecShootDir._x = Math.cos(_local5) * 11;
vecShootDir._y = Math.sin(_local5) * 11;
var _local3 = 100;
do {
if (ProjectileOffScreen() != false) {
break;
}
_root.projectile._x = _root.projectile._x - vecShootDir._x;
_root.projectile._y = _root.projectile._y - vecShootDir._y;
_local3--;
} while (_local3 != 0);
var _local6 = (360 * _local5) / (Math.PI*2);
_root.projectile.gotoAndStop(2);
_root.projectile._rotation = _local6;
_root.gameBackground.gotoAndPlay("hide");
TurnOffAllArrows();
intState = 2;
}
}
function ProjectileOffScreen() {
var _local2 = false;
if (((_root.projectile._x + _root.projectile._width) < 0) || ((_root.projectile._x - _root.projectile._width) > Stage.width)) {
_local2 = true;
}
if (((_root.projectile._y + _root.projectile._height) < 0) || ((_root.projectile._y - _root.projectile._height) > Stage.height)) {
_local2 = true;
}
return(_local2);
}
function MoveProjectilesAndCollide() {
var _local4 = 0;
while (_local4 < arrProjectiles.length) {
_root[arrProjectiles[_local4].name]._x = _root[arrProjectiles[_local4].name]._x + (arrProjectiles[_local4].dX / 2);
_root[arrProjectiles[_local4].name]._y = _root[arrProjectiles[_local4].name]._y + (arrProjectiles[_local4].dY / 2);
if (((_root[arrProjectiles[_local4].name]._x + _root[arrProjectiles[_local4].name]._width) < 0) || ((_root[arrProjectiles[_local4].name]._x - _root[arrProjectiles[_local4].name]._width) > Stage.width)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
if (((_root[arrProjectiles[_local4].name]._y + _root[arrProjectiles[_local4].name]._height) < 0) || ((_root[arrProjectiles[_local4].name]._y - _root[arrProjectiles[_local4].name]._height) > Stage.height)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
_local4++;
}
var _local5 = new Array();
var _local3 = 0;
while (_local3 < arrProjectiles.length) {
_local4 = 0;
while (_local4 < arrParticles.length) {
if (_root[arrParticles[_local4]].hitTest(_root[arrProjectiles[_local3].name]._x, _root[arrProjectiles[_local3].name]._y, true) == true) {
_local5.push({name:arrParticles[_local4], X:arrProjectiles[_local3].X, Y:arrProjectiles[_local3].Y});
arrParticles.splice(_local4, 1);
_local4--;
_root[arrProjectiles[_local3].name].removeMovieClip();
arrProjectiles.splice(_local3, 1);
_local3--;
}
_local4++;
}
_local3++;
}
_local4 = 0;
while (_local4 < _local5.length) {
_root[_local5[_local4].name].Collision(_local5[_local4].X, _local5[_local4].Y);
_root[_local5[_local4].name].gotoAndStop(2);
_local4++;
}
_local4 = 0;
while (_local4 < arrProjectiles.length) {
_root[arrProjectiles[_local4].name]._x = _root[arrProjectiles[_local4].name]._x + (arrProjectiles[_local4].dX / 2);
_root[arrProjectiles[_local4].name]._y = _root[arrProjectiles[_local4].name]._y + (arrProjectiles[_local4].dY / 2);
if (((_root[arrProjectiles[_local4].name]._x + _root[arrProjectiles[_local4].name]._width) < 0) || ((_root[arrProjectiles[_local4].name]._x - _root[arrProjectiles[_local4].name]._width) > Stage.width)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
if (((_root[arrProjectiles[_local4].name]._y + _root[arrProjectiles[_local4].name]._height) < 0) || ((_root[arrProjectiles[_local4].name]._y - _root[arrProjectiles[_local4].name]._height) > Stage.height)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
_local4++;
}
_local5 = new Array();
_local3 = 0;
while (_local3 < arrProjectiles.length) {
_local4 = 0;
while (_local4 < arrParticles.length) {
if (_root[arrParticles[_local4]].hitTest(_root[arrProjectiles[_local3].name]._x, _root[arrProjectiles[_local3].name]._y, true) == true) {
_local5.push({name:arrParticles[_local4], X:arrProjectiles[_local3].X, Y:arrProjectiles[_local3].Y});
arrParticles.splice(_local4, 1);
_local4--;
_root[arrProjectiles[_local3].name].removeMovieClip();
arrProjectiles.splice(_local3, 1);
_local3--;
}
_local4++;
}
_local3++;
}
_local4 = 0;
while (_local4 < _local5.length) {
_root[_local5[_local4].name].Collision(_local5[_local4].X, _local5[_local4].Y);
_root[_local5[_local4].name].gotoAndStop(2);
_local4++;
}
if ((arrProjectiles.length == 0) && (projectileOver == true)) {
if (arrParticles.length != 0) {
intState = 3;
_root.messages_mc.gotoAndPlay("retry");
} else {
intState = 4;
var _local10 = ((_global.currentLevel + 5) - 15) / 5;
_global.levels[_local10] = 1;
var _local9 = SharedObject.getLocal("userData");
_local9.data.levelsCompleted = _global.levels;
_global.SoundManager.PlaySound("all");
_root.messages_mc.gotoAndPlay("next");
}
}
}
function LaunchProjectile(deltaX, deltaY, startX, startY, rot) {
var _local2 = "projectile_" + projectileDepth;
arrProjectiles.push({name:_local2, dX:deltaX, dY:deltaY, X:startX, Y:startY});
_root.attachMovie("shootingStar", _local2, projectileDepth);
_root[_local2]._x = startX;
_root[_local2]._y = startY;
_root[_local2]._rotation = rot;
projectileDepth++;
if (projectileDepth > 9999) {
projectileDepth = 5000;
}
}
stop();
var intState = 1;
var vecShootDir;
var arrParticles = new Array();
var arrProjectiles = new Array();
var arrParticlesReset = new Array();
var particleDepth = 1000;
var projectileDepth = 5000;
var arrowDepth = 15000;
var saveX = 0;
var saveY = 0;
var projectileOnScreen = false;
var projectileOver = false;
var saveDepth;
mouseListener = new Object();
mouseListener.onMouseDown = function () {
_root.Shoot();
};
Mouse.addListener(mouseListener);
Frame 220
function GameSetup() {
trace("%%%%%%%%");
trace((_global.currentLevel + " ----- ") + _global.latestLevel);
if (_global.latestLevel == -1) {
_root.gotoAndPlay("splash");
} else if ((_global.latestLevel != 0) && (_global.latestLevel != 20)) {
_global.currentLevel = _global.latestLevel;
_root.gotoAndPlay(_global.latestLevel);
_global.latestLevel = 0;
trace("go here");
} else if ((_global.latestLevel != 0) && (_global.latestLevel == 20)) {
_global.currentLevel = _global.latestLevel;
_global.latestLevel = 0;
}
if (_root.messages_mc.getDepth() != 50000) {
saveDepth = _root.messages_mc.getDepth();
}
vecShootDir = new Vector();
if (_global.musicOn == true) {
_global.myMusicPlayer.SetTrack("game");
_global.myMusicPlayer.SetMaxVolume(40);
_global.myMusicPlayer.PlayWithCrossFade(4);
}
}
function Mediator() {
_global.myMusicPlayer.RunPlayer();
switch (intState) {
case 1 :
AimProjectile();
if (_root.messages_mc.getDepth() != 50000) {
_root.messages_mc.swapDepths(50000);
trace(_root.messages_mc.getDepth());
}
break;
case 2 :
if (projectileOver == false) {
MoveProjectile();
}
DetectParticleCollisions();
MoveProjectilesAndCollide();
break;
case 3 :
if (Key.isDown(32)) {
Reset();
}
break;
case 4 :
if (!Key.isDown(32)) {
break;
}
Next();
}
}
function Reset() {
projectileDepth = 5000;
arrParticles = arrParticlesReset.slice();
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].gotoAndStop(1);
trace(arrParticles[_local2]);
_local2++;
}
trace("-----");
_root.projectile.gotoAndStop(1);
_root.gameBackground.gotoAndStop(1);
_root.messages_mc.gotoAndStop("hide");
projectileOver = false;
projectileOnScreen = false;
intState = 1;
}
function ExitGame() {
CleanupGame();
Mouse.removeListener(mouseListener);
_root.messages_mc.swapDepths(saveDepth);
_global.latestLevel = -1;
_root.gotoAndPlay("level1");
}
function Next() {
_global.currentLevel = _global.currentLevel + 5;
CleanupGame();
_root.messages_mc.swapDepths(saveDepth);
_root.gotoAndPlay(_global.currentLevel);
}
function CleanupGame() {
Mouse.removeListener(mouseListener);
Reset();
var _local3 = 10;
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].swapDepths(_local3);
_local3++;
_root[arrParticles[_local2]].removeMovieClip();
_local2++;
}
delete arrParticles;
arrParticles = new Array();
}
function DetectParticleCollisions() {
var _local3 = new Array();
var _local2 = 0;
while (_local2 < arrParticles.length) {
var _local4 = (_root[arrParticles[_local2]]._width / 2) + 7.5;
if (GetDistance(arrParticles[_local2], "projectile") <= _local4) {
_root[arrParticles[_local2]].Collision(saveX, saveY);
_local3.push(arrParticles[_local2]);
}
_local2++;
}
_local2 = 0;
while (_local2 < _local3.length) {
RemoveParticle(_local3[_local2]);
_root[_local3[_local2]].gotoAndStop(2);
_local2++;
}
}
function RemoveParticle(strName) {
var _local1 = 0;
while (_local1 < arrParticles.length) {
if (strName == arrParticles[_local1]) {
arrParticles.splice(_local1, 1);
break;
}
_local1++;
}
}
function GetDistance(targetA, targetB) {
var _local3 = _root[targetB]._x - _root[targetA]._x;
var _local2 = _root[targetB]._y - _root[targetA]._y;
return(Math.sqrt((_local3 * _local3) + (_local2 * _local2)));
}
function RegisterParticle(particleName) {
arrParticles.push(particleName);
arrParticlesReset.push(particleName);
particleDepth++;
return(particleDepth);
}
function MoveProjectile() {
if (ProjectileOffScreen() == false) {
projectileOnScreen = true;
_root.projectile._x = _root.projectile._x + vecShootDir._x;
_root.projectile._y = _root.projectile._y + vecShootDir._y;
} else if (projectileOnScreen == true) {
projectileOver = true;
} else {
_root.projectile._x = _root.projectile._x + vecShootDir._x;
_root.projectile._y = _root.projectile._y + vecShootDir._y;
}
}
function AimProjectile() {
var _local11 = new Vector();
_local11._x = _xmouse - (Stage.width / 2);
_local11._y = _ymouse - (Stage.height / 2);
var _local12 = Math.atan2(_local11._y, _local11._x);
var _local15 = (360 * _local12) / (Math.PI*2);
var _local6 = _root.gameBackground._width / 2;
_root.projectile._x = (_local6 * Math.cos(_local12)) + (Stage.width / 2);
_root.projectile._y = (_local6 * Math.sin(_local12)) + (Stage.height / 2);
_local11._x = (Stage.width / 2) - _root.projectile._x;
_local11._y = (Stage.height / 2) - _root.projectile._y;
_local12 = Math.atan2(_local11._y, _local11._x);
var _local14 = Math.cos(_local12) * 11;
var _local13 = Math.sin(_local12) * 11;
var _local9 = _root.projectile._x;
var _local10 = _root.projectile._y;
var _local5 = new Array(arrParticles.length);
var _local4 = 0;
while (_local4 < _local5.length) {
_local5[_local4] = 0;
_local4++;
}
var _local8 = 0;
while (_local8 < 70) {
_local9 = _local9 + _local14;
_local10 = _local10 + _local13;
_local4 = 0;
while (_local4 < arrParticles.length) {
var _local7 = (_root[arrParticles[_local4]]._width / 2) + 7.5;
var _local3 = _root[arrParticles[_local4]]._x - _local9;
var _local2 = _root[arrParticles[_local4]]._y - _local10;
_local6 = Math.sqrt((_local3 * _local3) + (_local2 * _local2));
if (_local6 <= _local7) {
_local5[_local4] = 1;
}
_local4++;
}
_local8++;
}
_local4 = 0;
while (_local4 < _local5.length) {
if (_local5[_local4] == 1) {
_root[arrParticles[_local4]].ArrowsOn(arrowDepth, _root.projectile._x, _root.projectile._y);
} else {
_root[arrParticles[_local4]].ArrowsOff();
}
_local4++;
}
}
function TurnOffAllArrows() {
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].ArrowsOff();
_local2++;
}
}
function NextArrowDepth() {
arrowDepth++;
if (arrowDepth > 39999) {
arrowDepth = 15000;
}
}
function DrawLines() {
_root.clear();
_root.lineStyle(2, 16777215, 50);
var _local2 = new Object();
var _local3 = new Object();
_local2.x = _root.projectile._x;
_local2.y = _root.projectile._y;
_local3.x = _xmouse;
_local3.y = _ymouse;
_root.moveTo(_local2.x, _local2.y);
_root.lineTo(_local3.x, _local3.y);
}
function Shoot() {
if ((intState == 1) && (_global.latestLevel != -1)) {
trace("in");
_root.clear();
saveX = _root.projectile._x;
saveY = _root.projectile._y;
var _local4 = new Vector();
_local4._x = (Stage.width / 2) - _root.projectile._x;
_local4._y = (Stage.height / 2) - _root.projectile._y;
var _local5 = Math.atan2(_local4._y, _local4._x);
vecShootDir._x = Math.cos(_local5) * 11;
vecShootDir._y = Math.sin(_local5) * 11;
var _local3 = 100;
do {
if (ProjectileOffScreen() != false) {
break;
}
_root.projectile._x = _root.projectile._x - vecShootDir._x;
_root.projectile._y = _root.projectile._y - vecShootDir._y;
_local3--;
} while (_local3 != 0);
var _local6 = (360 * _local5) / (Math.PI*2);
_root.projectile.gotoAndStop(2);
_root.projectile._rotation = _local6;
_root.gameBackground.gotoAndPlay("hide");
TurnOffAllArrows();
intState = 2;
}
}
function ProjectileOffScreen() {
var _local2 = false;
if (((_root.projectile._x + _root.projectile._width) < 0) || ((_root.projectile._x - _root.projectile._width) > Stage.width)) {
_local2 = true;
}
if (((_root.projectile._y + _root.projectile._height) < 0) || ((_root.projectile._y - _root.projectile._height) > Stage.height)) {
_local2 = true;
}
return(_local2);
}
function MoveProjectilesAndCollide() {
var _local4 = 0;
while (_local4 < arrProjectiles.length) {
_root[arrProjectiles[_local4].name]._x = _root[arrProjectiles[_local4].name]._x + (arrProjectiles[_local4].dX / 2);
_root[arrProjectiles[_local4].name]._y = _root[arrProjectiles[_local4].name]._y + (arrProjectiles[_local4].dY / 2);
if (((_root[arrProjectiles[_local4].name]._x + _root[arrProjectiles[_local4].name]._width) < 0) || ((_root[arrProjectiles[_local4].name]._x - _root[arrProjectiles[_local4].name]._width) > Stage.width)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
if (((_root[arrProjectiles[_local4].name]._y + _root[arrProjectiles[_local4].name]._height) < 0) || ((_root[arrProjectiles[_local4].name]._y - _root[arrProjectiles[_local4].name]._height) > Stage.height)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
_local4++;
}
var _local5 = new Array();
var _local3 = 0;
while (_local3 < arrProjectiles.length) {
_local4 = 0;
while (_local4 < arrParticles.length) {
if (_root[arrParticles[_local4]].hitTest(_root[arrProjectiles[_local3].name]._x, _root[arrProjectiles[_local3].name]._y, true) == true) {
_local5.push({name:arrParticles[_local4], X:arrProjectiles[_local3].X, Y:arrProjectiles[_local3].Y});
arrParticles.splice(_local4, 1);
_local4--;
_root[arrProjectiles[_local3].name].removeMovieClip();
arrProjectiles.splice(_local3, 1);
_local3--;
}
_local4++;
}
_local3++;
}
_local4 = 0;
while (_local4 < _local5.length) {
_root[_local5[_local4].name].Collision(_local5[_local4].X, _local5[_local4].Y);
_root[_local5[_local4].name].gotoAndStop(2);
_local4++;
}
_local4 = 0;
while (_local4 < arrProjectiles.length) {
_root[arrProjectiles[_local4].name]._x = _root[arrProjectiles[_local4].name]._x + (arrProjectiles[_local4].dX / 2);
_root[arrProjectiles[_local4].name]._y = _root[arrProjectiles[_local4].name]._y + (arrProjectiles[_local4].dY / 2);
if (((_root[arrProjectiles[_local4].name]._x + _root[arrProjectiles[_local4].name]._width) < 0) || ((_root[arrProjectiles[_local4].name]._x - _root[arrProjectiles[_local4].name]._width) > Stage.width)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
if (((_root[arrProjectiles[_local4].name]._y + _root[arrProjectiles[_local4].name]._height) < 0) || ((_root[arrProjectiles[_local4].name]._y - _root[arrProjectiles[_local4].name]._height) > Stage.height)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
_local4++;
}
_local5 = new Array();
_local3 = 0;
while (_local3 < arrProjectiles.length) {
_local4 = 0;
while (_local4 < arrParticles.length) {
if (_root[arrParticles[_local4]].hitTest(_root[arrProjectiles[_local3].name]._x, _root[arrProjectiles[_local3].name]._y, true) == true) {
_local5.push({name:arrParticles[_local4], X:arrProjectiles[_local3].X, Y:arrProjectiles[_local3].Y});
arrParticles.splice(_local4, 1);
_local4--;
_root[arrProjectiles[_local3].name].removeMovieClip();
arrProjectiles.splice(_local3, 1);
_local3--;
}
_local4++;
}
_local3++;
}
_local4 = 0;
while (_local4 < _local5.length) {
_root[_local5[_local4].name].Collision(_local5[_local4].X, _local5[_local4].Y);
_root[_local5[_local4].name].gotoAndStop(2);
_local4++;
}
if ((arrProjectiles.length == 0) && (projectileOver == true)) {
if (arrParticles.length != 0) {
intState = 3;
_root.messages_mc.gotoAndPlay("retry");
} else {
intState = 4;
var _local10 = ((_global.currentLevel + 5) - 15) / 5;
_global.levels[_local10] = 1;
var _local9 = SharedObject.getLocal("userData");
_local9.data.levelsCompleted = _global.levels;
_global.SoundManager.PlaySound("all");
_root.messages_mc.gotoAndPlay("next");
}
}
}
function LaunchProjectile(deltaX, deltaY, startX, startY, rot) {
var _local2 = "projectile_" + projectileDepth;
arrProjectiles.push({name:_local2, dX:deltaX, dY:deltaY, X:startX, Y:startY});
_root.attachMovie("shootingStar", _local2, projectileDepth);
_root[_local2]._x = startX;
_root[_local2]._y = startY;
_root[_local2]._rotation = rot;
projectileDepth++;
if (projectileDepth > 9999) {
projectileDepth = 5000;
}
}
stop();
var intState = 1;
var vecShootDir;
var arrParticles = new Array();
var arrProjectiles = new Array();
var arrParticlesReset = new Array();
var particleDepth = 1000;
var projectileDepth = 5000;
var arrowDepth = 15000;
var saveX = 0;
var saveY = 0;
var projectileOnScreen = false;
var projectileOver = false;
var saveDepth;
mouseListener = new Object();
mouseListener.onMouseDown = function () {
_root.Shoot();
};
Mouse.addListener(mouseListener);
Frame 225
function GameSetup() {
trace("%%%%%%%%");
trace((_global.currentLevel + " ----- ") + _global.latestLevel);
if (_global.latestLevel == -1) {
_root.gotoAndPlay("splash");
} else if ((_global.latestLevel != 0) && (_global.latestLevel != 20)) {
_global.currentLevel = _global.latestLevel;
_root.gotoAndPlay(_global.latestLevel);
_global.latestLevel = 0;
trace("go here");
} else if ((_global.latestLevel != 0) && (_global.latestLevel == 20)) {
_global.currentLevel = _global.latestLevel;
_global.latestLevel = 0;
}
if (_root.messages_mc.getDepth() != 50000) {
saveDepth = _root.messages_mc.getDepth();
}
vecShootDir = new Vector();
if (_global.musicOn == true) {
_global.myMusicPlayer.SetTrack("game");
_global.myMusicPlayer.SetMaxVolume(40);
_global.myMusicPlayer.PlayWithCrossFade(4);
}
}
function Mediator() {
_global.myMusicPlayer.RunPlayer();
switch (intState) {
case 1 :
AimProjectile();
if (_root.messages_mc.getDepth() != 50000) {
_root.messages_mc.swapDepths(50000);
trace(_root.messages_mc.getDepth());
}
break;
case 2 :
if (projectileOver == false) {
MoveProjectile();
}
DetectParticleCollisions();
MoveProjectilesAndCollide();
break;
case 3 :
if (Key.isDown(32)) {
Reset();
}
break;
case 4 :
if (!Key.isDown(32)) {
break;
}
Next();
}
}
function Reset() {
projectileDepth = 5000;
arrParticles = arrParticlesReset.slice();
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].gotoAndStop(1);
trace(arrParticles[_local2]);
_local2++;
}
trace("-----");
_root.projectile.gotoAndStop(1);
_root.gameBackground.gotoAndStop(1);
_root.messages_mc.gotoAndStop("hide");
projectileOver = false;
projectileOnScreen = false;
intState = 1;
}
function ExitGame() {
CleanupGame();
Mouse.removeListener(mouseListener);
_root.messages_mc.swapDepths(saveDepth);
_global.latestLevel = -1;
_root.gotoAndPlay("level1");
}
function Next() {
_global.currentLevel = _global.currentLevel + 5;
CleanupGame();
_root.messages_mc.swapDepths(saveDepth);
_root.gotoAndPlay(_global.currentLevel);
}
function CleanupGame() {
Mouse.removeListener(mouseListener);
Reset();
var _local3 = 10;
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].swapDepths(_local3);
_local3++;
_root[arrParticles[_local2]].removeMovieClip();
_local2++;
}
delete arrParticles;
arrParticles = new Array();
}
function DetectParticleCollisions() {
var _local3 = new Array();
var _local2 = 0;
while (_local2 < arrParticles.length) {
var _local4 = (_root[arrParticles[_local2]]._width / 2) + 7.5;
if (GetDistance(arrParticles[_local2], "projectile") <= _local4) {
_root[arrParticles[_local2]].Collision(saveX, saveY);
_local3.push(arrParticles[_local2]);
}
_local2++;
}
_local2 = 0;
while (_local2 < _local3.length) {
RemoveParticle(_local3[_local2]);
_root[_local3[_local2]].gotoAndStop(2);
_local2++;
}
}
function RemoveParticle(strName) {
var _local1 = 0;
while (_local1 < arrParticles.length) {
if (strName == arrParticles[_local1]) {
arrParticles.splice(_local1, 1);
break;
}
_local1++;
}
}
function GetDistance(targetA, targetB) {
var _local3 = _root[targetB]._x - _root[targetA]._x;
var _local2 = _root[targetB]._y - _root[targetA]._y;
return(Math.sqrt((_local3 * _local3) + (_local2 * _local2)));
}
function RegisterParticle(particleName) {
arrParticles.push(particleName);
arrParticlesReset.push(particleName);
particleDepth++;
return(particleDepth);
}
function MoveProjectile() {
if (ProjectileOffScreen() == false) {
projectileOnScreen = true;
_root.projectile._x = _root.projectile._x + vecShootDir._x;
_root.projectile._y = _root.projectile._y + vecShootDir._y;
} else if (projectileOnScreen == true) {
projectileOver = true;
} else {
_root.projectile._x = _root.projectile._x + vecShootDir._x;
_root.projectile._y = _root.projectile._y + vecShootDir._y;
}
}
function AimProjectile() {
var _local11 = new Vector();
_local11._x = _xmouse - (Stage.width / 2);
_local11._y = _ymouse - (Stage.height / 2);
var _local12 = Math.atan2(_local11._y, _local11._x);
var _local15 = (360 * _local12) / (Math.PI*2);
var _local6 = _root.gameBackground._width / 2;
_root.projectile._x = (_local6 * Math.cos(_local12)) + (Stage.width / 2);
_root.projectile._y = (_local6 * Math.sin(_local12)) + (Stage.height / 2);
_local11._x = (Stage.width / 2) - _root.projectile._x;
_local11._y = (Stage.height / 2) - _root.projectile._y;
_local12 = Math.atan2(_local11._y, _local11._x);
var _local14 = Math.cos(_local12) * 11;
var _local13 = Math.sin(_local12) * 11;
var _local9 = _root.projectile._x;
var _local10 = _root.projectile._y;
var _local5 = new Array(arrParticles.length);
var _local4 = 0;
while (_local4 < _local5.length) {
_local5[_local4] = 0;
_local4++;
}
var _local8 = 0;
while (_local8 < 70) {
_local9 = _local9 + _local14;
_local10 = _local10 + _local13;
_local4 = 0;
while (_local4 < arrParticles.length) {
var _local7 = (_root[arrParticles[_local4]]._width / 2) + 7.5;
var _local3 = _root[arrParticles[_local4]]._x - _local9;
var _local2 = _root[arrParticles[_local4]]._y - _local10;
_local6 = Math.sqrt((_local3 * _local3) + (_local2 * _local2));
if (_local6 <= _local7) {
_local5[_local4] = 1;
}
_local4++;
}
_local8++;
}
_local4 = 0;
while (_local4 < _local5.length) {
if (_local5[_local4] == 1) {
_root[arrParticles[_local4]].ArrowsOn(arrowDepth, _root.projectile._x, _root.projectile._y);
} else {
_root[arrParticles[_local4]].ArrowsOff();
}
_local4++;
}
}
function TurnOffAllArrows() {
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].ArrowsOff();
_local2++;
}
}
function NextArrowDepth() {
arrowDepth++;
if (arrowDepth > 39999) {
arrowDepth = 15000;
}
}
function DrawLines() {
_root.clear();
_root.lineStyle(2, 16777215, 50);
var _local2 = new Object();
var _local3 = new Object();
_local2.x = _root.projectile._x;
_local2.y = _root.projectile._y;
_local3.x = _xmouse;
_local3.y = _ymouse;
_root.moveTo(_local2.x, _local2.y);
_root.lineTo(_local3.x, _local3.y);
}
function Shoot() {
if ((intState == 1) && (_global.latestLevel != -1)) {
trace("in");
_root.clear();
saveX = _root.projectile._x;
saveY = _root.projectile._y;
var _local4 = new Vector();
_local4._x = (Stage.width / 2) - _root.projectile._x;
_local4._y = (Stage.height / 2) - _root.projectile._y;
var _local5 = Math.atan2(_local4._y, _local4._x);
vecShootDir._x = Math.cos(_local5) * 11;
vecShootDir._y = Math.sin(_local5) * 11;
var _local3 = 100;
do {
if (ProjectileOffScreen() != false) {
break;
}
_root.projectile._x = _root.projectile._x - vecShootDir._x;
_root.projectile._y = _root.projectile._y - vecShootDir._y;
_local3--;
} while (_local3 != 0);
var _local6 = (360 * _local5) / (Math.PI*2);
_root.projectile.gotoAndStop(2);
_root.projectile._rotation = _local6;
_root.gameBackground.gotoAndPlay("hide");
TurnOffAllArrows();
intState = 2;
}
}
function ProjectileOffScreen() {
var _local2 = false;
if (((_root.projectile._x + _root.projectile._width) < 0) || ((_root.projectile._x - _root.projectile._width) > Stage.width)) {
_local2 = true;
}
if (((_root.projectile._y + _root.projectile._height) < 0) || ((_root.projectile._y - _root.projectile._height) > Stage.height)) {
_local2 = true;
}
return(_local2);
}
function MoveProjectilesAndCollide() {
var _local4 = 0;
while (_local4 < arrProjectiles.length) {
_root[arrProjectiles[_local4].name]._x = _root[arrProjectiles[_local4].name]._x + (arrProjectiles[_local4].dX / 2);
_root[arrProjectiles[_local4].name]._y = _root[arrProjectiles[_local4].name]._y + (arrProjectiles[_local4].dY / 2);
if (((_root[arrProjectiles[_local4].name]._x + _root[arrProjectiles[_local4].name]._width) < 0) || ((_root[arrProjectiles[_local4].name]._x - _root[arrProjectiles[_local4].name]._width) > Stage.width)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
if (((_root[arrProjectiles[_local4].name]._y + _root[arrProjectiles[_local4].name]._height) < 0) || ((_root[arrProjectiles[_local4].name]._y - _root[arrProjectiles[_local4].name]._height) > Stage.height)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
_local4++;
}
var _local5 = new Array();
var _local3 = 0;
while (_local3 < arrProjectiles.length) {
_local4 = 0;
while (_local4 < arrParticles.length) {
if (_root[arrParticles[_local4]].hitTest(_root[arrProjectiles[_local3].name]._x, _root[arrProjectiles[_local3].name]._y, true) == true) {
_local5.push({name:arrParticles[_local4], X:arrProjectiles[_local3].X, Y:arrProjectiles[_local3].Y});
arrParticles.splice(_local4, 1);
_local4--;
_root[arrProjectiles[_local3].name].removeMovieClip();
arrProjectiles.splice(_local3, 1);
_local3--;
}
_local4++;
}
_local3++;
}
_local4 = 0;
while (_local4 < _local5.length) {
_root[_local5[_local4].name].Collision(_local5[_local4].X, _local5[_local4].Y);
_root[_local5[_local4].name].gotoAndStop(2);
_local4++;
}
_local4 = 0;
while (_local4 < arrProjectiles.length) {
_root[arrProjectiles[_local4].name]._x = _root[arrProjectiles[_local4].name]._x + (arrProjectiles[_local4].dX / 2);
_root[arrProjectiles[_local4].name]._y = _root[arrProjectiles[_local4].name]._y + (arrProjectiles[_local4].dY / 2);
if (((_root[arrProjectiles[_local4].name]._x + _root[arrProjectiles[_local4].name]._width) < 0) || ((_root[arrProjectiles[_local4].name]._x - _root[arrProjectiles[_local4].name]._width) > Stage.width)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
if (((_root[arrProjectiles[_local4].name]._y + _root[arrProjectiles[_local4].name]._height) < 0) || ((_root[arrProjectiles[_local4].name]._y - _root[arrProjectiles[_local4].name]._height) > Stage.height)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
_local4++;
}
_local5 = new Array();
_local3 = 0;
while (_local3 < arrProjectiles.length) {
_local4 = 0;
while (_local4 < arrParticles.length) {
if (_root[arrParticles[_local4]].hitTest(_root[arrProjectiles[_local3].name]._x, _root[arrProjectiles[_local3].name]._y, true) == true) {
_local5.push({name:arrParticles[_local4], X:arrProjectiles[_local3].X, Y:arrProjectiles[_local3].Y});
arrParticles.splice(_local4, 1);
_local4--;
_root[arrProjectiles[_local3].name].removeMovieClip();
arrProjectiles.splice(_local3, 1);
_local3--;
}
_local4++;
}
_local3++;
}
_local4 = 0;
while (_local4 < _local5.length) {
_root[_local5[_local4].name].Collision(_local5[_local4].X, _local5[_local4].Y);
_root[_local5[_local4].name].gotoAndStop(2);
_local4++;
}
if ((arrProjectiles.length == 0) && (projectileOver == true)) {
if (arrParticles.length != 0) {
intState = 3;
_root.messages_mc.gotoAndPlay("retry");
} else {
intState = 4;
var _local10 = ((_global.currentLevel + 5) - 15) / 5;
_global.levels[_local10] = 1;
var _local9 = SharedObject.getLocal("userData");
_local9.data.levelsCompleted = _global.levels;
_global.SoundManager.PlaySound("all");
_root.messages_mc.gotoAndPlay("next");
}
}
}
function LaunchProjectile(deltaX, deltaY, startX, startY, rot) {
var _local2 = "projectile_" + projectileDepth;
arrProjectiles.push({name:_local2, dX:deltaX, dY:deltaY, X:startX, Y:startY});
_root.attachMovie("shootingStar", _local2, projectileDepth);
_root[_local2]._x = startX;
_root[_local2]._y = startY;
_root[_local2]._rotation = rot;
projectileDepth++;
if (projectileDepth > 9999) {
projectileDepth = 5000;
}
}
stop();
var intState = 1;
var vecShootDir;
var arrParticles = new Array();
var arrProjectiles = new Array();
var arrParticlesReset = new Array();
var particleDepth = 1000;
var projectileDepth = 5000;
var arrowDepth = 15000;
var saveX = 0;
var saveY = 0;
var projectileOnScreen = false;
var projectileOver = false;
var saveDepth;
mouseListener = new Object();
mouseListener.onMouseDown = function () {
_root.Shoot();
};
Mouse.addListener(mouseListener);
Frame 230
function GameSetup() {
trace("%%%%%%%%");
trace((_global.currentLevel + " ----- ") + _global.latestLevel);
if (_global.latestLevel == -1) {
_root.gotoAndPlay("splash");
} else if ((_global.latestLevel != 0) && (_global.latestLevel != 20)) {
_global.currentLevel = _global.latestLevel;
_root.gotoAndPlay(_global.latestLevel);
_global.latestLevel = 0;
trace("go here");
} else if ((_global.latestLevel != 0) && (_global.latestLevel == 20)) {
_global.currentLevel = _global.latestLevel;
_global.latestLevel = 0;
}
if (_root.messages_mc.getDepth() != 50000) {
saveDepth = _root.messages_mc.getDepth();
}
vecShootDir = new Vector();
if (_global.musicOn == true) {
_global.myMusicPlayer.SetTrack("game");
_global.myMusicPlayer.SetMaxVolume(40);
_global.myMusicPlayer.PlayWithCrossFade(4);
}
}
function Mediator() {
_global.myMusicPlayer.RunPlayer();
switch (intState) {
case 1 :
AimProjectile();
if (_root.messages_mc.getDepth() != 50000) {
_root.messages_mc.swapDepths(50000);
trace(_root.messages_mc.getDepth());
}
break;
case 2 :
if (projectileOver == false) {
MoveProjectile();
}
DetectParticleCollisions();
MoveProjectilesAndCollide();
break;
case 3 :
if (Key.isDown(32)) {
Reset();
}
break;
case 4 :
if (!Key.isDown(32)) {
break;
}
Next();
}
}
function Reset() {
projectileDepth = 5000;
arrParticles = arrParticlesReset.slice();
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].gotoAndStop(1);
trace(arrParticles[_local2]);
_local2++;
}
trace("-----");
_root.projectile.gotoAndStop(1);
_root.gameBackground.gotoAndStop(1);
_root.messages_mc.gotoAndStop("hide");
projectileOver = false;
projectileOnScreen = false;
intState = 1;
}
function ExitGame() {
CleanupGame();
Mouse.removeListener(mouseListener);
_root.messages_mc.swapDepths(saveDepth);
_global.latestLevel = -1;
_root.gotoAndPlay("level1");
}
function Next() {
_global.currentLevel = _global.currentLevel + 5;
CleanupGame();
_root.messages_mc.swapDepths(saveDepth);
_root.gotoAndPlay(_global.currentLevel);
}
function CleanupGame() {
Mouse.removeListener(mouseListener);
Reset();
var _local3 = 10;
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].swapDepths(_local3);
_local3++;
_root[arrParticles[_local2]].removeMovieClip();
_local2++;
}
delete arrParticles;
arrParticles = new Array();
}
function DetectParticleCollisions() {
var _local3 = new Array();
var _local2 = 0;
while (_local2 < arrParticles.length) {
var _local4 = (_root[arrParticles[_local2]]._width / 2) + 7.5;
if (GetDistance(arrParticles[_local2], "projectile") <= _local4) {
_root[arrParticles[_local2]].Collision(saveX, saveY);
_local3.push(arrParticles[_local2]);
}
_local2++;
}
_local2 = 0;
while (_local2 < _local3.length) {
RemoveParticle(_local3[_local2]);
_root[_local3[_local2]].gotoAndStop(2);
_local2++;
}
}
function RemoveParticle(strName) {
var _local1 = 0;
while (_local1 < arrParticles.length) {
if (strName == arrParticles[_local1]) {
arrParticles.splice(_local1, 1);
break;
}
_local1++;
}
}
function GetDistance(targetA, targetB) {
var _local3 = _root[targetB]._x - _root[targetA]._x;
var _local2 = _root[targetB]._y - _root[targetA]._y;
return(Math.sqrt((_local3 * _local3) + (_local2 * _local2)));
}
function RegisterParticle(particleName) {
arrParticles.push(particleName);
arrParticlesReset.push(particleName);
particleDepth++;
return(particleDepth);
}
function MoveProjectile() {
if (ProjectileOffScreen() == false) {
projectileOnScreen = true;
_root.projectile._x = _root.projectile._x + vecShootDir._x;
_root.projectile._y = _root.projectile._y + vecShootDir._y;
} else if (projectileOnScreen == true) {
projectileOver = true;
} else {
_root.projectile._x = _root.projectile._x + vecShootDir._x;
_root.projectile._y = _root.projectile._y + vecShootDir._y;
}
}
function AimProjectile() {
var _local11 = new Vector();
_local11._x = _xmouse - (Stage.width / 2);
_local11._y = _ymouse - (Stage.height / 2);
var _local12 = Math.atan2(_local11._y, _local11._x);
var _local15 = (360 * _local12) / (Math.PI*2);
var _local6 = _root.gameBackground._width / 2;
_root.projectile._x = (_local6 * Math.cos(_local12)) + (Stage.width / 2);
_root.projectile._y = (_local6 * Math.sin(_local12)) + (Stage.height / 2);
_local11._x = (Stage.width / 2) - _root.projectile._x;
_local11._y = (Stage.height / 2) - _root.projectile._y;
_local12 = Math.atan2(_local11._y, _local11._x);
var _local14 = Math.cos(_local12) * 11;
var _local13 = Math.sin(_local12) * 11;
var _local9 = _root.projectile._x;
var _local10 = _root.projectile._y;
var _local5 = new Array(arrParticles.length);
var _local4 = 0;
while (_local4 < _local5.length) {
_local5[_local4] = 0;
_local4++;
}
var _local8 = 0;
while (_local8 < 70) {
_local9 = _local9 + _local14;
_local10 = _local10 + _local13;
_local4 = 0;
while (_local4 < arrParticles.length) {
var _local7 = (_root[arrParticles[_local4]]._width / 2) + 7.5;
var _local3 = _root[arrParticles[_local4]]._x - _local9;
var _local2 = _root[arrParticles[_local4]]._y - _local10;
_local6 = Math.sqrt((_local3 * _local3) + (_local2 * _local2));
if (_local6 <= _local7) {
_local5[_local4] = 1;
}
_local4++;
}
_local8++;
}
_local4 = 0;
while (_local4 < _local5.length) {
if (_local5[_local4] == 1) {
_root[arrParticles[_local4]].ArrowsOn(arrowDepth, _root.projectile._x, _root.projectile._y);
} else {
_root[arrParticles[_local4]].ArrowsOff();
}
_local4++;
}
}
function TurnOffAllArrows() {
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].ArrowsOff();
_local2++;
}
}
function NextArrowDepth() {
arrowDepth++;
if (arrowDepth > 39999) {
arrowDepth = 15000;
}
}
function DrawLines() {
_root.clear();
_root.lineStyle(2, 16777215, 50);
var _local2 = new Object();
var _local3 = new Object();
_local2.x = _root.projectile._x;
_local2.y = _root.projectile._y;
_local3.x = _xmouse;
_local3.y = _ymouse;
_root.moveTo(_local2.x, _local2.y);
_root.lineTo(_local3.x, _local3.y);
}
function Shoot() {
if ((intState == 1) && (_global.latestLevel != -1)) {
trace("in");
_root.clear();
saveX = _root.projectile._x;
saveY = _root.projectile._y;
var _local4 = new Vector();
_local4._x = (Stage.width / 2) - _root.projectile._x;
_local4._y = (Stage.height / 2) - _root.projectile._y;
var _local5 = Math.atan2(_local4._y, _local4._x);
vecShootDir._x = Math.cos(_local5) * 11;
vecShootDir._y = Math.sin(_local5) * 11;
var _local3 = 100;
do {
if (ProjectileOffScreen() != false) {
break;
}
_root.projectile._x = _root.projectile._x - vecShootDir._x;
_root.projectile._y = _root.projectile._y - vecShootDir._y;
_local3--;
} while (_local3 != 0);
var _local6 = (360 * _local5) / (Math.PI*2);
_root.projectile.gotoAndStop(2);
_root.projectile._rotation = _local6;
_root.gameBackground.gotoAndPlay("hide");
TurnOffAllArrows();
intState = 2;
}
}
function ProjectileOffScreen() {
var _local2 = false;
if (((_root.projectile._x + _root.projectile._width) < 0) || ((_root.projectile._x - _root.projectile._width) > Stage.width)) {
_local2 = true;
}
if (((_root.projectile._y + _root.projectile._height) < 0) || ((_root.projectile._y - _root.projectile._height) > Stage.height)) {
_local2 = true;
}
return(_local2);
}
function MoveProjectilesAndCollide() {
var _local4 = 0;
while (_local4 < arrProjectiles.length) {
_root[arrProjectiles[_local4].name]._x = _root[arrProjectiles[_local4].name]._x + (arrProjectiles[_local4].dX / 2);
_root[arrProjectiles[_local4].name]._y = _root[arrProjectiles[_local4].name]._y + (arrProjectiles[_local4].dY / 2);
if (((_root[arrProjectiles[_local4].name]._x + _root[arrProjectiles[_local4].name]._width) < 0) || ((_root[arrProjectiles[_local4].name]._x - _root[arrProjectiles[_local4].name]._width) > Stage.width)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
if (((_root[arrProjectiles[_local4].name]._y + _root[arrProjectiles[_local4].name]._height) < 0) || ((_root[arrProjectiles[_local4].name]._y - _root[arrProjectiles[_local4].name]._height) > Stage.height)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
_local4++;
}
var _local5 = new Array();
var _local3 = 0;
while (_local3 < arrProjectiles.length) {
_local4 = 0;
while (_local4 < arrParticles.length) {
if (_root[arrParticles[_local4]].hitTest(_root[arrProjectiles[_local3].name]._x, _root[arrProjectiles[_local3].name]._y, true) == true) {
_local5.push({name:arrParticles[_local4], X:arrProjectiles[_local3].X, Y:arrProjectiles[_local3].Y});
arrParticles.splice(_local4, 1);
_local4--;
_root[arrProjectiles[_local3].name].removeMovieClip();
arrProjectiles.splice(_local3, 1);
_local3--;
}
_local4++;
}
_local3++;
}
_local4 = 0;
while (_local4 < _local5.length) {
_root[_local5[_local4].name].Collision(_local5[_local4].X, _local5[_local4].Y);
_root[_local5[_local4].name].gotoAndStop(2);
_local4++;
}
_local4 = 0;
while (_local4 < arrProjectiles.length) {
_root[arrProjectiles[_local4].name]._x = _root[arrProjectiles[_local4].name]._x + (arrProjectiles[_local4].dX / 2);
_root[arrProjectiles[_local4].name]._y = _root[arrProjectiles[_local4].name]._y + (arrProjectiles[_local4].dY / 2);
if (((_root[arrProjectiles[_local4].name]._x + _root[arrProjectiles[_local4].name]._width) < 0) || ((_root[arrProjectiles[_local4].name]._x - _root[arrProjectiles[_local4].name]._width) > Stage.width)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
if (((_root[arrProjectiles[_local4].name]._y + _root[arrProjectiles[_local4].name]._height) < 0) || ((_root[arrProjectiles[_local4].name]._y - _root[arrProjectiles[_local4].name]._height) > Stage.height)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
_local4++;
}
_local5 = new Array();
_local3 = 0;
while (_local3 < arrProjectiles.length) {
_local4 = 0;
while (_local4 < arrParticles.length) {
if (_root[arrParticles[_local4]].hitTest(_root[arrProjectiles[_local3].name]._x, _root[arrProjectiles[_local3].name]._y, true) == true) {
_local5.push({name:arrParticles[_local4], X:arrProjectiles[_local3].X, Y:arrProjectiles[_local3].Y});
arrParticles.splice(_local4, 1);
_local4--;
_root[arrProjectiles[_local3].name].removeMovieClip();
arrProjectiles.splice(_local3, 1);
_local3--;
}
_local4++;
}
_local3++;
}
_local4 = 0;
while (_local4 < _local5.length) {
_root[_local5[_local4].name].Collision(_local5[_local4].X, _local5[_local4].Y);
_root[_local5[_local4].name].gotoAndStop(2);
_local4++;
}
if ((arrProjectiles.length == 0) && (projectileOver == true)) {
if (arrParticles.length != 0) {
intState = 3;
_root.messages_mc.gotoAndPlay("retry");
} else {
intState = 4;
var _local10 = ((_global.currentLevel + 5) - 15) / 5;
_global.levels[_local10] = 1;
var _local9 = SharedObject.getLocal("userData");
_local9.data.levelsCompleted = _global.levels;
_global.SoundManager.PlaySound("all");
_root.messages_mc.gotoAndPlay("next");
}
}
}
function LaunchProjectile(deltaX, deltaY, startX, startY, rot) {
var _local2 = "projectile_" + projectileDepth;
arrProjectiles.push({name:_local2, dX:deltaX, dY:deltaY, X:startX, Y:startY});
_root.attachMovie("shootingStar", _local2, projectileDepth);
_root[_local2]._x = startX;
_root[_local2]._y = startY;
_root[_local2]._rotation = rot;
projectileDepth++;
if (projectileDepth > 9999) {
projectileDepth = 5000;
}
}
stop();
var intState = 1;
var vecShootDir;
var arrParticles = new Array();
var arrProjectiles = new Array();
var arrParticlesReset = new Array();
var particleDepth = 1000;
var projectileDepth = 5000;
var arrowDepth = 15000;
var saveX = 0;
var saveY = 0;
var projectileOnScreen = false;
var projectileOver = false;
var saveDepth;
mouseListener = new Object();
mouseListener.onMouseDown = function () {
_root.Shoot();
};
Mouse.addListener(mouseListener);
Frame 235
function GameSetup() {
trace("%%%%%%%%");
trace((_global.currentLevel + " ----- ") + _global.latestLevel);
if (_global.latestLevel == -1) {
_root.gotoAndPlay("splash");
} else if ((_global.latestLevel != 0) && (_global.latestLevel != 20)) {
_global.currentLevel = _global.latestLevel;
_root.gotoAndPlay(_global.latestLevel);
_global.latestLevel = 0;
trace("go here");
} else if ((_global.latestLevel != 0) && (_global.latestLevel == 20)) {
_global.currentLevel = _global.latestLevel;
_global.latestLevel = 0;
}
if (_root.messages_mc.getDepth() != 50000) {
saveDepth = _root.messages_mc.getDepth();
}
vecShootDir = new Vector();
if (_global.musicOn == true) {
_global.myMusicPlayer.SetTrack("game");
_global.myMusicPlayer.SetMaxVolume(40);
_global.myMusicPlayer.PlayWithCrossFade(4);
}
}
function Mediator() {
_global.myMusicPlayer.RunPlayer();
switch (intState) {
case 1 :
AimProjectile();
if (_root.messages_mc.getDepth() != 50000) {
_root.messages_mc.swapDepths(50000);
trace(_root.messages_mc.getDepth());
}
break;
case 2 :
if (projectileOver == false) {
MoveProjectile();
}
DetectParticleCollisions();
MoveProjectilesAndCollide();
break;
case 3 :
if (Key.isDown(32)) {
Reset();
}
break;
case 4 :
if (!Key.isDown(32)) {
break;
}
Next();
}
}
function Reset() {
projectileDepth = 5000;
arrParticles = arrParticlesReset.slice();
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].gotoAndStop(1);
trace(arrParticles[_local2]);
_local2++;
}
trace("-----");
_root.projectile.gotoAndStop(1);
_root.gameBackground.gotoAndStop(1);
_root.messages_mc.gotoAndStop("hide");
projectileOver = false;
projectileOnScreen = false;
intState = 1;
}
function ExitGame() {
CleanupGame();
Mouse.removeListener(mouseListener);
_root.messages_mc.swapDepths(saveDepth);
_global.latestLevel = -1;
_root.gotoAndPlay("level1");
}
function Next() {
_global.currentLevel = _global.currentLevel + 5;
CleanupGame();
_root.messages_mc.swapDepths(saveDepth);
_root.gotoAndPlay(_global.currentLevel);
}
function CleanupGame() {
Mouse.removeListener(mouseListener);
Reset();
var _local3 = 10;
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].swapDepths(_local3);
_local3++;
_root[arrParticles[_local2]].removeMovieClip();
_local2++;
}
delete arrParticles;
arrParticles = new Array();
}
function DetectParticleCollisions() {
var _local3 = new Array();
var _local2 = 0;
while (_local2 < arrParticles.length) {
var _local4 = (_root[arrParticles[_local2]]._width / 2) + 7.5;
if (GetDistance(arrParticles[_local2], "projectile") <= _local4) {
_root[arrParticles[_local2]].Collision(saveX, saveY);
_local3.push(arrParticles[_local2]);
}
_local2++;
}
_local2 = 0;
while (_local2 < _local3.length) {
RemoveParticle(_local3[_local2]);
_root[_local3[_local2]].gotoAndStop(2);
_local2++;
}
}
function RemoveParticle(strName) {
var _local1 = 0;
while (_local1 < arrParticles.length) {
if (strName == arrParticles[_local1]) {
arrParticles.splice(_local1, 1);
break;
}
_local1++;
}
}
function GetDistance(targetA, targetB) {
var _local3 = _root[targetB]._x - _root[targetA]._x;
var _local2 = _root[targetB]._y - _root[targetA]._y;
return(Math.sqrt((_local3 * _local3) + (_local2 * _local2)));
}
function RegisterParticle(particleName) {
arrParticles.push(particleName);
arrParticlesReset.push(particleName);
particleDepth++;
return(particleDepth);
}
function MoveProjectile() {
if (ProjectileOffScreen() == false) {
projectileOnScreen = true;
_root.projectile._x = _root.projectile._x + vecShootDir._x;
_root.projectile._y = _root.projectile._y + vecShootDir._y;
} else if (projectileOnScreen == true) {
projectileOver = true;
} else {
_root.projectile._x = _root.projectile._x + vecShootDir._x;
_root.projectile._y = _root.projectile._y + vecShootDir._y;
}
}
function AimProjectile() {
var _local11 = new Vector();
_local11._x = _xmouse - (Stage.width / 2);
_local11._y = _ymouse - (Stage.height / 2);
var _local12 = Math.atan2(_local11._y, _local11._x);
var _local15 = (360 * _local12) / (Math.PI*2);
var _local6 = _root.gameBackground._width / 2;
_root.projectile._x = (_local6 * Math.cos(_local12)) + (Stage.width / 2);
_root.projectile._y = (_local6 * Math.sin(_local12)) + (Stage.height / 2);
_local11._x = (Stage.width / 2) - _root.projectile._x;
_local11._y = (Stage.height / 2) - _root.projectile._y;
_local12 = Math.atan2(_local11._y, _local11._x);
var _local14 = Math.cos(_local12) * 11;
var _local13 = Math.sin(_local12) * 11;
var _local9 = _root.projectile._x;
var _local10 = _root.projectile._y;
var _local5 = new Array(arrParticles.length);
var _local4 = 0;
while (_local4 < _local5.length) {
_local5[_local4] = 0;
_local4++;
}
var _local8 = 0;
while (_local8 < 70) {
_local9 = _local9 + _local14;
_local10 = _local10 + _local13;
_local4 = 0;
while (_local4 < arrParticles.length) {
var _local7 = (_root[arrParticles[_local4]]._width / 2) + 7.5;
var _local3 = _root[arrParticles[_local4]]._x - _local9;
var _local2 = _root[arrParticles[_local4]]._y - _local10;
_local6 = Math.sqrt((_local3 * _local3) + (_local2 * _local2));
if (_local6 <= _local7) {
_local5[_local4] = 1;
}
_local4++;
}
_local8++;
}
_local4 = 0;
while (_local4 < _local5.length) {
if (_local5[_local4] == 1) {
_root[arrParticles[_local4]].ArrowsOn(arrowDepth, _root.projectile._x, _root.projectile._y);
} else {
_root[arrParticles[_local4]].ArrowsOff();
}
_local4++;
}
}
function TurnOffAllArrows() {
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].ArrowsOff();
_local2++;
}
}
function NextArrowDepth() {
arrowDepth++;
if (arrowDepth > 39999) {
arrowDepth = 15000;
}
}
function DrawLines() {
_root.clear();
_root.lineStyle(2, 16777215, 50);
var _local2 = new Object();
var _local3 = new Object();
_local2.x = _root.projectile._x;
_local2.y = _root.projectile._y;
_local3.x = _xmouse;
_local3.y = _ymouse;
_root.moveTo(_local2.x, _local2.y);
_root.lineTo(_local3.x, _local3.y);
}
function Shoot() {
if ((intState == 1) && (_global.latestLevel != -1)) {
trace("in");
_root.clear();
saveX = _root.projectile._x;
saveY = _root.projectile._y;
var _local4 = new Vector();
_local4._x = (Stage.width / 2) - _root.projectile._x;
_local4._y = (Stage.height / 2) - _root.projectile._y;
var _local5 = Math.atan2(_local4._y, _local4._x);
vecShootDir._x = Math.cos(_local5) * 11;
vecShootDir._y = Math.sin(_local5) * 11;
var _local3 = 100;
do {
if (ProjectileOffScreen() != false) {
break;
}
_root.projectile._x = _root.projectile._x - vecShootDir._x;
_root.projectile._y = _root.projectile._y - vecShootDir._y;
_local3--;
} while (_local3 != 0);
var _local6 = (360 * _local5) / (Math.PI*2);
_root.projectile.gotoAndStop(2);
_root.projectile._rotation = _local6;
_root.gameBackground.gotoAndPlay("hide");
TurnOffAllArrows();
intState = 2;
}
}
function ProjectileOffScreen() {
var _local2 = false;
if (((_root.projectile._x + _root.projectile._width) < 0) || ((_root.projectile._x - _root.projectile._width) > Stage.width)) {
_local2 = true;
}
if (((_root.projectile._y + _root.projectile._height) < 0) || ((_root.projectile._y - _root.projectile._height) > Stage.height)) {
_local2 = true;
}
return(_local2);
}
function MoveProjectilesAndCollide() {
var _local4 = 0;
while (_local4 < arrProjectiles.length) {
_root[arrProjectiles[_local4].name]._x = _root[arrProjectiles[_local4].name]._x + (arrProjectiles[_local4].dX / 2);
_root[arrProjectiles[_local4].name]._y = _root[arrProjectiles[_local4].name]._y + (arrProjectiles[_local4].dY / 2);
if (((_root[arrProjectiles[_local4].name]._x + _root[arrProjectiles[_local4].name]._width) < 0) || ((_root[arrProjectiles[_local4].name]._x - _root[arrProjectiles[_local4].name]._width) > Stage.width)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
if (((_root[arrProjectiles[_local4].name]._y + _root[arrProjectiles[_local4].name]._height) < 0) || ((_root[arrProjectiles[_local4].name]._y - _root[arrProjectiles[_local4].name]._height) > Stage.height)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
_local4++;
}
var _local5 = new Array();
var _local3 = 0;
while (_local3 < arrProjectiles.length) {
_local4 = 0;
while (_local4 < arrParticles.length) {
if (_root[arrParticles[_local4]].hitTest(_root[arrProjectiles[_local3].name]._x, _root[arrProjectiles[_local3].name]._y, true) == true) {
_local5.push({name:arrParticles[_local4], X:arrProjectiles[_local3].X, Y:arrProjectiles[_local3].Y});
arrParticles.splice(_local4, 1);
_local4--;
_root[arrProjectiles[_local3].name].removeMovieClip();
arrProjectiles.splice(_local3, 1);
_local3--;
}
_local4++;
}
_local3++;
}
_local4 = 0;
while (_local4 < _local5.length) {
_root[_local5[_local4].name].Collision(_local5[_local4].X, _local5[_local4].Y);
_root[_local5[_local4].name].gotoAndStop(2);
_local4++;
}
_local4 = 0;
while (_local4 < arrProjectiles.length) {
_root[arrProjectiles[_local4].name]._x = _root[arrProjectiles[_local4].name]._x + (arrProjectiles[_local4].dX / 2);
_root[arrProjectiles[_local4].name]._y = _root[arrProjectiles[_local4].name]._y + (arrProjectiles[_local4].dY / 2);
if (((_root[arrProjectiles[_local4].name]._x + _root[arrProjectiles[_local4].name]._width) < 0) || ((_root[arrProjectiles[_local4].name]._x - _root[arrProjectiles[_local4].name]._width) > Stage.width)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
if (((_root[arrProjectiles[_local4].name]._y + _root[arrProjectiles[_local4].name]._height) < 0) || ((_root[arrProjectiles[_local4].name]._y - _root[arrProjectiles[_local4].name]._height) > Stage.height)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
_local4++;
}
_local5 = new Array();
_local3 = 0;
while (_local3 < arrProjectiles.length) {
_local4 = 0;
while (_local4 < arrParticles.length) {
if (_root[arrParticles[_local4]].hitTest(_root[arrProjectiles[_local3].name]._x, _root[arrProjectiles[_local3].name]._y, true) == true) {
_local5.push({name:arrParticles[_local4], X:arrProjectiles[_local3].X, Y:arrProjectiles[_local3].Y});
arrParticles.splice(_local4, 1);
_local4--;
_root[arrProjectiles[_local3].name].removeMovieClip();
arrProjectiles.splice(_local3, 1);
_local3--;
}
_local4++;
}
_local3++;
}
_local4 = 0;
while (_local4 < _local5.length) {
_root[_local5[_local4].name].Collision(_local5[_local4].X, _local5[_local4].Y);
_root[_local5[_local4].name].gotoAndStop(2);
_local4++;
}
if ((arrProjectiles.length == 0) && (projectileOver == true)) {
if (arrParticles.length != 0) {
intState = 3;
_root.messages_mc.gotoAndPlay("retry");
} else {
intState = 4;
var _local10 = ((_global.currentLevel + 5) - 15) / 5;
_global.levels[_local10] = 1;
var _local9 = SharedObject.getLocal("userData");
_local9.data.levelsCompleted = _global.levels;
_global.SoundManager.PlaySound("all");
_root.messages_mc.gotoAndPlay("next");
}
}
}
function LaunchProjectile(deltaX, deltaY, startX, startY, rot) {
var _local2 = "projectile_" + projectileDepth;
arrProjectiles.push({name:_local2, dX:deltaX, dY:deltaY, X:startX, Y:startY});
_root.attachMovie("shootingStar", _local2, projectileDepth);
_root[_local2]._x = startX;
_root[_local2]._y = startY;
_root[_local2]._rotation = rot;
projectileDepth++;
if (projectileDepth > 9999) {
projectileDepth = 5000;
}
}
stop();
var intState = 1;
var vecShootDir;
var arrParticles = new Array();
var arrProjectiles = new Array();
var arrParticlesReset = new Array();
var particleDepth = 1000;
var projectileDepth = 5000;
var arrowDepth = 15000;
var saveX = 0;
var saveY = 0;
var projectileOnScreen = false;
var projectileOver = false;
var saveDepth;
mouseListener = new Object();
mouseListener.onMouseDown = function () {
_root.Shoot();
};
Mouse.addListener(mouseListener);
Frame 240
function GameSetup() {
trace("%%%%%%%%");
trace((_global.currentLevel + " ----- ") + _global.latestLevel);
if (_global.latestLevel == -1) {
_root.gotoAndPlay("splash");
} else if ((_global.latestLevel != 0) && (_global.latestLevel != 20)) {
_global.currentLevel = _global.latestLevel;
_root.gotoAndPlay(_global.latestLevel);
_global.latestLevel = 0;
trace("go here");
} else if ((_global.latestLevel != 0) && (_global.latestLevel == 20)) {
_global.currentLevel = _global.latestLevel;
_global.latestLevel = 0;
}
if (_root.messages_mc.getDepth() != 50000) {
saveDepth = _root.messages_mc.getDepth();
}
vecShootDir = new Vector();
if (_global.musicOn == true) {
_global.myMusicPlayer.SetTrack("game");
_global.myMusicPlayer.SetMaxVolume(40);
_global.myMusicPlayer.PlayWithCrossFade(4);
}
}
function Mediator() {
_global.myMusicPlayer.RunPlayer();
switch (intState) {
case 1 :
AimProjectile();
if (_root.messages_mc.getDepth() != 50000) {
_root.messages_mc.swapDepths(50000);
trace(_root.messages_mc.getDepth());
}
break;
case 2 :
if (projectileOver == false) {
MoveProjectile();
}
DetectParticleCollisions();
MoveProjectilesAndCollide();
break;
case 3 :
if (Key.isDown(32)) {
Reset();
}
break;
case 4 :
if (!Key.isDown(32)) {
break;
}
Next();
}
}
function Reset() {
projectileDepth = 5000;
arrParticles = arrParticlesReset.slice();
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].gotoAndStop(1);
trace(arrParticles[_local2]);
_local2++;
}
trace("-----");
_root.projectile.gotoAndStop(1);
_root.gameBackground.gotoAndStop(1);
_root.messages_mc.gotoAndStop("hide");
projectileOver = false;
projectileOnScreen = false;
intState = 1;
}
function ExitGame() {
CleanupGame();
Mouse.removeListener(mouseListener);
_root.messages_mc.swapDepths(saveDepth);
_global.latestLevel = -1;
_root.gotoAndPlay("level1");
}
function Next() {
_global.currentLevel = _global.currentLevel + 5;
CleanupGame();
_root.messages_mc.swapDepths(saveDepth);
_root.gotoAndPlay(_global.currentLevel);
}
function CleanupGame() {
Mouse.removeListener(mouseListener);
Reset();
var _local3 = 10;
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].swapDepths(_local3);
_local3++;
_root[arrParticles[_local2]].removeMovieClip();
_local2++;
}
delete arrParticles;
arrParticles = new Array();
}
function DetectParticleCollisions() {
var _local3 = new Array();
var _local2 = 0;
while (_local2 < arrParticles.length) {
var _local4 = (_root[arrParticles[_local2]]._width / 2) + 7.5;
if (GetDistance(arrParticles[_local2], "projectile") <= _local4) {
_root[arrParticles[_local2]].Collision(saveX, saveY);
_local3.push(arrParticles[_local2]);
}
_local2++;
}
_local2 = 0;
while (_local2 < _local3.length) {
RemoveParticle(_local3[_local2]);
_root[_local3[_local2]].gotoAndStop(2);
_local2++;
}
}
function RemoveParticle(strName) {
var _local1 = 0;
while (_local1 < arrParticles.length) {
if (strName == arrParticles[_local1]) {
arrParticles.splice(_local1, 1);
break;
}
_local1++;
}
}
function GetDistance(targetA, targetB) {
var _local3 = _root[targetB]._x - _root[targetA]._x;
var _local2 = _root[targetB]._y - _root[targetA]._y;
return(Math.sqrt((_local3 * _local3) + (_local2 * _local2)));
}
function RegisterParticle(particleName) {
arrParticles.push(particleName);
arrParticlesReset.push(particleName);
particleDepth++;
return(particleDepth);
}
function MoveProjectile() {
if (ProjectileOffScreen() == false) {
projectileOnScreen = true;
_root.projectile._x = _root.projectile._x + vecShootDir._x;
_root.projectile._y = _root.projectile._y + vecShootDir._y;
} else if (projectileOnScreen == true) {
projectileOver = true;
} else {
_root.projectile._x = _root.projectile._x + vecShootDir._x;
_root.projectile._y = _root.projectile._y + vecShootDir._y;
}
}
function AimProjectile() {
var _local11 = new Vector();
_local11._x = _xmouse - (Stage.width / 2);
_local11._y = _ymouse - (Stage.height / 2);
var _local12 = Math.atan2(_local11._y, _local11._x);
var _local15 = (360 * _local12) / (Math.PI*2);
var _local6 = _root.gameBackground._width / 2;
_root.projectile._x = (_local6 * Math.cos(_local12)) + (Stage.width / 2);
_root.projectile._y = (_local6 * Math.sin(_local12)) + (Stage.height / 2);
_local11._x = (Stage.width / 2) - _root.projectile._x;
_local11._y = (Stage.height / 2) - _root.projectile._y;
_local12 = Math.atan2(_local11._y, _local11._x);
var _local14 = Math.cos(_local12) * 11;
var _local13 = Math.sin(_local12) * 11;
var _local9 = _root.projectile._x;
var _local10 = _root.projectile._y;
var _local5 = new Array(arrParticles.length);
var _local4 = 0;
while (_local4 < _local5.length) {
_local5[_local4] = 0;
_local4++;
}
var _local8 = 0;
while (_local8 < 70) {
_local9 = _local9 + _local14;
_local10 = _local10 + _local13;
_local4 = 0;
while (_local4 < arrParticles.length) {
var _local7 = (_root[arrParticles[_local4]]._width / 2) + 7.5;
var _local3 = _root[arrParticles[_local4]]._x - _local9;
var _local2 = _root[arrParticles[_local4]]._y - _local10;
_local6 = Math.sqrt((_local3 * _local3) + (_local2 * _local2));
if (_local6 <= _local7) {
_local5[_local4] = 1;
}
_local4++;
}
_local8++;
}
_local4 = 0;
while (_local4 < _local5.length) {
if (_local5[_local4] == 1) {
_root[arrParticles[_local4]].ArrowsOn(arrowDepth, _root.projectile._x, _root.projectile._y);
} else {
_root[arrParticles[_local4]].ArrowsOff();
}
_local4++;
}
}
function TurnOffAllArrows() {
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].ArrowsOff();
_local2++;
}
}
function NextArrowDepth() {
arrowDepth++;
if (arrowDepth > 39999) {
arrowDepth = 15000;
}
}
function DrawLines() {
_root.clear();
_root.lineStyle(2, 16777215, 50);
var _local2 = new Object();
var _local3 = new Object();
_local2.x = _root.projectile._x;
_local2.y = _root.projectile._y;
_local3.x = _xmouse;
_local3.y = _ymouse;
_root.moveTo(_local2.x, _local2.y);
_root.lineTo(_local3.x, _local3.y);
}
function Shoot() {
if ((intState == 1) && (_global.latestLevel != -1)) {
trace("in");
_root.clear();
saveX = _root.projectile._x;
saveY = _root.projectile._y;
var _local4 = new Vector();
_local4._x = (Stage.width / 2) - _root.projectile._x;
_local4._y = (Stage.height / 2) - _root.projectile._y;
var _local5 = Math.atan2(_local4._y, _local4._x);
vecShootDir._x = Math.cos(_local5) * 11;
vecShootDir._y = Math.sin(_local5) * 11;
var _local3 = 100;
do {
if (ProjectileOffScreen() != false) {
break;
}
_root.projectile._x = _root.projectile._x - vecShootDir._x;
_root.projectile._y = _root.projectile._y - vecShootDir._y;
_local3--;
} while (_local3 != 0);
var _local6 = (360 * _local5) / (Math.PI*2);
_root.projectile.gotoAndStop(2);
_root.projectile._rotation = _local6;
_root.gameBackground.gotoAndPlay("hide");
TurnOffAllArrows();
intState = 2;
}
}
function ProjectileOffScreen() {
var _local2 = false;
if (((_root.projectile._x + _root.projectile._width) < 0) || ((_root.projectile._x - _root.projectile._width) > Stage.width)) {
_local2 = true;
}
if (((_root.projectile._y + _root.projectile._height) < 0) || ((_root.projectile._y - _root.projectile._height) > Stage.height)) {
_local2 = true;
}
return(_local2);
}
function MoveProjectilesAndCollide() {
var _local4 = 0;
while (_local4 < arrProjectiles.length) {
_root[arrProjectiles[_local4].name]._x = _root[arrProjectiles[_local4].name]._x + (arrProjectiles[_local4].dX / 2);
_root[arrProjectiles[_local4].name]._y = _root[arrProjectiles[_local4].name]._y + (arrProjectiles[_local4].dY / 2);
if (((_root[arrProjectiles[_local4].name]._x + _root[arrProjectiles[_local4].name]._width) < 0) || ((_root[arrProjectiles[_local4].name]._x - _root[arrProjectiles[_local4].name]._width) > Stage.width)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
if (((_root[arrProjectiles[_local4].name]._y + _root[arrProjectiles[_local4].name]._height) < 0) || ((_root[arrProjectiles[_local4].name]._y - _root[arrProjectiles[_local4].name]._height) > Stage.height)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
_local4++;
}
var _local5 = new Array();
var _local3 = 0;
while (_local3 < arrProjectiles.length) {
_local4 = 0;
while (_local4 < arrParticles.length) {
if (_root[arrParticles[_local4]].hitTest(_root[arrProjectiles[_local3].name]._x, _root[arrProjectiles[_local3].name]._y, true) == true) {
_local5.push({name:arrParticles[_local4], X:arrProjectiles[_local3].X, Y:arrProjectiles[_local3].Y});
arrParticles.splice(_local4, 1);
_local4--;
_root[arrProjectiles[_local3].name].removeMovieClip();
arrProjectiles.splice(_local3, 1);
_local3--;
}
_local4++;
}
_local3++;
}
_local4 = 0;
while (_local4 < _local5.length) {
_root[_local5[_local4].name].Collision(_local5[_local4].X, _local5[_local4].Y);
_root[_local5[_local4].name].gotoAndStop(2);
_local4++;
}
_local4 = 0;
while (_local4 < arrProjectiles.length) {
_root[arrProjectiles[_local4].name]._x = _root[arrProjectiles[_local4].name]._x + (arrProjectiles[_local4].dX / 2);
_root[arrProjectiles[_local4].name]._y = _root[arrProjectiles[_local4].name]._y + (arrProjectiles[_local4].dY / 2);
if (((_root[arrProjectiles[_local4].name]._x + _root[arrProjectiles[_local4].name]._width) < 0) || ((_root[arrProjectiles[_local4].name]._x - _root[arrProjectiles[_local4].name]._width) > Stage.width)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
if (((_root[arrProjectiles[_local4].name]._y + _root[arrProjectiles[_local4].name]._height) < 0) || ((_root[arrProjectiles[_local4].name]._y - _root[arrProjectiles[_local4].name]._height) > Stage.height)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
_local4++;
}
_local5 = new Array();
_local3 = 0;
while (_local3 < arrProjectiles.length) {
_local4 = 0;
while (_local4 < arrParticles.length) {
if (_root[arrParticles[_local4]].hitTest(_root[arrProjectiles[_local3].name]._x, _root[arrProjectiles[_local3].name]._y, true) == true) {
_local5.push({name:arrParticles[_local4], X:arrProjectiles[_local3].X, Y:arrProjectiles[_local3].Y});
arrParticles.splice(_local4, 1);
_local4--;
_root[arrProjectiles[_local3].name].removeMovieClip();
arrProjectiles.splice(_local3, 1);
_local3--;
}
_local4++;
}
_local3++;
}
_local4 = 0;
while (_local4 < _local5.length) {
_root[_local5[_local4].name].Collision(_local5[_local4].X, _local5[_local4].Y);
_root[_local5[_local4].name].gotoAndStop(2);
_local4++;
}
if ((arrProjectiles.length == 0) && (projectileOver == true)) {
if (arrParticles.length != 0) {
intState = 3;
_root.messages_mc.gotoAndPlay("retry");
} else {
intState = 4;
var _local10 = ((_global.currentLevel + 5) - 15) / 5;
_global.levels[_local10] = 1;
var _local9 = SharedObject.getLocal("userData");
_local9.data.levelsCompleted = _global.levels;
_global.SoundManager.PlaySound("all");
_root.messages_mc.gotoAndPlay("next");
}
}
}
function LaunchProjectile(deltaX, deltaY, startX, startY, rot) {
var _local2 = "projectile_" + projectileDepth;
arrProjectiles.push({name:_local2, dX:deltaX, dY:deltaY, X:startX, Y:startY});
_root.attachMovie("shootingStar", _local2, projectileDepth);
_root[_local2]._x = startX;
_root[_local2]._y = startY;
_root[_local2]._rotation = rot;
projectileDepth++;
if (projectileDepth > 9999) {
projectileDepth = 5000;
}
}
stop();
var intState = 1;
var vecShootDir;
var arrParticles = new Array();
var arrProjectiles = new Array();
var arrParticlesReset = new Array();
var particleDepth = 1000;
var projectileDepth = 5000;
var arrowDepth = 15000;
var saveX = 0;
var saveY = 0;
var projectileOnScreen = false;
var projectileOver = false;
var saveDepth;
mouseListener = new Object();
mouseListener.onMouseDown = function () {
_root.Shoot();
};
Mouse.addListener(mouseListener);
Frame 245
function GameSetup() {
trace("%%%%%%%%");
trace((_global.currentLevel + " ----- ") + _global.latestLevel);
if (_global.latestLevel == -1) {
_root.gotoAndPlay("splash");
} else if ((_global.latestLevel != 0) && (_global.latestLevel != 20)) {
_global.currentLevel = _global.latestLevel;
_root.gotoAndPlay(_global.latestLevel);
_global.latestLevel = 0;
trace("go here");
} else if ((_global.latestLevel != 0) && (_global.latestLevel == 20)) {
_global.currentLevel = _global.latestLevel;
_global.latestLevel = 0;
}
if (_root.messages_mc.getDepth() != 50000) {
saveDepth = _root.messages_mc.getDepth();
}
vecShootDir = new Vector();
if (_global.musicOn == true) {
_global.myMusicPlayer.SetTrack("game");
_global.myMusicPlayer.SetMaxVolume(40);
_global.myMusicPlayer.PlayWithCrossFade(4);
}
}
function Mediator() {
_global.myMusicPlayer.RunPlayer();
switch (intState) {
case 1 :
AimProjectile();
if (_root.messages_mc.getDepth() != 50000) {
_root.messages_mc.swapDepths(50000);
trace(_root.messages_mc.getDepth());
}
break;
case 2 :
if (projectileOver == false) {
MoveProjectile();
}
DetectParticleCollisions();
MoveProjectilesAndCollide();
break;
case 3 :
if (Key.isDown(32)) {
Reset();
}
break;
case 4 :
if (!Key.isDown(32)) {
break;
}
Next();
}
}
function Reset() {
projectileDepth = 5000;
arrParticles = arrParticlesReset.slice();
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].gotoAndStop(1);
trace(arrParticles[_local2]);
_local2++;
}
trace("-----");
_root.projectile.gotoAndStop(1);
_root.gameBackground.gotoAndStop(1);
_root.messages_mc.gotoAndStop("hide");
projectileOver = false;
projectileOnScreen = false;
intState = 1;
}
function ExitGame() {
CleanupGame();
Mouse.removeListener(mouseListener);
_root.messages_mc.swapDepths(saveDepth);
_global.latestLevel = -1;
_root.gotoAndPlay("level1");
}
function Next() {
_global.currentLevel = _global.currentLevel + 5;
CleanupGame();
_root.messages_mc.swapDepths(saveDepth);
_root.gotoAndPlay(_global.currentLevel);
}
function CleanupGame() {
Mouse.removeListener(mouseListener);
Reset();
var _local3 = 10;
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].swapDepths(_local3);
_local3++;
_root[arrParticles[_local2]].removeMovieClip();
_local2++;
}
delete arrParticles;
arrParticles = new Array();
}
function DetectParticleCollisions() {
var _local3 = new Array();
var _local2 = 0;
while (_local2 < arrParticles.length) {
var _local4 = (_root[arrParticles[_local2]]._width / 2) + 7.5;
if (GetDistance(arrParticles[_local2], "projectile") <= _local4) {
_root[arrParticles[_local2]].Collision(saveX, saveY);
_local3.push(arrParticles[_local2]);
}
_local2++;
}
_local2 = 0;
while (_local2 < _local3.length) {
RemoveParticle(_local3[_local2]);
_root[_local3[_local2]].gotoAndStop(2);
_local2++;
}
}
function RemoveParticle(strName) {
var _local1 = 0;
while (_local1 < arrParticles.length) {
if (strName == arrParticles[_local1]) {
arrParticles.splice(_local1, 1);
break;
}
_local1++;
}
}
function GetDistance(targetA, targetB) {
var _local3 = _root[targetB]._x - _root[targetA]._x;
var _local2 = _root[targetB]._y - _root[targetA]._y;
return(Math.sqrt((_local3 * _local3) + (_local2 * _local2)));
}
function RegisterParticle(particleName) {
arrParticles.push(particleName);
arrParticlesReset.push(particleName);
particleDepth++;
return(particleDepth);
}
function MoveProjectile() {
if (ProjectileOffScreen() == false) {
projectileOnScreen = true;
_root.projectile._x = _root.projectile._x + vecShootDir._x;
_root.projectile._y = _root.projectile._y + vecShootDir._y;
} else if (projectileOnScreen == true) {
projectileOver = true;
} else {
_root.projectile._x = _root.projectile._x + vecShootDir._x;
_root.projectile._y = _root.projectile._y + vecShootDir._y;
}
}
function AimProjectile() {
var _local11 = new Vector();
_local11._x = _xmouse - (Stage.width / 2);
_local11._y = _ymouse - (Stage.height / 2);
var _local12 = Math.atan2(_local11._y, _local11._x);
var _local15 = (360 * _local12) / (Math.PI*2);
var _local6 = _root.gameBackground._width / 2;
_root.projectile._x = (_local6 * Math.cos(_local12)) + (Stage.width / 2);
_root.projectile._y = (_local6 * Math.sin(_local12)) + (Stage.height / 2);
_local11._x = (Stage.width / 2) - _root.projectile._x;
_local11._y = (Stage.height / 2) - _root.projectile._y;
_local12 = Math.atan2(_local11._y, _local11._x);
var _local14 = Math.cos(_local12) * 11;
var _local13 = Math.sin(_local12) * 11;
var _local9 = _root.projectile._x;
var _local10 = _root.projectile._y;
var _local5 = new Array(arrParticles.length);
var _local4 = 0;
while (_local4 < _local5.length) {
_local5[_local4] = 0;
_local4++;
}
var _local8 = 0;
while (_local8 < 70) {
_local9 = _local9 + _local14;
_local10 = _local10 + _local13;
_local4 = 0;
while (_local4 < arrParticles.length) {
var _local7 = (_root[arrParticles[_local4]]._width / 2) + 7.5;
var _local3 = _root[arrParticles[_local4]]._x - _local9;
var _local2 = _root[arrParticles[_local4]]._y - _local10;
_local6 = Math.sqrt((_local3 * _local3) + (_local2 * _local2));
if (_local6 <= _local7) {
_local5[_local4] = 1;
}
_local4++;
}
_local8++;
}
_local4 = 0;
while (_local4 < _local5.length) {
if (_local5[_local4] == 1) {
_root[arrParticles[_local4]].ArrowsOn(arrowDepth, _root.projectile._x, _root.projectile._y);
} else {
_root[arrParticles[_local4]].ArrowsOff();
}
_local4++;
}
}
function TurnOffAllArrows() {
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].ArrowsOff();
_local2++;
}
}
function NextArrowDepth() {
arrowDepth++;
if (arrowDepth > 39999) {
arrowDepth = 15000;
}
}
function DrawLines() {
_root.clear();
_root.lineStyle(2, 16777215, 50);
var _local2 = new Object();
var _local3 = new Object();
_local2.x = _root.projectile._x;
_local2.y = _root.projectile._y;
_local3.x = _xmouse;
_local3.y = _ymouse;
_root.moveTo(_local2.x, _local2.y);
_root.lineTo(_local3.x, _local3.y);
}
function Shoot() {
if ((intState == 1) && (_global.latestLevel != -1)) {
trace("in");
_root.clear();
saveX = _root.projectile._x;
saveY = _root.projectile._y;
var _local4 = new Vector();
_local4._x = (Stage.width / 2) - _root.projectile._x;
_local4._y = (Stage.height / 2) - _root.projectile._y;
var _local5 = Math.atan2(_local4._y, _local4._x);
vecShootDir._x = Math.cos(_local5) * 11;
vecShootDir._y = Math.sin(_local5) * 11;
var _local3 = 100;
do {
if (ProjectileOffScreen() != false) {
break;
}
_root.projectile._x = _root.projectile._x - vecShootDir._x;
_root.projectile._y = _root.projectile._y - vecShootDir._y;
_local3--;
} while (_local3 != 0);
var _local6 = (360 * _local5) / (Math.PI*2);
_root.projectile.gotoAndStop(2);
_root.projectile._rotation = _local6;
_root.gameBackground.gotoAndPlay("hide");
TurnOffAllArrows();
intState = 2;
}
}
function ProjectileOffScreen() {
var _local2 = false;
if (((_root.projectile._x + _root.projectile._width) < 0) || ((_root.projectile._x - _root.projectile._width) > Stage.width)) {
_local2 = true;
}
if (((_root.projectile._y + _root.projectile._height) < 0) || ((_root.projectile._y - _root.projectile._height) > Stage.height)) {
_local2 = true;
}
return(_local2);
}
function MoveProjectilesAndCollide() {
var _local4 = 0;
while (_local4 < arrProjectiles.length) {
_root[arrProjectiles[_local4].name]._x = _root[arrProjectiles[_local4].name]._x + (arrProjectiles[_local4].dX / 2);
_root[arrProjectiles[_local4].name]._y = _root[arrProjectiles[_local4].name]._y + (arrProjectiles[_local4].dY / 2);
if (((_root[arrProjectiles[_local4].name]._x + _root[arrProjectiles[_local4].name]._width) < 0) || ((_root[arrProjectiles[_local4].name]._x - _root[arrProjectiles[_local4].name]._width) > Stage.width)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
if (((_root[arrProjectiles[_local4].name]._y + _root[arrProjectiles[_local4].name]._height) < 0) || ((_root[arrProjectiles[_local4].name]._y - _root[arrProjectiles[_local4].name]._height) > Stage.height)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
_local4++;
}
var _local5 = new Array();
var _local3 = 0;
while (_local3 < arrProjectiles.length) {
_local4 = 0;
while (_local4 < arrParticles.length) {
if (_root[arrParticles[_local4]].hitTest(_root[arrProjectiles[_local3].name]._x, _root[arrProjectiles[_local3].name]._y, true) == true) {
_local5.push({name:arrParticles[_local4], X:arrProjectiles[_local3].X, Y:arrProjectiles[_local3].Y});
arrParticles.splice(_local4, 1);
_local4--;
_root[arrProjectiles[_local3].name].removeMovieClip();
arrProjectiles.splice(_local3, 1);
_local3--;
}
_local4++;
}
_local3++;
}
_local4 = 0;
while (_local4 < _local5.length) {
_root[_local5[_local4].name].Collision(_local5[_local4].X, _local5[_local4].Y);
_root[_local5[_local4].name].gotoAndStop(2);
_local4++;
}
_local4 = 0;
while (_local4 < arrProjectiles.length) {
_root[arrProjectiles[_local4].name]._x = _root[arrProjectiles[_local4].name]._x + (arrProjectiles[_local4].dX / 2);
_root[arrProjectiles[_local4].name]._y = _root[arrProjectiles[_local4].name]._y + (arrProjectiles[_local4].dY / 2);
if (((_root[arrProjectiles[_local4].name]._x + _root[arrProjectiles[_local4].name]._width) < 0) || ((_root[arrProjectiles[_local4].name]._x - _root[arrProjectiles[_local4].name]._width) > Stage.width)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
if (((_root[arrProjectiles[_local4].name]._y + _root[arrProjectiles[_local4].name]._height) < 0) || ((_root[arrProjectiles[_local4].name]._y - _root[arrProjectiles[_local4].name]._height) > Stage.height)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
_local4++;
}
_local5 = new Array();
_local3 = 0;
while (_local3 < arrProjectiles.length) {
_local4 = 0;
while (_local4 < arrParticles.length) {
if (_root[arrParticles[_local4]].hitTest(_root[arrProjectiles[_local3].name]._x, _root[arrProjectiles[_local3].name]._y, true) == true) {
_local5.push({name:arrParticles[_local4], X:arrProjectiles[_local3].X, Y:arrProjectiles[_local3].Y});
arrParticles.splice(_local4, 1);
_local4--;
_root[arrProjectiles[_local3].name].removeMovieClip();
arrProjectiles.splice(_local3, 1);
_local3--;
}
_local4++;
}
_local3++;
}
_local4 = 0;
while (_local4 < _local5.length) {
_root[_local5[_local4].name].Collision(_local5[_local4].X, _local5[_local4].Y);
_root[_local5[_local4].name].gotoAndStop(2);
_local4++;
}
if ((arrProjectiles.length == 0) && (projectileOver == true)) {
if (arrParticles.length != 0) {
intState = 3;
_root.messages_mc.gotoAndPlay("retry");
} else {
intState = 4;
var _local10 = ((_global.currentLevel + 5) - 15) / 5;
_global.levels[_local10] = 1;
var _local9 = SharedObject.getLocal("userData");
_local9.data.levelsCompleted = _global.levels;
_global.SoundManager.PlaySound("all");
_root.messages_mc.gotoAndPlay("next");
}
}
}
function LaunchProjectile(deltaX, deltaY, startX, startY, rot) {
var _local2 = "projectile_" + projectileDepth;
arrProjectiles.push({name:_local2, dX:deltaX, dY:deltaY, X:startX, Y:startY});
_root.attachMovie("shootingStar", _local2, projectileDepth);
_root[_local2]._x = startX;
_root[_local2]._y = startY;
_root[_local2]._rotation = rot;
projectileDepth++;
if (projectileDepth > 9999) {
projectileDepth = 5000;
}
}
stop();
var intState = 1;
var vecShootDir;
var arrParticles = new Array();
var arrProjectiles = new Array();
var arrParticlesReset = new Array();
var particleDepth = 1000;
var projectileDepth = 5000;
var arrowDepth = 15000;
var saveX = 0;
var saveY = 0;
var projectileOnScreen = false;
var projectileOver = false;
var saveDepth;
mouseListener = new Object();
mouseListener.onMouseDown = function () {
_root.Shoot();
};
Mouse.addListener(mouseListener);
Frame 250
function GameSetup() {
trace("%%%%%%%%");
trace((_global.currentLevel + " ----- ") + _global.latestLevel);
if (_global.latestLevel == -1) {
_root.gotoAndPlay("splash");
} else if ((_global.latestLevel != 0) && (_global.latestLevel != 20)) {
_global.currentLevel = _global.latestLevel;
_root.gotoAndPlay(_global.latestLevel);
_global.latestLevel = 0;
trace("go here");
} else if ((_global.latestLevel != 0) && (_global.latestLevel == 20)) {
_global.currentLevel = _global.latestLevel;
_global.latestLevel = 0;
}
if (_root.messages_mc.getDepth() != 50000) {
saveDepth = _root.messages_mc.getDepth();
}
vecShootDir = new Vector();
if (_global.musicOn == true) {
_global.myMusicPlayer.SetTrack("game");
_global.myMusicPlayer.SetMaxVolume(40);
_global.myMusicPlayer.PlayWithCrossFade(4);
}
}
function Mediator() {
_global.myMusicPlayer.RunPlayer();
switch (intState) {
case 1 :
AimProjectile();
if (_root.messages_mc.getDepth() != 50000) {
_root.messages_mc.swapDepths(50000);
trace(_root.messages_mc.getDepth());
}
break;
case 2 :
if (projectileOver == false) {
MoveProjectile();
}
DetectParticleCollisions();
MoveProjectilesAndCollide();
break;
case 3 :
if (Key.isDown(32)) {
Reset();
}
break;
case 4 :
if (!Key.isDown(32)) {
break;
}
Next();
}
}
function Reset() {
projectileDepth = 5000;
arrParticles = arrParticlesReset.slice();
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].gotoAndStop(1);
trace(arrParticles[_local2]);
_local2++;
}
trace("-----");
_root.projectile.gotoAndStop(1);
_root.gameBackground.gotoAndStop(1);
_root.messages_mc.gotoAndStop("hide");
projectileOver = false;
projectileOnScreen = false;
intState = 1;
}
function ExitGame() {
CleanupGame();
Mouse.removeListener(mouseListener);
_root.messages_mc.swapDepths(saveDepth);
_global.latestLevel = -1;
_root.gotoAndPlay("level1");
}
function Next() {
_global.currentLevel = _global.currentLevel + 5;
CleanupGame();
_root.messages_mc.swapDepths(saveDepth);
_root.gotoAndPlay(_global.currentLevel);
}
function CleanupGame() {
Mouse.removeListener(mouseListener);
Reset();
var _local3 = 10;
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].swapDepths(_local3);
_local3++;
_root[arrParticles[_local2]].removeMovieClip();
_local2++;
}
delete arrParticles;
arrParticles = new Array();
}
function DetectParticleCollisions() {
var _local3 = new Array();
var _local2 = 0;
while (_local2 < arrParticles.length) {
var _local4 = (_root[arrParticles[_local2]]._width / 2) + 7.5;
if (GetDistance(arrParticles[_local2], "projectile") <= _local4) {
_root[arrParticles[_local2]].Collision(saveX, saveY);
_local3.push(arrParticles[_local2]);
}
_local2++;
}
_local2 = 0;
while (_local2 < _local3.length) {
RemoveParticle(_local3[_local2]);
_root[_local3[_local2]].gotoAndStop(2);
_local2++;
}
}
function RemoveParticle(strName) {
var _local1 = 0;
while (_local1 < arrParticles.length) {
if (strName == arrParticles[_local1]) {
arrParticles.splice(_local1, 1);
break;
}
_local1++;
}
}
function GetDistance(targetA, targetB) {
var _local3 = _root[targetB]._x - _root[targetA]._x;
var _local2 = _root[targetB]._y - _root[targetA]._y;
return(Math.sqrt((_local3 * _local3) + (_local2 * _local2)));
}
function RegisterParticle(particleName) {
arrParticles.push(particleName);
arrParticlesReset.push(particleName);
particleDepth++;
return(particleDepth);
}
function MoveProjectile() {
if (ProjectileOffScreen() == false) {
projectileOnScreen = true;
_root.projectile._x = _root.projectile._x + vecShootDir._x;
_root.projectile._y = _root.projectile._y + vecShootDir._y;
} else if (projectileOnScreen == true) {
projectileOver = true;
} else {
_root.projectile._x = _root.projectile._x + vecShootDir._x;
_root.projectile._y = _root.projectile._y + vecShootDir._y;
}
}
function AimProjectile() {
var _local11 = new Vector();
_local11._x = _xmouse - (Stage.width / 2);
_local11._y = _ymouse - (Stage.height / 2);
var _local12 = Math.atan2(_local11._y, _local11._x);
var _local15 = (360 * _local12) / (Math.PI*2);
var _local6 = _root.gameBackground._width / 2;
_root.projectile._x = (_local6 * Math.cos(_local12)) + (Stage.width / 2);
_root.projectile._y = (_local6 * Math.sin(_local12)) + (Stage.height / 2);
_local11._x = (Stage.width / 2) - _root.projectile._x;
_local11._y = (Stage.height / 2) - _root.projectile._y;
_local12 = Math.atan2(_local11._y, _local11._x);
var _local14 = Math.cos(_local12) * 11;
var _local13 = Math.sin(_local12) * 11;
var _local9 = _root.projectile._x;
var _local10 = _root.projectile._y;
var _local5 = new Array(arrParticles.length);
var _local4 = 0;
while (_local4 < _local5.length) {
_local5[_local4] = 0;
_local4++;
}
var _local8 = 0;
while (_local8 < 70) {
_local9 = _local9 + _local14;
_local10 = _local10 + _local13;
_local4 = 0;
while (_local4 < arrParticles.length) {
var _local7 = (_root[arrParticles[_local4]]._width / 2) + 7.5;
var _local3 = _root[arrParticles[_local4]]._x - _local9;
var _local2 = _root[arrParticles[_local4]]._y - _local10;
_local6 = Math.sqrt((_local3 * _local3) + (_local2 * _local2));
if (_local6 <= _local7) {
_local5[_local4] = 1;
}
_local4++;
}
_local8++;
}
_local4 = 0;
while (_local4 < _local5.length) {
if (_local5[_local4] == 1) {
_root[arrParticles[_local4]].ArrowsOn(arrowDepth, _root.projectile._x, _root.projectile._y);
} else {
_root[arrParticles[_local4]].ArrowsOff();
}
_local4++;
}
}
function TurnOffAllArrows() {
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].ArrowsOff();
_local2++;
}
}
function NextArrowDepth() {
arrowDepth++;
if (arrowDepth > 39999) {
arrowDepth = 15000;
}
}
function DrawLines() {
_root.clear();
_root.lineStyle(2, 16777215, 50);
var _local2 = new Object();
var _local3 = new Object();
_local2.x = _root.projectile._x;
_local2.y = _root.projectile._y;
_local3.x = _xmouse;
_local3.y = _ymouse;
_root.moveTo(_local2.x, _local2.y);
_root.lineTo(_local3.x, _local3.y);
}
function Shoot() {
if ((intState == 1) && (_global.latestLevel != -1)) {
trace("in");
_root.clear();
saveX = _root.projectile._x;
saveY = _root.projectile._y;
var _local4 = new Vector();
_local4._x = (Stage.width / 2) - _root.projectile._x;
_local4._y = (Stage.height / 2) - _root.projectile._y;
var _local5 = Math.atan2(_local4._y, _local4._x);
vecShootDir._x = Math.cos(_local5) * 11;
vecShootDir._y = Math.sin(_local5) * 11;
var _local3 = 100;
do {
if (ProjectileOffScreen() != false) {
break;
}
_root.projectile._x = _root.projectile._x - vecShootDir._x;
_root.projectile._y = _root.projectile._y - vecShootDir._y;
_local3--;
} while (_local3 != 0);
var _local6 = (360 * _local5) / (Math.PI*2);
_root.projectile.gotoAndStop(2);
_root.projectile._rotation = _local6;
_root.gameBackground.gotoAndPlay("hide");
TurnOffAllArrows();
intState = 2;
}
}
function ProjectileOffScreen() {
var _local2 = false;
if (((_root.projectile._x + _root.projectile._width) < 0) || ((_root.projectile._x - _root.projectile._width) > Stage.width)) {
_local2 = true;
}
if (((_root.projectile._y + _root.projectile._height) < 0) || ((_root.projectile._y - _root.projectile._height) > Stage.height)) {
_local2 = true;
}
return(_local2);
}
function MoveProjectilesAndCollide() {
var _local4 = 0;
while (_local4 < arrProjectiles.length) {
_root[arrProjectiles[_local4].name]._x = _root[arrProjectiles[_local4].name]._x + (arrProjectiles[_local4].dX / 2);
_root[arrProjectiles[_local4].name]._y = _root[arrProjectiles[_local4].name]._y + (arrProjectiles[_local4].dY / 2);
if (((_root[arrProjectiles[_local4].name]._x + _root[arrProjectiles[_local4].name]._width) < 0) || ((_root[arrProjectiles[_local4].name]._x - _root[arrProjectiles[_local4].name]._width) > Stage.width)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
if (((_root[arrProjectiles[_local4].name]._y + _root[arrProjectiles[_local4].name]._height) < 0) || ((_root[arrProjectiles[_local4].name]._y - _root[arrProjectiles[_local4].name]._height) > Stage.height)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
_local4++;
}
var _local5 = new Array();
var _local3 = 0;
while (_local3 < arrProjectiles.length) {
_local4 = 0;
while (_local4 < arrParticles.length) {
if (_root[arrParticles[_local4]].hitTest(_root[arrProjectiles[_local3].name]._x, _root[arrProjectiles[_local3].name]._y, true) == true) {
_local5.push({name:arrParticles[_local4], X:arrProjectiles[_local3].X, Y:arrProjectiles[_local3].Y});
arrParticles.splice(_local4, 1);
_local4--;
_root[arrProjectiles[_local3].name].removeMovieClip();
arrProjectiles.splice(_local3, 1);
_local3--;
}
_local4++;
}
_local3++;
}
_local4 = 0;
while (_local4 < _local5.length) {
_root[_local5[_local4].name].Collision(_local5[_local4].X, _local5[_local4].Y);
_root[_local5[_local4].name].gotoAndStop(2);
_local4++;
}
_local4 = 0;
while (_local4 < arrProjectiles.length) {
_root[arrProjectiles[_local4].name]._x = _root[arrProjectiles[_local4].name]._x + (arrProjectiles[_local4].dX / 2);
_root[arrProjectiles[_local4].name]._y = _root[arrProjectiles[_local4].name]._y + (arrProjectiles[_local4].dY / 2);
if (((_root[arrProjectiles[_local4].name]._x + _root[arrProjectiles[_local4].name]._width) < 0) || ((_root[arrProjectiles[_local4].name]._x - _root[arrProjectiles[_local4].name]._width) > Stage.width)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
if (((_root[arrProjectiles[_local4].name]._y + _root[arrProjectiles[_local4].name]._height) < 0) || ((_root[arrProjectiles[_local4].name]._y - _root[arrProjectiles[_local4].name]._height) > Stage.height)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
_local4++;
}
_local5 = new Array();
_local3 = 0;
while (_local3 < arrProjectiles.length) {
_local4 = 0;
while (_local4 < arrParticles.length) {
if (_root[arrParticles[_local4]].hitTest(_root[arrProjectiles[_local3].name]._x, _root[arrProjectiles[_local3].name]._y, true) == true) {
_local5.push({name:arrParticles[_local4], X:arrProjectiles[_local3].X, Y:arrProjectiles[_local3].Y});
arrParticles.splice(_local4, 1);
_local4--;
_root[arrProjectiles[_local3].name].removeMovieClip();
arrProjectiles.splice(_local3, 1);
_local3--;
}
_local4++;
}
_local3++;
}
_local4 = 0;
while (_local4 < _local5.length) {
_root[_local5[_local4].name].Collision(_local5[_local4].X, _local5[_local4].Y);
_root[_local5[_local4].name].gotoAndStop(2);
_local4++;
}
if ((arrProjectiles.length == 0) && (projectileOver == true)) {
if (arrParticles.length != 0) {
intState = 3;
_root.messages_mc.gotoAndPlay("retry");
} else {
intState = 4;
var _local10 = ((_global.currentLevel + 5) - 15) / 5;
_global.levels[_local10] = 1;
var _local9 = SharedObject.getLocal("userData");
_local9.data.levelsCompleted = _global.levels;
_global.SoundManager.PlaySound("all");
_root.messages_mc.gotoAndPlay("next");
}
}
}
function LaunchProjectile(deltaX, deltaY, startX, startY, rot) {
var _local2 = "projectile_" + projectileDepth;
arrProjectiles.push({name:_local2, dX:deltaX, dY:deltaY, X:startX, Y:startY});
_root.attachMovie("shootingStar", _local2, projectileDepth);
_root[_local2]._x = startX;
_root[_local2]._y = startY;
_root[_local2]._rotation = rot;
projectileDepth++;
if (projectileDepth > 9999) {
projectileDepth = 5000;
}
}
stop();
var intState = 1;
var vecShootDir;
var arrParticles = new Array();
var arrProjectiles = new Array();
var arrParticlesReset = new Array();
var particleDepth = 1000;
var projectileDepth = 5000;
var arrowDepth = 15000;
var saveX = 0;
var saveY = 0;
var projectileOnScreen = false;
var projectileOver = false;
var saveDepth;
mouseListener = new Object();
mouseListener.onMouseDown = function () {
_root.Shoot();
};
Mouse.addListener(mouseListener);
Frame 255
function GameSetup() {
trace("%%%%%%%%");
trace((_global.currentLevel + " ----- ") + _global.latestLevel);
if (_global.latestLevel == -1) {
_root.gotoAndPlay("splash");
} else if ((_global.latestLevel != 0) && (_global.latestLevel != 20)) {
_global.currentLevel = _global.latestLevel;
_root.gotoAndPlay(_global.latestLevel);
_global.latestLevel = 0;
trace("go here");
} else if ((_global.latestLevel != 0) && (_global.latestLevel == 20)) {
_global.currentLevel = _global.latestLevel;
_global.latestLevel = 0;
}
if (_root.messages_mc.getDepth() != 50000) {
saveDepth = _root.messages_mc.getDepth();
}
vecShootDir = new Vector();
if (_global.musicOn == true) {
_global.myMusicPlayer.SetTrack("game");
_global.myMusicPlayer.SetMaxVolume(40);
_global.myMusicPlayer.PlayWithCrossFade(4);
}
}
function Mediator() {
_global.myMusicPlayer.RunPlayer();
switch (intState) {
case 1 :
AimProjectile();
if (_root.messages_mc.getDepth() != 50000) {
_root.messages_mc.swapDepths(50000);
trace(_root.messages_mc.getDepth());
}
break;
case 2 :
if (projectileOver == false) {
MoveProjectile();
}
DetectParticleCollisions();
MoveProjectilesAndCollide();
break;
case 3 :
if (Key.isDown(32)) {
Reset();
}
break;
case 4 :
if (!Key.isDown(32)) {
break;
}
Next();
}
}
function Reset() {
projectileDepth = 5000;
arrParticles = arrParticlesReset.slice();
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].gotoAndStop(1);
trace(arrParticles[_local2]);
_local2++;
}
trace("-----");
_root.projectile.gotoAndStop(1);
_root.gameBackground.gotoAndStop(1);
_root.messages_mc.gotoAndStop("hide");
projectileOver = false;
projectileOnScreen = false;
intState = 1;
}
function ExitGame() {
CleanupGame();
Mouse.removeListener(mouseListener);
_root.messages_mc.swapDepths(saveDepth);
_global.latestLevel = -1;
_root.gotoAndPlay("level1");
}
function Next() {
_global.currentLevel = _global.currentLevel + 5;
CleanupGame();
_root.messages_mc.swapDepths(saveDepth);
_root.gotoAndPlay(_global.currentLevel);
}
function CleanupGame() {
Mouse.removeListener(mouseListener);
Reset();
var _local3 = 10;
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].swapDepths(_local3);
_local3++;
_root[arrParticles[_local2]].removeMovieClip();
_local2++;
}
delete arrParticles;
arrParticles = new Array();
}
function DetectParticleCollisions() {
var _local3 = new Array();
var _local2 = 0;
while (_local2 < arrParticles.length) {
var _local4 = (_root[arrParticles[_local2]]._width / 2) + 7.5;
if (GetDistance(arrParticles[_local2], "projectile") <= _local4) {
_root[arrParticles[_local2]].Collision(saveX, saveY);
_local3.push(arrParticles[_local2]);
}
_local2++;
}
_local2 = 0;
while (_local2 < _local3.length) {
RemoveParticle(_local3[_local2]);
_root[_local3[_local2]].gotoAndStop(2);
_local2++;
}
}
function RemoveParticle(strName) {
var _local1 = 0;
while (_local1 < arrParticles.length) {
if (strName == arrParticles[_local1]) {
arrParticles.splice(_local1, 1);
break;
}
_local1++;
}
}
function GetDistance(targetA, targetB) {
var _local3 = _root[targetB]._x - _root[targetA]._x;
var _local2 = _root[targetB]._y - _root[targetA]._y;
return(Math.sqrt((_local3 * _local3) + (_local2 * _local2)));
}
function RegisterParticle(particleName) {
arrParticles.push(particleName);
arrParticlesReset.push(particleName);
particleDepth++;
return(particleDepth);
}
function MoveProjectile() {
if (ProjectileOffScreen() == false) {
projectileOnScreen = true;
_root.projectile._x = _root.projectile._x + vecShootDir._x;
_root.projectile._y = _root.projectile._y + vecShootDir._y;
} else if (projectileOnScreen == true) {
projectileOver = true;
} else {
_root.projectile._x = _root.projectile._x + vecShootDir._x;
_root.projectile._y = _root.projectile._y + vecShootDir._y;
}
}
function AimProjectile() {
var _local11 = new Vector();
_local11._x = _xmouse - (Stage.width / 2);
_local11._y = _ymouse - (Stage.height / 2);
var _local12 = Math.atan2(_local11._y, _local11._x);
var _local15 = (360 * _local12) / (Math.PI*2);
var _local6 = _root.gameBackground._width / 2;
_root.projectile._x = (_local6 * Math.cos(_local12)) + (Stage.width / 2);
_root.projectile._y = (_local6 * Math.sin(_local12)) + (Stage.height / 2);
_local11._x = (Stage.width / 2) - _root.projectile._x;
_local11._y = (Stage.height / 2) - _root.projectile._y;
_local12 = Math.atan2(_local11._y, _local11._x);
var _local14 = Math.cos(_local12) * 11;
var _local13 = Math.sin(_local12) * 11;
var _local9 = _root.projectile._x;
var _local10 = _root.projectile._y;
var _local5 = new Array(arrParticles.length);
var _local4 = 0;
while (_local4 < _local5.length) {
_local5[_local4] = 0;
_local4++;
}
var _local8 = 0;
while (_local8 < 70) {
_local9 = _local9 + _local14;
_local10 = _local10 + _local13;
_local4 = 0;
while (_local4 < arrParticles.length) {
var _local7 = (_root[arrParticles[_local4]]._width / 2) + 7.5;
var _local3 = _root[arrParticles[_local4]]._x - _local9;
var _local2 = _root[arrParticles[_local4]]._y - _local10;
_local6 = Math.sqrt((_local3 * _local3) + (_local2 * _local2));
if (_local6 <= _local7) {
_local5[_local4] = 1;
}
_local4++;
}
_local8++;
}
_local4 = 0;
while (_local4 < _local5.length) {
if (_local5[_local4] == 1) {
_root[arrParticles[_local4]].ArrowsOn(arrowDepth, _root.projectile._x, _root.projectile._y);
} else {
_root[arrParticles[_local4]].ArrowsOff();
}
_local4++;
}
}
function TurnOffAllArrows() {
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].ArrowsOff();
_local2++;
}
}
function NextArrowDepth() {
arrowDepth++;
if (arrowDepth > 39999) {
arrowDepth = 15000;
}
}
function DrawLines() {
_root.clear();
_root.lineStyle(2, 16777215, 50);
var _local2 = new Object();
var _local3 = new Object();
_local2.x = _root.projectile._x;
_local2.y = _root.projectile._y;
_local3.x = _xmouse;
_local3.y = _ymouse;
_root.moveTo(_local2.x, _local2.y);
_root.lineTo(_local3.x, _local3.y);
}
function Shoot() {
if ((intState == 1) && (_global.latestLevel != -1)) {
trace("in");
_root.clear();
saveX = _root.projectile._x;
saveY = _root.projectile._y;
var _local4 = new Vector();
_local4._x = (Stage.width / 2) - _root.projectile._x;
_local4._y = (Stage.height / 2) - _root.projectile._y;
var _local5 = Math.atan2(_local4._y, _local4._x);
vecShootDir._x = Math.cos(_local5) * 11;
vecShootDir._y = Math.sin(_local5) * 11;
var _local3 = 100;
do {
if (ProjectileOffScreen() != false) {
break;
}
_root.projectile._x = _root.projectile._x - vecShootDir._x;
_root.projectile._y = _root.projectile._y - vecShootDir._y;
_local3--;
} while (_local3 != 0);
var _local6 = (360 * _local5) / (Math.PI*2);
_root.projectile.gotoAndStop(2);
_root.projectile._rotation = _local6;
_root.gameBackground.gotoAndPlay("hide");
TurnOffAllArrows();
intState = 2;
}
}
function ProjectileOffScreen() {
var _local2 = false;
if (((_root.projectile._x + _root.projectile._width) < 0) || ((_root.projectile._x - _root.projectile._width) > Stage.width)) {
_local2 = true;
}
if (((_root.projectile._y + _root.projectile._height) < 0) || ((_root.projectile._y - _root.projectile._height) > Stage.height)) {
_local2 = true;
}
return(_local2);
}
function MoveProjectilesAndCollide() {
var _local4 = 0;
while (_local4 < arrProjectiles.length) {
_root[arrProjectiles[_local4].name]._x = _root[arrProjectiles[_local4].name]._x + (arrProjectiles[_local4].dX / 2);
_root[arrProjectiles[_local4].name]._y = _root[arrProjectiles[_local4].name]._y + (arrProjectiles[_local4].dY / 2);
if (((_root[arrProjectiles[_local4].name]._x + _root[arrProjectiles[_local4].name]._width) < 0) || ((_root[arrProjectiles[_local4].name]._x - _root[arrProjectiles[_local4].name]._width) > Stage.width)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
if (((_root[arrProjectiles[_local4].name]._y + _root[arrProjectiles[_local4].name]._height) < 0) || ((_root[arrProjectiles[_local4].name]._y - _root[arrProjectiles[_local4].name]._height) > Stage.height)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
_local4++;
}
var _local5 = new Array();
var _local3 = 0;
while (_local3 < arrProjectiles.length) {
_local4 = 0;
while (_local4 < arrParticles.length) {
if (_root[arrParticles[_local4]].hitTest(_root[arrProjectiles[_local3].name]._x, _root[arrProjectiles[_local3].name]._y, true) == true) {
_local5.push({name:arrParticles[_local4], X:arrProjectiles[_local3].X, Y:arrProjectiles[_local3].Y});
arrParticles.splice(_local4, 1);
_local4--;
_root[arrProjectiles[_local3].name].removeMovieClip();
arrProjectiles.splice(_local3, 1);
_local3--;
}
_local4++;
}
_local3++;
}
_local4 = 0;
while (_local4 < _local5.length) {
_root[_local5[_local4].name].Collision(_local5[_local4].X, _local5[_local4].Y);
_root[_local5[_local4].name].gotoAndStop(2);
_local4++;
}
_local4 = 0;
while (_local4 < arrProjectiles.length) {
_root[arrProjectiles[_local4].name]._x = _root[arrProjectiles[_local4].name]._x + (arrProjectiles[_local4].dX / 2);
_root[arrProjectiles[_local4].name]._y = _root[arrProjectiles[_local4].name]._y + (arrProjectiles[_local4].dY / 2);
if (((_root[arrProjectiles[_local4].name]._x + _root[arrProjectiles[_local4].name]._width) < 0) || ((_root[arrProjectiles[_local4].name]._x - _root[arrProjectiles[_local4].name]._width) > Stage.width)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
if (((_root[arrProjectiles[_local4].name]._y + _root[arrProjectiles[_local4].name]._height) < 0) || ((_root[arrProjectiles[_local4].name]._y - _root[arrProjectiles[_local4].name]._height) > Stage.height)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
_local4++;
}
_local5 = new Array();
_local3 = 0;
while (_local3 < arrProjectiles.length) {
_local4 = 0;
while (_local4 < arrParticles.length) {
if (_root[arrParticles[_local4]].hitTest(_root[arrProjectiles[_local3].name]._x, _root[arrProjectiles[_local3].name]._y, true) == true) {
_local5.push({name:arrParticles[_local4], X:arrProjectiles[_local3].X, Y:arrProjectiles[_local3].Y});
arrParticles.splice(_local4, 1);
_local4--;
_root[arrProjectiles[_local3].name].removeMovieClip();
arrProjectiles.splice(_local3, 1);
_local3--;
}
_local4++;
}
_local3++;
}
_local4 = 0;
while (_local4 < _local5.length) {
_root[_local5[_local4].name].Collision(_local5[_local4].X, _local5[_local4].Y);
_root[_local5[_local4].name].gotoAndStop(2);
_local4++;
}
if ((arrProjectiles.length == 0) && (projectileOver == true)) {
if (arrParticles.length != 0) {
intState = 3;
_root.messages_mc.gotoAndPlay("retry");
} else {
intState = 4;
var _local10 = ((_global.currentLevel + 5) - 15) / 5;
_global.levels[_local10] = 1;
var _local9 = SharedObject.getLocal("userData");
_local9.data.levelsCompleted = _global.levels;
_global.SoundManager.PlaySound("all");
_root.messages_mc.gotoAndPlay("next");
}
}
}
function LaunchProjectile(deltaX, deltaY, startX, startY, rot) {
var _local2 = "projectile_" + projectileDepth;
arrProjectiles.push({name:_local2, dX:deltaX, dY:deltaY, X:startX, Y:startY});
_root.attachMovie("shootingStar", _local2, projectileDepth);
_root[_local2]._x = startX;
_root[_local2]._y = startY;
_root[_local2]._rotation = rot;
projectileDepth++;
if (projectileDepth > 9999) {
projectileDepth = 5000;
}
}
stop();
var intState = 1;
var vecShootDir;
var arrParticles = new Array();
var arrProjectiles = new Array();
var arrParticlesReset = new Array();
var particleDepth = 1000;
var projectileDepth = 5000;
var arrowDepth = 15000;
var saveX = 0;
var saveY = 0;
var projectileOnScreen = false;
var projectileOver = false;
var saveDepth;
mouseListener = new Object();
mouseListener.onMouseDown = function () {
_root.Shoot();
};
Mouse.addListener(mouseListener);
Frame 260
function GameSetup() {
trace("%%%%%%%%");
trace((_global.currentLevel + " ----- ") + _global.latestLevel);
if (_global.latestLevel == -1) {
_root.gotoAndPlay("splash");
} else if ((_global.latestLevel != 0) && (_global.latestLevel != 20)) {
_global.currentLevel = _global.latestLevel;
_root.gotoAndPlay(_global.latestLevel);
_global.latestLevel = 0;
trace("go here");
} else if ((_global.latestLevel != 0) && (_global.latestLevel == 20)) {
_global.currentLevel = _global.latestLevel;
_global.latestLevel = 0;
}
if (_root.messages_mc.getDepth() != 50000) {
saveDepth = _root.messages_mc.getDepth();
}
vecShootDir = new Vector();
if (_global.musicOn == true) {
_global.myMusicPlayer.SetTrack("game");
_global.myMusicPlayer.SetMaxVolume(40);
_global.myMusicPlayer.PlayWithCrossFade(4);
}
}
function Mediator() {
_global.myMusicPlayer.RunPlayer();
switch (intState) {
case 1 :
AimProjectile();
if (_root.messages_mc.getDepth() != 50000) {
_root.messages_mc.swapDepths(50000);
trace(_root.messages_mc.getDepth());
}
break;
case 2 :
if (projectileOver == false) {
MoveProjectile();
}
DetectParticleCollisions();
MoveProjectilesAndCollide();
break;
case 3 :
if (Key.isDown(32)) {
Reset();
}
break;
case 4 :
if (!Key.isDown(32)) {
break;
}
Next();
}
}
function Reset() {
projectileDepth = 5000;
arrParticles = arrParticlesReset.slice();
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].gotoAndStop(1);
trace(arrParticles[_local2]);
_local2++;
}
trace("-----");
_root.projectile.gotoAndStop(1);
_root.gameBackground.gotoAndStop(1);
_root.messages_mc.gotoAndStop("hide");
projectileOver = false;
projectileOnScreen = false;
intState = 1;
}
function ExitGame() {
CleanupGame();
Mouse.removeListener(mouseListener);
_root.messages_mc.swapDepths(saveDepth);
_global.latestLevel = -1;
_root.gotoAndPlay("level1");
}
function Next() {
_global.currentLevel = _global.currentLevel + 5;
CleanupGame();
_root.messages_mc.swapDepths(saveDepth);
_root.gotoAndPlay(_global.currentLevel);
}
function CleanupGame() {
Mouse.removeListener(mouseListener);
Reset();
var _local3 = 10;
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].swapDepths(_local3);
_local3++;
_root[arrParticles[_local2]].removeMovieClip();
_local2++;
}
delete arrParticles;
arrParticles = new Array();
}
function DetectParticleCollisions() {
var _local3 = new Array();
var _local2 = 0;
while (_local2 < arrParticles.length) {
var _local4 = (_root[arrParticles[_local2]]._width / 2) + 7.5;
if (GetDistance(arrParticles[_local2], "projectile") <= _local4) {
_root[arrParticles[_local2]].Collision(saveX, saveY);
_local3.push(arrParticles[_local2]);
}
_local2++;
}
_local2 = 0;
while (_local2 < _local3.length) {
RemoveParticle(_local3[_local2]);
_root[_local3[_local2]].gotoAndStop(2);
_local2++;
}
}
function RemoveParticle(strName) {
var _local1 = 0;
while (_local1 < arrParticles.length) {
if (strName == arrParticles[_local1]) {
arrParticles.splice(_local1, 1);
break;
}
_local1++;
}
}
function GetDistance(targetA, targetB) {
var _local3 = _root[targetB]._x - _root[targetA]._x;
var _local2 = _root[targetB]._y - _root[targetA]._y;
return(Math.sqrt((_local3 * _local3) + (_local2 * _local2)));
}
function RegisterParticle(particleName) {
arrParticles.push(particleName);
arrParticlesReset.push(particleName);
particleDepth++;
return(particleDepth);
}
function MoveProjectile() {
if (ProjectileOffScreen() == false) {
projectileOnScreen = true;
_root.projectile._x = _root.projectile._x + vecShootDir._x;
_root.projectile._y = _root.projectile._y + vecShootDir._y;
} else if (projectileOnScreen == true) {
projectileOver = true;
} else {
_root.projectile._x = _root.projectile._x + vecShootDir._x;
_root.projectile._y = _root.projectile._y + vecShootDir._y;
}
}
function AimProjectile() {
var _local11 = new Vector();
_local11._x = _xmouse - (Stage.width / 2);
_local11._y = _ymouse - (Stage.height / 2);
var _local12 = Math.atan2(_local11._y, _local11._x);
var _local15 = (360 * _local12) / (Math.PI*2);
var _local6 = _root.gameBackground._width / 2;
_root.projectile._x = (_local6 * Math.cos(_local12)) + (Stage.width / 2);
_root.projectile._y = (_local6 * Math.sin(_local12)) + (Stage.height / 2);
_local11._x = (Stage.width / 2) - _root.projectile._x;
_local11._y = (Stage.height / 2) - _root.projectile._y;
_local12 = Math.atan2(_local11._y, _local11._x);
var _local14 = Math.cos(_local12) * 11;
var _local13 = Math.sin(_local12) * 11;
var _local9 = _root.projectile._x;
var _local10 = _root.projectile._y;
var _local5 = new Array(arrParticles.length);
var _local4 = 0;
while (_local4 < _local5.length) {
_local5[_local4] = 0;
_local4++;
}
var _local8 = 0;
while (_local8 < 70) {
_local9 = _local9 + _local14;
_local10 = _local10 + _local13;
_local4 = 0;
while (_local4 < arrParticles.length) {
var _local7 = (_root[arrParticles[_local4]]._width / 2) + 7.5;
var _local3 = _root[arrParticles[_local4]]._x - _local9;
var _local2 = _root[arrParticles[_local4]]._y - _local10;
_local6 = Math.sqrt((_local3 * _local3) + (_local2 * _local2));
if (_local6 <= _local7) {
_local5[_local4] = 1;
}
_local4++;
}
_local8++;
}
_local4 = 0;
while (_local4 < _local5.length) {
if (_local5[_local4] == 1) {
_root[arrParticles[_local4]].ArrowsOn(arrowDepth, _root.projectile._x, _root.projectile._y);
} else {
_root[arrParticles[_local4]].ArrowsOff();
}
_local4++;
}
}
function TurnOffAllArrows() {
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].ArrowsOff();
_local2++;
}
}
function NextArrowDepth() {
arrowDepth++;
if (arrowDepth > 39999) {
arrowDepth = 15000;
}
}
function DrawLines() {
_root.clear();
_root.lineStyle(2, 16777215, 50);
var _local2 = new Object();
var _local3 = new Object();
_local2.x = _root.projectile._x;
_local2.y = _root.projectile._y;
_local3.x = _xmouse;
_local3.y = _ymouse;
_root.moveTo(_local2.x, _local2.y);
_root.lineTo(_local3.x, _local3.y);
}
function Shoot() {
if ((intState == 1) && (_global.latestLevel != -1)) {
trace("in");
_root.clear();
saveX = _root.projectile._x;
saveY = _root.projectile._y;
var _local4 = new Vector();
_local4._x = (Stage.width / 2) - _root.projectile._x;
_local4._y = (Stage.height / 2) - _root.projectile._y;
var _local5 = Math.atan2(_local4._y, _local4._x);
vecShootDir._x = Math.cos(_local5) * 11;
vecShootDir._y = Math.sin(_local5) * 11;
var _local3 = 100;
do {
if (ProjectileOffScreen() != false) {
break;
}
_root.projectile._x = _root.projectile._x - vecShootDir._x;
_root.projectile._y = _root.projectile._y - vecShootDir._y;
_local3--;
} while (_local3 != 0);
var _local6 = (360 * _local5) / (Math.PI*2);
_root.projectile.gotoAndStop(2);
_root.projectile._rotation = _local6;
_root.gameBackground.gotoAndPlay("hide");
TurnOffAllArrows();
intState = 2;
}
}
function ProjectileOffScreen() {
var _local2 = false;
if (((_root.projectile._x + _root.projectile._width) < 0) || ((_root.projectile._x - _root.projectile._width) > Stage.width)) {
_local2 = true;
}
if (((_root.projectile._y + _root.projectile._height) < 0) || ((_root.projectile._y - _root.projectile._height) > Stage.height)) {
_local2 = true;
}
return(_local2);
}
function MoveProjectilesAndCollide() {
var _local4 = 0;
while (_local4 < arrProjectiles.length) {
_root[arrProjectiles[_local4].name]._x = _root[arrProjectiles[_local4].name]._x + (arrProjectiles[_local4].dX / 2);
_root[arrProjectiles[_local4].name]._y = _root[arrProjectiles[_local4].name]._y + (arrProjectiles[_local4].dY / 2);
if (((_root[arrProjectiles[_local4].name]._x + _root[arrProjectiles[_local4].name]._width) < 0) || ((_root[arrProjectiles[_local4].name]._x - _root[arrProjectiles[_local4].name]._width) > Stage.width)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
if (((_root[arrProjectiles[_local4].name]._y + _root[arrProjectiles[_local4].name]._height) < 0) || ((_root[arrProjectiles[_local4].name]._y - _root[arrProjectiles[_local4].name]._height) > Stage.height)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
_local4++;
}
var _local5 = new Array();
var _local3 = 0;
while (_local3 < arrProjectiles.length) {
_local4 = 0;
while (_local4 < arrParticles.length) {
if (_root[arrParticles[_local4]].hitTest(_root[arrProjectiles[_local3].name]._x, _root[arrProjectiles[_local3].name]._y, true) == true) {
_local5.push({name:arrParticles[_local4], X:arrProjectiles[_local3].X, Y:arrProjectiles[_local3].Y});
arrParticles.splice(_local4, 1);
_local4--;
_root[arrProjectiles[_local3].name].removeMovieClip();
arrProjectiles.splice(_local3, 1);
_local3--;
}
_local4++;
}
_local3++;
}
_local4 = 0;
while (_local4 < _local5.length) {
_root[_local5[_local4].name].Collision(_local5[_local4].X, _local5[_local4].Y);
_root[_local5[_local4].name].gotoAndStop(2);
_local4++;
}
_local4 = 0;
while (_local4 < arrProjectiles.length) {
_root[arrProjectiles[_local4].name]._x = _root[arrProjectiles[_local4].name]._x + (arrProjectiles[_local4].dX / 2);
_root[arrProjectiles[_local4].name]._y = _root[arrProjectiles[_local4].name]._y + (arrProjectiles[_local4].dY / 2);
if (((_root[arrProjectiles[_local4].name]._x + _root[arrProjectiles[_local4].name]._width) < 0) || ((_root[arrProjectiles[_local4].name]._x - _root[arrProjectiles[_local4].name]._width) > Stage.width)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
if (((_root[arrProjectiles[_local4].name]._y + _root[arrProjectiles[_local4].name]._height) < 0) || ((_root[arrProjectiles[_local4].name]._y - _root[arrProjectiles[_local4].name]._height) > Stage.height)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
_local4++;
}
_local5 = new Array();
_local3 = 0;
while (_local3 < arrProjectiles.length) {
_local4 = 0;
while (_local4 < arrParticles.length) {
if (_root[arrParticles[_local4]].hitTest(_root[arrProjectiles[_local3].name]._x, _root[arrProjectiles[_local3].name]._y, true) == true) {
_local5.push({name:arrParticles[_local4], X:arrProjectiles[_local3].X, Y:arrProjectiles[_local3].Y});
arrParticles.splice(_local4, 1);
_local4--;
_root[arrProjectiles[_local3].name].removeMovieClip();
arrProjectiles.splice(_local3, 1);
_local3--;
}
_local4++;
}
_local3++;
}
_local4 = 0;
while (_local4 < _local5.length) {
_root[_local5[_local4].name].Collision(_local5[_local4].X, _local5[_local4].Y);
_root[_local5[_local4].name].gotoAndStop(2);
_local4++;
}
if ((arrProjectiles.length == 0) && (projectileOver == true)) {
if (arrParticles.length != 0) {
intState = 3;
_root.messages_mc.gotoAndPlay("retry");
} else {
intState = 4;
var _local10 = ((_global.currentLevel + 5) - 15) / 5;
_global.levels[_local10] = 1;
var _local9 = SharedObject.getLocal("userData");
_local9.data.levelsCompleted = _global.levels;
_global.SoundManager.PlaySound("all");
_root.messages_mc.gotoAndPlay("next");
}
}
}
function LaunchProjectile(deltaX, deltaY, startX, startY, rot) {
var _local2 = "projectile_" + projectileDepth;
arrProjectiles.push({name:_local2, dX:deltaX, dY:deltaY, X:startX, Y:startY});
_root.attachMovie("shootingStar", _local2, projectileDepth);
_root[_local2]._x = startX;
_root[_local2]._y = startY;
_root[_local2]._rotation = rot;
projectileDepth++;
if (projectileDepth > 9999) {
projectileDepth = 5000;
}
}
stop();
var intState = 1;
var vecShootDir;
var arrParticles = new Array();
var arrProjectiles = new Array();
var arrParticlesReset = new Array();
var particleDepth = 1000;
var projectileDepth = 5000;
var arrowDepth = 15000;
var saveX = 0;
var saveY = 0;
var projectileOnScreen = false;
var projectileOver = false;
var saveDepth;
mouseListener = new Object();
mouseListener.onMouseDown = function () {
_root.Shoot();
};
Mouse.addListener(mouseListener);
Frame 265
function GameSetup() {
trace("%%%%%%%%");
trace((_global.currentLevel + " ----- ") + _global.latestLevel);
if (_global.latestLevel == -1) {
_root.gotoAndPlay("splash");
} else if ((_global.latestLevel != 0) && (_global.latestLevel != 20)) {
_global.currentLevel = _global.latestLevel;
_root.gotoAndPlay(_global.latestLevel);
_global.latestLevel = 0;
trace("go here");
} else if ((_global.latestLevel != 0) && (_global.latestLevel == 20)) {
_global.currentLevel = _global.latestLevel;
_global.latestLevel = 0;
}
if (_root.messages_mc.getDepth() != 50000) {
saveDepth = _root.messages_mc.getDepth();
}
vecShootDir = new Vector();
if (_global.musicOn == true) {
_global.myMusicPlayer.SetTrack("game");
_global.myMusicPlayer.SetMaxVolume(40);
_global.myMusicPlayer.PlayWithCrossFade(4);
}
}
function Mediator() {
_global.myMusicPlayer.RunPlayer();
switch (intState) {
case 1 :
AimProjectile();
if (_root.messages_mc.getDepth() != 50000) {
_root.messages_mc.swapDepths(50000);
trace(_root.messages_mc.getDepth());
}
break;
case 2 :
if (projectileOver == false) {
MoveProjectile();
}
DetectParticleCollisions();
MoveProjectilesAndCollide();
break;
case 3 :
if (Key.isDown(32)) {
Reset();
}
break;
case 4 :
if (!Key.isDown(32)) {
break;
}
Next();
}
}
function Reset() {
projectileDepth = 5000;
arrParticles = arrParticlesReset.slice();
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].gotoAndStop(1);
trace(arrParticles[_local2]);
_local2++;
}
trace("-----");
_root.projectile.gotoAndStop(1);
_root.gameBackground.gotoAndStop(1);
_root.messages_mc.gotoAndStop("hide");
projectileOver = false;
projectileOnScreen = false;
intState = 1;
}
function ExitGame() {
CleanupGame();
Mouse.removeListener(mouseListener);
_root.messages_mc.swapDepths(saveDepth);
_global.latestLevel = -1;
_root.gotoAndPlay("level1");
}
function Next() {
_global.currentLevel = _global.currentLevel + 5;
CleanupGame();
_root.messages_mc.swapDepths(saveDepth);
_root.gotoAndPlay(_global.currentLevel);
}
function CleanupGame() {
Mouse.removeListener(mouseListener);
Reset();
var _local3 = 10;
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].swapDepths(_local3);
_local3++;
_root[arrParticles[_local2]].removeMovieClip();
_local2++;
}
delete arrParticles;
arrParticles = new Array();
}
function DetectParticleCollisions() {
var _local3 = new Array();
var _local2 = 0;
while (_local2 < arrParticles.length) {
var _local4 = (_root[arrParticles[_local2]]._width / 2) + 7.5;
if (GetDistance(arrParticles[_local2], "projectile") <= _local4) {
_root[arrParticles[_local2]].Collision(saveX, saveY);
_local3.push(arrParticles[_local2]);
}
_local2++;
}
_local2 = 0;
while (_local2 < _local3.length) {
RemoveParticle(_local3[_local2]);
_root[_local3[_local2]].gotoAndStop(2);
_local2++;
}
}
function RemoveParticle(strName) {
var _local1 = 0;
while (_local1 < arrParticles.length) {
if (strName == arrParticles[_local1]) {
arrParticles.splice(_local1, 1);
break;
}
_local1++;
}
}
function GetDistance(targetA, targetB) {
var _local3 = _root[targetB]._x - _root[targetA]._x;
var _local2 = _root[targetB]._y - _root[targetA]._y;
return(Math.sqrt((_local3 * _local3) + (_local2 * _local2)));
}
function RegisterParticle(particleName) {
arrParticles.push(particleName);
arrParticlesReset.push(particleName);
particleDepth++;
return(particleDepth);
}
function MoveProjectile() {
if (ProjectileOffScreen() == false) {
projectileOnScreen = true;
_root.projectile._x = _root.projectile._x + vecShootDir._x;
_root.projectile._y = _root.projectile._y + vecShootDir._y;
} else if (projectileOnScreen == true) {
projectileOver = true;
} else {
_root.projectile._x = _root.projectile._x + vecShootDir._x;
_root.projectile._y = _root.projectile._y + vecShootDir._y;
}
}
function AimProjectile() {
var _local11 = new Vector();
_local11._x = _xmouse - (Stage.width / 2);
_local11._y = _ymouse - (Stage.height / 2);
var _local12 = Math.atan2(_local11._y, _local11._x);
var _local15 = (360 * _local12) / (Math.PI*2);
var _local6 = _root.gameBackground._width / 2;
_root.projectile._x = (_local6 * Math.cos(_local12)) + (Stage.width / 2);
_root.projectile._y = (_local6 * Math.sin(_local12)) + (Stage.height / 2);
_local11._x = (Stage.width / 2) - _root.projectile._x;
_local11._y = (Stage.height / 2) - _root.projectile._y;
_local12 = Math.atan2(_local11._y, _local11._x);
var _local14 = Math.cos(_local12) * 11;
var _local13 = Math.sin(_local12) * 11;
var _local9 = _root.projectile._x;
var _local10 = _root.projectile._y;
var _local5 = new Array(arrParticles.length);
var _local4 = 0;
while (_local4 < _local5.length) {
_local5[_local4] = 0;
_local4++;
}
var _local8 = 0;
while (_local8 < 70) {
_local9 = _local9 + _local14;
_local10 = _local10 + _local13;
_local4 = 0;
while (_local4 < arrParticles.length) {
var _local7 = (_root[arrParticles[_local4]]._width / 2) + 7.5;
var _local3 = _root[arrParticles[_local4]]._x - _local9;
var _local2 = _root[arrParticles[_local4]]._y - _local10;
_local6 = Math.sqrt((_local3 * _local3) + (_local2 * _local2));
if (_local6 <= _local7) {
_local5[_local4] = 1;
}
_local4++;
}
_local8++;
}
_local4 = 0;
while (_local4 < _local5.length) {
if (_local5[_local4] == 1) {
_root[arrParticles[_local4]].ArrowsOn(arrowDepth, _root.projectile._x, _root.projectile._y);
} else {
_root[arrParticles[_local4]].ArrowsOff();
}
_local4++;
}
}
function TurnOffAllArrows() {
var _local2 = 0;
while (_local2 < arrParticles.length) {
_root[arrParticles[_local2]].ArrowsOff();
_local2++;
}
}
function NextArrowDepth() {
arrowDepth++;
if (arrowDepth > 39999) {
arrowDepth = 15000;
}
}
function DrawLines() {
_root.clear();
_root.lineStyle(2, 16777215, 50);
var _local2 = new Object();
var _local3 = new Object();
_local2.x = _root.projectile._x;
_local2.y = _root.projectile._y;
_local3.x = _xmouse;
_local3.y = _ymouse;
_root.moveTo(_local2.x, _local2.y);
_root.lineTo(_local3.x, _local3.y);
}
function Shoot() {
if ((intState == 1) && (_global.latestLevel != -1)) {
trace("in");
_root.clear();
saveX = _root.projectile._x;
saveY = _root.projectile._y;
var _local4 = new Vector();
_local4._x = (Stage.width / 2) - _root.projectile._x;
_local4._y = (Stage.height / 2) - _root.projectile._y;
var _local5 = Math.atan2(_local4._y, _local4._x);
vecShootDir._x = Math.cos(_local5) * 11;
vecShootDir._y = Math.sin(_local5) * 11;
var _local3 = 100;
do {
if (ProjectileOffScreen() != false) {
break;
}
_root.projectile._x = _root.projectile._x - vecShootDir._x;
_root.projectile._y = _root.projectile._y - vecShootDir._y;
_local3--;
} while (_local3 != 0);
var _local6 = (360 * _local5) / (Math.PI*2);
_root.projectile.gotoAndStop(2);
_root.projectile._rotation = _local6;
_root.gameBackground.gotoAndPlay("hide");
TurnOffAllArrows();
intState = 2;
}
}
function ProjectileOffScreen() {
var _local2 = false;
if (((_root.projectile._x + _root.projectile._width) < 0) || ((_root.projectile._x - _root.projectile._width) > Stage.width)) {
_local2 = true;
}
if (((_root.projectile._y + _root.projectile._height) < 0) || ((_root.projectile._y - _root.projectile._height) > Stage.height)) {
_local2 = true;
}
return(_local2);
}
function MoveProjectilesAndCollide() {
var _local4 = 0;
while (_local4 < arrProjectiles.length) {
_root[arrProjectiles[_local4].name]._x = _root[arrProjectiles[_local4].name]._x + (arrProjectiles[_local4].dX / 2);
_root[arrProjectiles[_local4].name]._y = _root[arrProjectiles[_local4].name]._y + (arrProjectiles[_local4].dY / 2);
if (((_root[arrProjectiles[_local4].name]._x + _root[arrProjectiles[_local4].name]._width) < 0) || ((_root[arrProjectiles[_local4].name]._x - _root[arrProjectiles[_local4].name]._width) > Stage.width)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
if (((_root[arrProjectiles[_local4].name]._y + _root[arrProjectiles[_local4].name]._height) < 0) || ((_root[arrProjectiles[_local4].name]._y - _root[arrProjectiles[_local4].name]._height) > Stage.height)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
_local4++;
}
var _local5 = new Array();
var _local3 = 0;
while (_local3 < arrProjectiles.length) {
_local4 = 0;
while (_local4 < arrParticles.length) {
if (_root[arrParticles[_local4]].hitTest(_root[arrProjectiles[_local3].name]._x, _root[arrProjectiles[_local3].name]._y, true) == true) {
_local5.push({name:arrParticles[_local4], X:arrProjectiles[_local3].X, Y:arrProjectiles[_local3].Y});
arrParticles.splice(_local4, 1);
_local4--;
_root[arrProjectiles[_local3].name].removeMovieClip();
arrProjectiles.splice(_local3, 1);
_local3--;
}
_local4++;
}
_local3++;
}
_local4 = 0;
while (_local4 < _local5.length) {
_root[_local5[_local4].name].Collision(_local5[_local4].X, _local5[_local4].Y);
_root[_local5[_local4].name].gotoAndStop(2);
_local4++;
}
_local4 = 0;
while (_local4 < arrProjectiles.length) {
_root[arrProjectiles[_local4].name]._x = _root[arrProjectiles[_local4].name]._x + (arrProjectiles[_local4].dX / 2);
_root[arrProjectiles[_local4].name]._y = _root[arrProjectiles[_local4].name]._y + (arrProjectiles[_local4].dY / 2);
if (((_root[arrProjectiles[_local4].name]._x + _root[arrProjectiles[_local4].name]._width) < 0) || ((_root[arrProjectiles[_local4].name]._x - _root[arrProjectiles[_local4].name]._width) > Stage.width)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
if (((_root[arrProjectiles[_local4].name]._y + _root[arrProjectiles[_local4].name]._height) < 0) || ((_root[arrProjectiles[_local4].name]._y - _root[arrProjectiles[_local4].name]._height) > Stage.height)) {
_root[arrProjectiles[_local4].name].removeMovieClip();
arrProjectiles.splice(_local4, 1);
_local4--;
}
_local4++;
}
_local5 = new Array();
_local3 = 0;
while (_local3 < arrProjectiles.length) {
_local4 = 0;
while (_local4 < arrParticles.length) {
if (_root[arrParticles[_local4]].hitTest(_root[arrProjectiles[_local3].name]._x, _root[arrProjectiles[_local3].name]._y, true) == true) {
_local5.push({name:arrParticles[_local4], X:arrProjectiles[_local3].X, Y:arrProjectiles[_local3].Y});
arrParticles.splice(_local4, 1);
_local4--;
_root[arrProjectiles[_local3].name].removeMovieClip();
arrProjectiles.splice(_local3, 1);
_local3--;
}
_local4++;
}
_local3++;
}
_local4 = 0;
while (_local4 < _local5.length) {
_root[_local5[_local4].name].Collision(_local5[_local4].X, _local5[_local4].Y);
_root[_local5[_local4].name].gotoAndStop(2);
_local4++;
}
if ((arrProjectiles.length == 0) && (projectileOver == true)) {
if (arrParticles.length != 0) {
intState = 3;
_root.messages_mc.gotoAndPlay("retry");
} else {
intState = 4;
var _local10 = ((_global.currentLevel + 5) - 15) / 5;
_global.levels[_local10] = 1;
var _local9 = SharedObject.getLocal("userData");
_local9.data.levelsCompleted = _global.levels;
_global.SoundManager.PlaySound("all");
_root.messages_mc.gotoAndPlay("next");
}
}
}
function LaunchProjectile(deltaX, deltaY, startX, startY, rot) {
var _local2 = "projectile_" + projectileDepth;
arrProjectiles.push({name:_local2, dX:deltaX, dY:deltaY, X:startX, Y:startY});
_root.attachMovie("shootingStar", _local2, projectileDepth);
_root[_local2]._x = startX;
_root[_local2]._y = startY;
_root[_local2]._rotation = rot;
projectileDepth++;
if (projectileDepth > 9999) {
projectileDepth = 5000;
}
}
stop();
var intState = 1;
var vecShootDir;
var arrParticles = new Array();
var arrProjectiles = new Array();
var arrParticlesReset = new Array();
var particleDepth = 1000;
var projectileDepth = 5000;
var arrowDepth = 15000;
var saveX = 0;
var saveY = 0;
var projectileOnScreen = false;
var projectileOver = false;
var saveDepth;
mouseListener = new Object();
mouseListener.onMouseDown = function () {
_root.Shoot();
};
Mouse.addListener(mouseListener);
Frame 270
stop();
Frame 275
gotoAndPlay ("doneStored");
Frame 285
gotoAndPlay ("ads");
Frame 295
stop();
Symbol 2 MovieClip [particle 1] Frame 1
#initclip 15
Object.registerClass("particle 1", Particle_1);
#endinitclip
Symbol 10 MovieClip Frame 71
gotoAndPlay (38);
Symbol 12 MovieClip [Star - 3 triangle] Frame 1
#initclip 10
Object.registerClass("Star - 3 triangle", Particle_5);
#endinitclip
stop();
Symbol 12 MovieClip [Star - 3 triangle] Frame 2
stop();
Symbol 14 MovieClip [Star - 12 blast] Frame 1
#initclip 11
Object.registerClass("Star - 12 blast", Particle_4);
#endinitclip
stop();
Symbol 14 MovieClip [Star - 12 blast] Frame 2
stop();
Symbol 16 MovieClip [Star - 2 Back] Frame 1
#initclip 12
Object.registerClass("Star - 2 Back", Particle_3);
#endinitclip
stop();
Symbol 16 MovieClip [Star - 2 Back] Frame 2
stop();
Symbol 18 MovieClip [Star - 1 To 45 Right] Frame 1
#initclip 13
Object.registerClass("Star - 1 To 45 Right", Particle_2);
#endinitclip
stop();
Symbol 18 MovieClip [Star - 1 To 45 Right] Frame 2
stop();
Symbol 20 MovieClip [star 1] Frame 1
#initclip 14
Object.registerClass("star 1", Particle_1);
#endinitclip
stop();
Symbol 20 MovieClip [star 1] Frame 2
stop();
Symbol 24 MovieClip [shootingStar] Frame 22
gotoAndPlay (8);
Symbol 40 MovieClip Frame 1
stop();
Symbol 215 MovieClip [__Packages.SoundPlayer] Frame 0
class SoundPlayer
{
var channelsAvailable, channel1, channel2, channel3, externalSoundVolume;
function SoundPlayer () {
channelsAvailable = new Array(true, true, true);
channel1 = new Sound();
channel2 = new Sound();
channel3 = new Sound();
externalSoundVolume = 100;
}
function CleanSounds(intIndex) {
channelsAvailable[intIndex] = true;
}
function PlaySound(linkIdentifier) {
if (_global.soundOn == true) {
var thisRef = this;
if (channelsAvailable[0] == true) {
channelsAvailable[0] = false;
delete channel1;
channel1 = new Sound();
channel1.attachSound(linkIdentifier);
channel1.setVolume(100);
channel1.start(0, 0);
channel1.onSoundComplete = function () {
thisRef.CleanSounds(0);
};
} else if (channelsAvailable[1] == true) {
channelsAvailable[1] = false;
delete channel2;
channel2 = new Sound();
channel2.attachSound(linkIdentifier);
channel2.setVolume(70);
channel2.start(0, 0);
channel2.onSoundComplete = function () {
thisRef.CleanSounds(1);
};
} else {
channelsAvailable[0] = false;
delete channel1;
channel1 = new Sound();
channel1.attachSound(linkIdentifier);
channel1.setVolume(70);
channel1.start(0, 0);
channel1.onSoundComplete = function () {
thisRef.CleanSounds(0);
};
}
}
}
function PlayBubbleSound(linkIdentifier) {
if (_global.soundOn == true) {
var thisRef = this;
if (channelsAvailable[2] == true) {
channelsAvailable[2] = false;
delete channel3;
channel3 = new Sound();
channel3.attachSound(linkIdentifier);
channel3.setVolume(100);
channel3.start(0, 0);
channel3.onSoundComplete = function () {
thisRef.CleanSounds(2);
};
}
}
}
function PlayExternalSound(urlPath) {
var thisRef = this;
if (channelsAvailable[0] == true) {
channelsAvailable[0] = false;
delete channel1;
channel1 = new Sound();
channel1.loadSound(urlPath, false);
channel1.setVolume(externalSoundVolume);
channel1.onLoad = function (loadedOK) {
if (loadedOK) {
this.start();
}
};
channel1.onSoundComplete = function () {
thisRef.CleanSounds(0);
};
} else if (channelsAvailable[1] == true) {
channelsAvailable[1] = false;
delete channel2;
channel2 = new Sound();
channel2.loadSound(urlPath, false);
channel2.setVolume(externalSoundVolume);
channel2.onLoad = function (loadedOK) {
if (loadedOK) {
this.start();
}
};
channel2.onSoundComplete = function () {
thisRef.CleanSounds(1);
};
} else {
channelsAvailable[0] = false;
delete channel1;
channel1 = new Sound();
channel1.loadSound(urlPath, false);
channel1.setVolume(externalSoundVolume);
channel1.onLoad = function (loadedOK) {
if (loadedOK) {
this.start();
}
};
channel1.onSoundComplete = function () {
thisRef.CleanSounds(0);
};
}
}
}
Symbol 216 MovieClip [__Packages.Music] Frame 0
class Music
{
var mySound, volume, currentTrack, inCrossfade, state, changeSongs, maxVolume, targetVolume, volumeSpeed;
function Music () {
mySound = new Sound();
volume = 100;
currentTrack = "";
inCrossfade = false;
state = false;
changeSongs = true;
maxVolume = 60;
}
function SetMaxVolume(vol) {
maxVolume = vol;
}
function SetTrack(setMusic) {
if (setMusic == currentTrack) {
changeSongs = false;
} else {
changeSongs = true;
currentTrack = setMusic;
}
}
function Play() {
mySound.stop();
mySound.attachSound(currentTrack);
volume = maxVolume;
mySound.setVolume(volume);
mySound.start(0, 2000);
state = true;
}
function Stop() {
mySound.stop();
state = false;
}
function PlayWithCrossFade(secondDuration) {
if (changeSongs == true) {
if (state == true) {
inCrossfade = true;
targetVolume = 0;
var _local2 = secondDuration * 30;
volumeSpeed = (targetVolume - volume) / (_local2 / 2);
} else {
mySound.stop();
mySound.attachSound(currentTrack);
mySound.start(0, 2000);
state = true;
inCrossfade = false;
targetVolume = maxVolume;
volume = 0;
mySound.setVolume(0);
var _local2 = secondDuration * 30;
volumeSpeed = (targetVolume - volume) / _local2;
}
}
}
function RunPlayer() {
if (targetVolume != volume) {
var _local2;
_local2 = volume + volumeSpeed;
if ((volumeSpeed < 0) && (_local2 < 0)) {
_local2 = 0;
} else if ((volumeSpeed > 0) && (_local2 > targetVolume)) {
_local2 = targetVolume;
}
volume = _local2;
mySound.setVolume(_local2);
}
if (inCrossfade == true) {
if (volume <= 0) {
volumeSpeed = volumeSpeed * -1;
inCrossfade = false;
targetVolume = maxVolume;
mySound.stop();
mySound.attachSound(currentTrack);
mySound.setVolume(0);
mySound.start(0, 2000);
state = true;
}
}
}
}
Symbol 217 MovieClip [__Packages.Particle] Frame 0
class Particle extends MovieClip
{
var arrPieces, arrArrows, blnHasRegistered, blnArrows, swapDepths, _name, _x, _y;
function Particle () {
super();
arrPieces = new Array();
arrArrows = new Array();
blnHasRegistered = false;
blnArrows = false;
Configure();
}
function Configure() {
}
function onEnterFrame() {
if (blnHasRegistered == false) {
blnHasRegistered = true;
swapDepths(_root.RegisterParticle(_name));
}
}
function ArrowsOn(arrowDepth, X, Y) {
if (blnArrows == false) {
var _local8 = new Vector();
_local8._x = X - _x;
_local8._y = Y - _y;
var _local9 = Math.atan2(_local8._y, _local8._x);
var _local7 = (360 * _local9) / (Math.PI*2);
var _local4 = 0;
while (_local4 < arrPieces.length) {
var _local6 = _local7 + arrPieces[_local4].launchAngle;
var _local3 = "arrow_" + arrowDepth;
_root.attachMovie("arrow", _local3, arrowDepth);
arrArrows.push(_local3);
arrowDepth++;
_root.NextArrowDepth();
_root[_local3]._x = _x;
_root[_local3]._y = _y;
_root[_local3]._rotation = _local6;
_local4++;
}
blnArrows = true;
} else {
var _local8 = new Vector();
_local8._x = X - _x;
_local8._y = Y - _y;
var _local9 = Math.atan2(_local8._y, _local8._x);
var _local7 = (360 * _local9) / (Math.PI*2);
var _local4 = 0;
while (_local4 < arrPieces.length) {
var _local6 = _local7 + arrPieces[_local4].launchAngle;
_root[arrArrows[_local4]]._rotation = _local6;
_local4++;
}
}
}
function ArrowsOff() {
if (blnArrows == true) {
var _local3 = 0;
while (_local3 < arrArrows.length) {
_root[arrArrows[_local3]].removeMovieClip();
_local3++;
}
delete arrArrows;
arrArrows = new Array();
blnArrows = false;
}
}
function Collision(startX, startY) {
_global.SoundManager.PlaySound("collect");
var _local8 = new Vector();
_local8._x = startX - _x;
_local8._y = startY - _y;
var _local9 = Math.atan2(_local8._y, _local8._x);
var _local7 = (360 * _local9) / (Math.PI*2);
var _local6 = 0;
while (_local6 < arrPieces.length) {
var _local5 = _local7 + arrPieces[_local6].launchAngle;
var _local4 = new Vector();
_local4._x = Math.cos((Math.PI * _local5) / 180) * 11;
_local4._y = Math.sin((Math.PI * _local5) / 180) * 11;
_root.LaunchProjectile(_local4._x, _local4._y, _x, _y, _local5);
_local6++;
}
}
}
Symbol 218 MovieClip [__Packages.Vector] Frame 0
class Vector
{
var _x, _y;
function Vector () {
_x = 0;
_y = 0;
}
}
Symbol 219 MovieClip [__Packages.Particle_5] Frame 0
class Particle_5 extends Particle
{
var arrPieces;
function Particle_5 () {
super();
}
function Configure() {
arrPieces.push({launchAngle:180});
arrPieces.push({launchAngle:-60});
arrPieces.push({launchAngle:60});
}
}
Symbol 220 MovieClip [__Packages.Particle_4] Frame 0
class Particle_4 extends Particle
{
var arrPieces;
function Particle_4 () {
super();
}
function Configure() {
arrPieces.push({launchAngle:0});
arrPieces.push({launchAngle:30});
arrPieces.push({launchAngle:60});
arrPieces.push({launchAngle:90});
arrPieces.push({launchAngle:120});
arrPieces.push({launchAngle:150});
arrPieces.push({launchAngle:180});
arrPieces.push({launchAngle:210});
arrPieces.push({launchAngle:240});
arrPieces.push({launchAngle:270});
arrPieces.push({launchAngle:300});
arrPieces.push({launchAngle:330});
}
}
Symbol 221 MovieClip [__Packages.Particle_3] Frame 0
class Particle_3 extends Particle
{
var arrPieces;
function Particle_3 () {
super();
}
function Configure() {
arrPieces.push({launchAngle:20});
arrPieces.push({launchAngle:-20});
}
}
Symbol 222 MovieClip [__Packages.Particle_2] Frame 0
class Particle_2 extends Particle
{
var arrPieces;
function Particle_2 () {
super();
}
function Configure() {
arrPieces.push({launchAngle:135});
}
}
Symbol 223 MovieClip [__Packages.Particle_1] Frame 0
class Particle_1 extends Particle
{
var arrPieces;
function Particle_1 () {
super();
}
function Configure() {
arrPieces.push({launchAngle:90});
arrPieces.push({launchAngle:-90});
}
}
Symbol 50 Button
on (release) {
getURL ("http://www.armorgames.com", "blank");
}
Symbol 57 MovieClip Frame 140
stop();
Instance of Symbol 60 MovieClip in Symbol 61 MovieClip Frame 150
on (release) {
getURL ("http://www.herointeractive.com", "_blank");
}
onClipEvent (load) {
if (_global.musicOn == true) {
_global.myMusicPlayer.SetTrack("title");
_global.myMusicPlayer.SetMaxVolume(100);
_global.myMusicPlayer.PlayWithCrossFade(4);
}
}
onClipEvent (enterFrame) {
_global.myMusicPlayer.RunPlayer();
}
Instance of Symbol 60 MovieClip in Symbol 61 MovieClip Frame 179
on (release) {
getURL ("http://www.herointeractive.com", "_blank");
}
Symbol 61 MovieClip Frame 328
_root.gotoAndPlay("splash");
Symbol 70 MovieClip Frame 1
r = random(200);
r = r + 50;
gotoAndPlay(r);
Symbol 75 MovieClip Frame 160
_root.gotoAndPlay("main menu");
stop();
Symbol 80 Button
on (release) {
gotoAndPlay ("level select");
_global.SoundManager.PlaySound("button");
}
Symbol 84 Button
on (release) {
gotoAndPlay ("settings");
_global.SoundManager.PlaySound("button");
}
Symbol 87 Button
on (release) {
gotoAndPlay ("credits");
_global.SoundManager.PlaySound("button");
}
Symbol 90 Button
on (release) {
getURL ("http://www.armorgames.com/", "_blank");
_global.SoundManager.PlaySound("button");
}
Symbol 91 MovieClip Frame 70
stop();
Symbol 93 MovieClip Frame 70
stop();
Symbol 98 Button
on (press) {
gotoAndPlay ("main menu");
_global.SoundManager.PlaySound("button");
}
Symbol 100 MovieClip Frame 1
stop();
Symbol 100 MovieClip Frame 2
stop();
Symbol 119 Button
on (press) {
_root.SelectLevel(this._name);
}
Symbol 120 MovieClip Frame 1
stop();
Symbol 120 MovieClip Frame 2
stop();
Symbol 174 MovieClip Frame 1
stop();
Symbol 174 MovieClip Frame 15
stop();
Symbol 178 MovieClip Frame 1
stop();
Symbol 178 MovieClip Frame 2
stop();
Symbol 185 Button
on (release) {
_root.Reset();
}
Symbol 189 Button
on (release) {
_root.ExitGame();
}
Symbol 193 Button
on (release) {
getURL ("http://www.armorgames.com", "_blank");
}
Symbol 194 MovieClip Frame 1
var r = Math.round(Math.random() * 5);
var badMessage = "Whoops";
switch (r) {
case 0 :
badMessage = "Whoops";
break;
case 1 :
badMessage = "Sorry!";
break;
case 2 :
badMessage = "Oops!";
break;
case 3 :
badMessage = "Miss!";
break;
case 4 :
badMessage = "Too Bad...";
break;
case 5 :
badMessage = "Uh oh...";
}
this.whoops.whoops_txt.text = badMessage;
Symbol 194 MovieClip Frame 15
stop();
Symbol 201 Button
on (release) {
trace("got here");
_root.Next();
}
Symbol 202 MovieClip Frame 15
stop();
Symbol 203 MovieClip Frame 1
stop();
Symbol 203 MovieClip Frame 10
stop();
Symbol 203 MovieClip Frame 20
stop();
Symbol 206 Button
on (press) {
gotoAndPlay ("splash");
}