home *** CD-ROM | disk | FTP | other *** search
- function toggleQuality()
- {
- if(Key.isDown(33))
- {
- _global.gameQuality = "HIGH";
- _quality = "HIGH";
- detailToggle_mc.gotoAndStop("up");
- detailText_mc.gotoAndPlay("high");
- }
- else if(Key.isDown(34))
- {
- _global.gameQuality = "LOW";
- _quality = "LOW";
- detailToggle_mc.gotoAndStop("down");
- detailText_mc.gotoAndPlay("low");
- }
- }
- function cheatSpeed()
- {
- if(!ship_mc.oldMaxSpeed)
- {
- ship_mc.oldMaxSpeed = ship_mc.maxSpeed;
- }
- if(Key.isDown(80))
- {
- ship_mc.maxSpeed = 20;
- }
- else
- {
- ship_mc.maxSpeed = ship_mc.oldMaxSpeed;
- }
- }
- function fadeOut(target)
- {
- if(target._alpha < 42)
- {
- target._alpha += 5;
- }
- }
- function setFlags()
- {
- if(_global.city.lisbon)
- {
- flagLisbon_mc.gotoAndStop("color");
- flagLisbon_mc._alpha = 100;
- }
- if(_global.city.alexandria)
- {
- flagAlexandria_mc.gotoAndStop("color");
- flagAlexandria_mc._alpha = 100;
- }
- if(_global.city.dakar)
- {
- flagDakar_mc.gotoAndStop("color");
- flagDakar_mc._alpha = 100;
- }
- if(_global.city.rioDeJaneiro)
- {
- flagRioDeJaneiro_mc.gotoAndStop("color");
- flagRioDeJaneiro_mc._alpha = 100;
- }
- if(_global.city.caracas)
- {
- flagCaracas_mc.gotoAndStop("color");
- flagCaracas_mc._alpha = 100;
- }
- if(_global.city.newOrleans)
- {
- flagNewOrleans_mc.gotoAndStop("color");
- flagNewOrleans_mc._alpha = 100;
- }
- if(_global.city.halifax)
- {
- flagHalifax_mc.gotoAndStop("color");
- flagHalifax_mc._alpha = 100;
- }
- }
- function createWaterTrail(target, x, y)
- {
- i = target.waterTrail;
- if(i % 2 && target.speed > 1.5 && Key.isDown(38))
- {
- map_mc.waterTrails_mc.attachMovie("waterTrail","waterTrail" + i + "_mc",300 + i);
- map_mc.waterTrails_mc["waterTrail" + i + "_mc"]._x = map_mc._x * -1 + x;
- map_mc.waterTrails_mc["waterTrail" + i + "_mc"]._y = map_mc._y * -1 + y;
- map_mc.waterTrails_mc["waterTrail" + i + "_mc"]._rotation = target._rotation + 30;
- }
- if(target.waterTrail < 14)
- {
- target.waterTrail += 1;
- }
- else
- {
- target.waterTrail = 0;
- }
- }
- function updateTimer()
- {
- if(!ship_mc.finished && !timer.outOfTime)
- {
- if(timer.milliseconds == 0)
- {
- timer.milliseconds = 9;
- timer.seconds -= 1;
- }
- else
- {
- timer.milliseconds -= 1;
- }
- if(timer.seconds <= 0 && timer.milliseconds <= 0)
- {
- clearInterval(timerInterval);
- timer.seconds = 0;
- timer.milliseconds = 0;
- timer.outOfTime = true;
- outOfTime_txt.text = "You\'re out of time.\nPress \"spacebar\" to try again.";
- }
- timer_txt.text = timer.seconds + "." + timer.milliseconds;
- }
- }
- function restartLeg()
- {
- if(Key.isDown(32))
- {
- clearInterval(timerInterval);
- movingSound.stop();
- _global.city[_global.nextCity] = false;
- gotoAndStop("restart");
- play();
- }
- }
- function restartRace()
- {
- if(Key.isDown(36))
- {
- clearInterval(timerInterval);
- movingSound.stop();
- gotoAndStop("selectBoat");
- play();
- }
- }
- function startNextLeg()
- {
- if(Key.isDown(35) || Key.isDown(13))
- {
- clearInterval(timerInterval);
- movingSound.stop();
- switch(_global.leg)
- {
- case "london":
- _global.londonSeconds = timer.seconds;
- _global.londonMilliseconds = timer.milliseconds;
- _global.leg = "lisbon";
- _global.nextCity = "alexandria";
- _global.nextDock = "alexandriaDock_mc";
- _global.shipRotation = 45;
- _global.startSeconds = 60;
- _global.startMilliseconds = 0;
- gotoAndStop("restart");
- play();
- break;
- case "lisbon":
- _global.lisbonSeconds = timer.seconds;
- _global.lisbonMilliseconds = timer.milliseconds;
- _global.leg = "alexandria";
- _global.nextCity = "dakar";
- _global.nextDock = "dakarDock_mc";
- _global.shipRotation = 180;
- _global.startSeconds = 60;
- _global.startMilliseconds = 0;
- gotoAndStop("restart");
- play();
- break;
- case "alexandria":
- _global.alexandriaSeconds = timer.seconds;
- _global.alexandriaMilliseconds = timer.milliseconds;
- _global.leg = "dakar";
- _global.nextCity = "rioDeJaneiro";
- _global.nextDock = "rioDeJaneiroDock_mc";
- _global.shipRotation = 90;
- _global.startSeconds = 14;
- _global.startMilliseconds = 0;
- gotoAndStop("restart");
- play();
- break;
- case "dakar":
- _global.dakarSeconds = timer.seconds;
- _global.dakarMilliseconds = timer.milliseconds;
- _global.leg = "rioDeJaneiro";
- _global.nextCity = "caracas";
- _global.nextDock = "caracasDock_mc";
- _global.shipRotation = 330;
- _global.startSeconds = 60;
- _global.startMilliseconds = 0;
- gotoAndStop("restart");
- play();
- break;
- case "rioDeJaneiro":
- _global.rioDeJaneiroSeconds = timer.seconds;
- _global.rioDeJaneiroMilliseconds = timer.milliseconds;
- _global.leg = "caracas";
- _global.nextCity = "newOrleans";
- _global.nextDock = "newOrleansDock_mc";
- _global.shipRotation = 195;
- _global.startSeconds = 25;
- _global.startMilliseconds = 0;
- gotoAndStop("restart");
- play();
- break;
- case "caracas":
- _global.caracasSeconds = timer.seconds;
- _global.caracasMilliseconds = timer.milliseconds;
- _global.leg = "newOrleans";
- _global.nextCity = "halifax";
- _global.nextDock = "halifaxDock_mc";
- _global.shipRotation = 340;
- _global.startSeconds = 20;
- _global.startMilliseconds = 0;
- gotoAndStop("restart");
- play();
- break;
- case "newOrleans":
- _global.newOrleansSeconds = timer.seconds;
- _global.newOrleansMilliseconds = timer.milliseconds;
- _global.leg = "finish";
- gotoAndStop("finish");
- play();
- }
- }
- }
- function hitLand(target)
- {
- if(map_mc.continents_mc.hitTest(target._x,target._y,true))
- {
- target.hitLand = true;
- }
- else
- {
- target.hitLand = false;
- }
- }
- function hitIceBergs(target)
- {
- if(map_mc.iceBergs_mc.hitTest(target._x,target._y,true))
- {
- target.hitIceBerg = true;
- }
- else
- {
- target.hitIceBerg = false;
- }
- }
- function hitRocks(target)
- {
- if(map_mc.rocks_mc.hitTest(target._x,target._y,true))
- {
- target.hitRock = true;
- }
- else
- {
- target.hitRock = false;
- }
- }
- function hitStorms(target)
- {
- if(stormLayer_mc.hitTest(target._x,target._y,true))
- {
- target.hitStorm = true;
- }
- else
- {
- target.hitStorm = false;
- }
- }
- function hitWhales(target)
- {
- if(map_mc.whales_mc.hitTest(target._x,target._y,true))
- {
- target.hitWhale = true;
- }
- else
- {
- target.hitWhale = false;
- }
- }
- function hitDock(target, dock)
- {
- if(map_mc.docks_mc[_global.nextDock].hitTest(target._x,target._y,true) && target.speed < 0.5 && target.momentumSpeed < 0.5)
- {
- if(!target.city[_global.nextCity])
- {
- clearInterval(timerInterval);
- movingSound.stop();
- welcomeText_mc.gotoAndPlay(_global.nextCity);
- cheeringSound = new Sound(this);
- cheeringSound.attachSound("cheering");
- cheeringSound.start();
- target.finished = true;
- _global.city[_global.nextCity] = true;
- setFlags();
- nextPortArrow_mc.removeMovieClip();
- _quality = "HIGH";
- }
- }
- }
- function moveBG(target, bg)
- {
- bg._x -= Math.cos(target.radians) * target.speed + Math.cos(target.momentumRad) * target.momentumSpeed;
- bg._y -= Math.sin(target.radians) * target.speed + Math.sin(target.momentumRad) * target.momentumSpeed;
- }
- function moveClouds(target, bg)
- {
- bg._x -= (Math.cos(target.radians) * target.speed + Math.cos(target.momentumRad) * target.momentumSpeed) * 2;
- bg._y -= (Math.sin(target.radians) * target.speed + Math.sin(target.momentumRad) * target.momentumSpeed) * 2;
- }
- function turnIt(target)
- {
- if(Key.isDown(37))
- {
- target._rotation -= target.turning;
- target.degrees -= target.turning;
- if(target.degrees < 0)
- {
- target.degrees += 360;
- }
- shipLayer_mc.ship3d_mc.gotoAndStop(Math.floor(target.degrees / 12));
- }
- if(Key.isDown(39))
- {
- target._rotation += target.turning;
- target.degrees += target.turning;
- if(target.degrees > 360)
- {
- target.degrees -= 360;
- }
- shipLayer_mc.ship3d_mc.gotoAndStop(Math.floor(target.degrees / 12));
- }
- if(target.hitStorm)
- {
- if(!_global.thunderPlaying)
- {
- thunderSound.start();
- _global.thunderPlaying = true;
- }
- target._rotation += target.turning * 2;
- target.degrees += target.turning * 2;
- if(target.degrees > 360)
- {
- target.degrees -= 360;
- }
- shipLayer_mc.ship3d_mc.gotoAndStop(Math.floor(target.degrees / 12));
- }
- target.radians = (target._rotation + 30) * 3.141592653589793 / 180;
- }
- function changeSpeed(target)
- {
- target.momentumSpeed *= 0.97;
- if(target.momentumSpeed < 0.05)
- {
- target.momentumSpeed = 0;
- }
- if(Key.isDown(38) && target.speed < target.maxSpeed)
- {
- target.speed += target.acceleration;
- if(target.speed > target.maxSpeed)
- {
- target.speed = target.maxSpeed;
- }
- if(target.momentumSpeed < target.speed)
- {
- target.momentumSpeed = target.speed;
- }
- target.momentumRad = target.radians;
- }
- else
- {
- target.speed *= 0.96;
- }
- if(Key.isDown(40) && target.speed > 0)
- {
- target.speed -= target.braking;
- if(target.speed < 0.05)
- {
- target.speed = 0;
- }
- }
- if(target.speed < 0.05)
- {
- target.speed = 0;
- }
- if(target.hitLand)
- {
- target.speed = 0.5;
- target.momentumSpeed = 0;
- if(pointsMinus_mc._currentframe == 1)
- {
- pointsMinus_mc.displayText = "4";
- pointsMinus_mc.gotoAndPlay("start");
- if(timer.seconds >= 4)
- {
- timer.seconds -= 4;
- }
- else
- {
- timer.seconds = 0;
- }
- }
- }
- else if(target.hitIceBerg)
- {
- target.speed = 0.5;
- target.momentumSpeed = 0;
- if(pointsMinus_mc._currentframe == 1)
- {
- pointsMinus_mc.displayText = "3";
- pointsMinus_mc.gotoAndPlay("start");
- if(timer.seconds >= 3)
- {
- timer.seconds -= 3;
- }
- else
- {
- timer.seconds = 0;
- }
- }
- }
- else if(target.hitRock)
- {
- target.speed = 0.5;
- target.momentumSpeed = 0;
- if(pointsMinus_mc._currentframe == 1)
- {
- pointsMinus_mc.displayText = "2";
- pointsMinus_mc.gotoAndPlay("start");
- if(timer.seconds >= 2)
- {
- timer.seconds -= 2;
- }
- else
- {
- timer.seconds = 0;
- }
- }
- }
- else if(target.hitWhale)
- {
- target.speed = 0.5;
- target.momentumSpeed = 0;
- if(pointsMinus_mc._currentframe == 1)
- {
- pointsMinus_mc.displayText = "3";
- pointsMinus_mc.gotoAndPlay("start");
- if(timer.seconds >= 3)
- {
- timer.seconds -= 3;
- }
- else
- {
- timer.seconds = 0;
- }
- }
- }
- movingSound.setVolume(target.speed * 10 + target.momentumSpeed * 10);
- }
- stop();
- _quality = _global.gameQuality;
- detailToggle_mc._visible = true;
- soundToggle_mc._visible = true;
- soundToggle_mc.onRelease = function()
- {
- if(openingSound.getVolume() > 0)
- {
- soundToggle_mc.gotoAndStop("down");
- openingSound.setVolume(0);
- }
- else
- {
- soundToggle_mc.gotoAndStop("up");
- openingSound.setVolume(100);
- }
- };
- ship_mc._rotation = _global.shipRotation;
- switch(_global.shipClass)
- {
- case "A":
- shipLayer_mc.attachMovie("shipA","ship3d_mc",1);
- shipLayer_mc.ship3d_mc._x = 231;
- shipLayer_mc.ship3d_mc._y = 178;
- ship_mc.radians = (ship_mc._rotation + 30) * 3.141592653589793 / 180;
- ship_mc.maxSpeed = 6;
- ship_mc.acceleration = 0.1;
- ship_mc.braking = 2;
- ship_mc.turning = 12;
- break;
- case "B":
- shipLayer_mc.attachMovie("shipB","ship3d_mc",1);
- shipLayer_mc.ship3d_mc._x = 231;
- shipLayer_mc.ship3d_mc._y = 178;
- ship_mc.radians = (ship_mc._rotation + 30) * 3.141592653589793 / 180;
- ship_mc.maxSpeed = 5.5;
- ship_mc.acceleration = 0.2;
- ship_mc.braking = 2;
- ship_mc.turning = 12;
- break;
- case "C":
- shipLayer_mc.attachMovie("shipC","ship3d_mc",1);
- shipLayer_mc.ship3d_mc._x = 231;
- shipLayer_mc.ship3d_mc._y = 178;
- ship_mc.radians = (ship_mc._rotation + 30) * 3.141592653589793 / 180;
- ship_mc.maxSpeed = 5;
- ship_mc.acceleration = 0.5;
- ship_mc.braking = 2;
- ship_mc.turning = 12;
- }
- ship_mc.degrees = _global.shipRotation;
- shipLayer_mc.ship3d_mc.gotoAndStop(Math.floor(ship_mc.degrees / 12));
- ship_mc.momentumRad = ship_mc.radians;
- ship_mc.momentumSpeed = 0;
- ship_mc.speed = 0;
- ship_mc.waterTrail = 0;
- ship_mc.orangeBuoys = 0;
- ship_mc.hitLand = false;
- ship_mc.hitIceBerg = false;
- ship_mc.hitRock = false;
- ship_mc.hitStorm = false;
- ship_mc.finished = false;
- ship_mc.onEnterFrame = function()
- {
- if(!ship_mc.finished && !timer.outOfTime)
- {
- toggleQuality();
- moveBG(this,map_mc);
- changeSpeed(this);
- turnIt(this);
- hitLand(this);
- hitDock(this,_global.nextDock);
- hitIceBergs(this);
- hitRocks(this);
- hitStorms(this);
- hitWhales(this);
- restartRace();
- restartLeg();
- }
- else if(ship_mc.finished)
- {
- startNextLeg();
- restartRace();
- fadeOut(fadeToBlack_mc);
- }
- else if(timer.outOfTime)
- {
- restartLeg();
- restartRace();
- fadeOut(fadeToBlack_mc);
- }
- };
- thunderSound = new Sound(this);
- thunderSound.attachSound("thunder");
- thunderSound.onSoundComplete = function()
- {
- _global.thunderPlaying = false;
- };
- movingSound.stop();
- movingSound = new Sound(ship_mc);
- movingSound.attachSound("moving");
- movingSound.start(0,2);
- detailToggle_mc.onRelease = function()
- {
- if(_global.gameQuality == "LOW")
- {
- _global.gameQuality = "HIGH";
- _quality = "HIGH";
- detailToggle_mc.gotoAndStop("up");
- detailText_mc.gotoAndPlay("high");
- }
- else if(_global.gameQuality == "HIGH")
- {
- _global.gameQuality = "LOW";
- _quality = "LOW";
- detailToggle_mc.gotoAndStop("down");
- detailText_mc.gotoAndPlay("low");
- }
- };
- attachMovie("nextPortArrow","nextPortArrow_mc",8989);
- nextPortArrow_mc._x = 218;
- nextPortArrow_mc._y = 164;
- nextPortArrow_mc.onEnterFrame = function()
- {
- portY = map_mc._y + map_mc.docks_mc[_global.nextDock]._y - 164;
- portX = map_mc._x + map_mc.docks_mc[_global.nextDock]._x - 218;
- angle = Math.atan2(portY,portX);
- angle = angle * 180 / 3.141592653589793;
- nextPortArrow_mc._rotation = angle;
- };
- timer = new Object();
- timer.outOfTime = false;
- timer.seconds = _global.startSeconds;
- timer.milliseconds = _global.startMilliseconds;
- timerInterval = setInterval(updateTimer,100);
- cloudLayer_mc.attachMovie("clouds","clouds_mc",200);
- cloudLayer_mc.clouds_mc._alpha = 80;
- cloudLayer_mc.clouds_mc.onEnterFrame = function()
- {
- if(!ship_mc.finished && !timer.outOfTime)
- {
- moveClouds(ship_mc,this);
- }
- if(this._x > 1000)
- {
- this._x = -1000;
- }
- if(this._x < -1000)
- {
- this._x = 1000;
- }
- if(this._y > 700)
- {
- this._y = -700;
- }
- if(this._y < -700)
- {
- this._y = 700;
- }
- };
- setFlags();
-