Frame 1
stop();
Frame 2
Engine.init();
Engine.loadSounds();
Engine.playSound(Engine.SOUND_OFF_THE_WRIST_MUSIC, 1, 20);
if (Engine.SKIP_SPLASH) {
gotoAndStop ("title");
}
Frame 236
gotoAndStop ("title");
Frame 265
var textFormat = new TextFormat();
textFormat.bold = true;
textFormat.font = "04b19";
textFormat.size = 30;
textFormat.color = 16777215 /* 0xFFFFFF */;
Text.init(textFormat);
Text.floobyText("PRIMORDIAL SOUP", 320, 430, Text.CENTRE, 0, 42);
Engine.playSound(Engine.SOUND_TITLE_MUSIC, 10000);
Frame 266
Symbol 70 Button
on (release) {
Engine.closeHelp();
}
on (rollOver) {
_root.playButton._xscale = (_root.playButton._yscale = _root.playButton._yscale + 5);
}
on (rollOut) {
_root.playButton._xscale = (_root.playButton._yscale = _root.playButton._yscale - 5);
}
Symbol 110 MovieClip Frame 1
bytesLoaded = _root.getBytesLoaded();
bytesTotal = _root.getBytesTotal();
percentSetup = (bytesLoaded / bytesTotal) * 100;
percentage = int(percentSetup) + "%";
setProperty("_root.DropIn.LoaderBar", _xscale , percentSetup);
if (bytesLoaded == bytesTotal) {
_root.gotoAndPlay("splash");
}
Symbol 110 MovieClip Frame 2
if (bytesLoaded < bytesTotal) {
_root.DropIn.gotoAndPlay(1);
}
Symbol 157 MovieClip [__Packages.Engine] Frame 0
class Engine
{
static var scoreText, score, levelText, gotoEnd, help, pointer, state, level, babyCount, livesLost, babySpeed, gameOver, almostGameOver, levelColourCool, scoreColourCool, bgRatios, bgColours, bgAlphas, mousePlanktonSourceLayer;
function Engine () {
}
static function init() {
if (PREVENT_THEFT) {
var _local12 = _root._url;
if (_local12.indexOf("www.offthewrist.com") == -1) {
getURL ("http://www.offthewrist.com/index.jsp?content=primordial_soup/index.html");
}
}
var _local8 = 0.01;
var _local3 = 0;
while (_local3 < LAYER_COUNT) {
var _local5 = new Layer(_local3, _local8);
layers.push(_local5);
_local8 = _local8 + LAYER_DEPTH_SEPARATION;
_local3++;
}
_local3 = 0;
while (_local3 < PLANKTON_COUNT) {
var _local7 = new Plankton(_local3);
allPlankton.push(_local7);
_local3++;
}
_local3 = 0;
while (_local3 < BUBBLE_COUNT) {
var _local6 = new Bubble(_local3);
bubbles.push(_local6);
_local3++;
}
_local3 = 0;
while (_local3 < LIGHT_COUNT) {
var _local2 = new Light(_local3);
lights.push(_local2);
_local3++;
}
_local3 = 0;
while (_local3 < MOVING_SYMBOL_COUNT) {
var _local4 = new MovingSymbol();
movingSymbols.push(_local4);
_local3++;
}
var _local10 = new Object();
_local10.onMouseWheel = function (d) {
if (d > 0) {
Engine.zoomCamera(1);
} else {
Engine.zoomCamera(-1);
}
};
_local10.onMouseDown = function () {
Engine.mousePressed();
};
Mouse.addListener(_local10);
var _local9 = new TextFormat();
_local9.bold = true;
_local9.font = "04b19";
_local9.size = 30;
_local9.color = 16777215 /* 0xFFFFFF */;
Text.init(_local9);
scoreText = _root.createTextField("scoreText", 900, 2, 2, 530, 100);
scoreText.setNewTextFormat(_local9);
scoreText.embedFonts = true;
scoreText.selectable = false;
score = 0;
levelText = _root.createTextField("levelText", 901, 280, 2, 530, 100);
levelText.setNewTextFormat(_local9);
levelText.embedFonts = true;
levelText.selectable = false;
_local3 = LIFE_COUNT;
while (_local3-- , _local3 >= 0) {
var _local2 = _root.attachMovie("heartClip", "life" + _local3, 800 + _local3);
_local2._x = (WIDTH - 20) - (_local3 * 36);
_local2._y = 16;
lives.push(_local2);
_local2._visible = false;
}
gotoEnd = false;
help = _root.attachMovie("help", "help", _root.getNextHighestDepth());
help._x = WIDTH / 2;
help._y = HEIGHT / 2;
help._visible = false;
Mouse.hide();
pointer = _root.attachMovie("pointerClip", "pointer", _root.getNextHighestDepth());
var _local11 = _root.createEmptyMovieClip("update", _root.getNextHighestDepth());
_local11.onEnterFrame = function () {
Engine.update();
};
_local11.onKeyDown = function () {
Engine.keyPressed();
};
Key.addListener(_local11);
setGameVisible(false);
state = STATE_INACTIVE;
}
static function reset() {
level = 1;
babyCount = 0;
livesLost = 0;
cameraZ = (cameraLayer = (cameraTargetZ = 0));
var _local2 = LIFE_COUNT;
while (_local2-- , _local2 >= 0) {
lives[_local2]._visible = true;
}
addPoints(-score);
levelText.text = "LEVEL: " + level;
babySpeed = INITIAL_BABY_SPEED;
_local2 = PLANKTON_COUNT;
while (_local2-- , _local2 >= 0) {
allPlankton[_local2].deactivate();
}
_local2 = 0;
while (_local2 < LAYER_COUNT) {
layers[_local2].init();
_local2++;
}
_local2 = allPlankton.length;
while (_local2-- , _local2 >= 0) {
if (allPlankton[_local2].active) {
allPlankton[_local2].celebrate();
}
}
gameOver = (almostGameOver = false);
playSound(SOUND_AMBIENT_MUSIC, 10000, 20);
_root.progressMeter.gotoAndStop(1);
setGameVisible(true);
state = STATE_GAME;
}
static function showHelp() {
setGameVisible(false);
help._visible = true;
state = STATE_HELP;
_root.helpicon._visible = false;
_root.progressMeter._visible = false;
}
static function closeHelp() {
help._visible = false;
setGameVisible(true);
state = STATE_GAME;
playSound(SOUND_ZOOM_IN);
_root.helpicon._visible = true;
_root.progressMeter._visible = true;
}
static function babySaved() {
babyCount++;
_root.progressMeter.gotoAndStop(1 + babyCount);
if (babyCount >= BABIES_PER_LEVEL) {
Text.floobyText("LEVEL UP!", WIDTH / 2, HEIGHT / 2, Text.CENTRE, 200);
playSound(SOUND_LEVEL_COMPLETE_MUSIC);
level++;
levelText.text = "LEVEL: " + level;
levelText.textColor = 16776960 /* 0xFFFF00 */;
levelColourCool = 0;
babySpeed = babySpeed + BABY_SPEED_LEVEL_INCREASE;
babyCount = 0;
var _local2 = allPlankton.length;
while (_local2-- , _local2 >= 0) {
if (allPlankton[_local2].active) {
allPlankton[_local2].celebrate();
}
}
}
}
static function addPoints(points) {
score = score + points;
scoreText.text = "SCORE: " + score;
scoreText.textColor = 16776960 /* 0xFFFF00 */;
scoreColourCool = 0;
}
static function planktonKilled() {
if (livesLost == (LIFE_COUNT - 1)) {
almostGameOver = true;
}
}
static function lostLife() {
if (gameOver) {
return(undefined);
}
lives[livesLost]._visible = false;
livesLost++;
if ((livesLost == LIFE_COUNT) && (!NEVER_DIE)) {
Text.floobyText("GAME OVER", WIDTH / 2, HEIGHT / 2, Text.CENTRE, 300);
gameOver = true;
stopAllSound();
playSound(SOUND_GAME_OVER_MUSIC);
if (mousePlankton != undefined) {
var _local2 = layers[cameraLayer];
_local2.insertPlankton(mousePlankton);
mousePlankton.graphic._rotation = 0;
mousePlankton = undefined;
}
var _local1 = allPlankton.length;
while (_local1-- , _local1 >= 0) {
allPlankton[_local1].kill();
}
}
}
static function notifyHighScoresClosed() {
gotoEnd = true;
}
static function notifyTextFinished(text) {
if (text == "GAME OVER") {
if (score > 0) {
if (HIGHSCORES_AVAILABLE) {
_root.playAtOTWButton._visible = false;
HighScores.init(GAME_NAME, GAME_ID, score, false, 3368601, 3355494, 3381759, Text.textFormat, pointer);
} else {
_root.playAtOTWButton._visible = true;
gotoEnd = true;
}
} else {
gotoEnd = true;
}
} else if (text == "LEVEL UP!") {
_root.progressMeter.gotoAndStop(1);
}
}
static function mousePressed() {
if (((state != STATE_GAME) || (gameOver)) || (almostGameOver)) {
return(undefined);
}
if (mousePlankton == undefined) {
var _local2 = layers[cameraLayer];
_local2.checkPlanktonClick(_root._xmouse, _root._ymouse);
} else {
dropMousePlankton();
}
}
static function updateGradientBackground() {
with (_root.gradientBackground) {
bgRatios[0] = (Math.sin(countTo360) * 32) + 64;
beginGradientFill("linear", bgColours, bgAlphas, bgRatios, bgMatrix, "reflect", "RGB", 0.9);
moveTo(0, 0);
lineTo(0, Stage.height);
lineTo(Stage.width, Stage.height);
lineTo(Stage.width, 0);
lineTo(0, 0);
endFill();
}
}
static function requestMovingSymbol(name, lid, x, y, z, scale) {
var _local2;
var _local1 = 0;
while (_local1 < MOVING_SYMBOL_COUNT) {
_local2 = movingSymbols[_local1];
if (!_local2.active) {
_local2.init(name, lid, x, y, z, scale);
return(_local2);
}
_local1++;
}
return(undefined);
}
static function update() {
Text.update();
Mouse.hide();
pointer._x = _root._xmouse;
pointer._y = _root._ymouse;
pointer.swapDepths(_root.getNextHighestDepth());
if (state == STATE_GAME) {
if (gotoEnd) {
gotoEnd = false;
setGameVisible(false);
_root.gotoAndStop("end");
Text.floobyText("PLAY AGAIN?", WIDTH / 4, 30, Text.CENTRE, 0, 20);
}
if (gameOver) {
return(undefined);
}
if (scoreColourCool < 255) {
scoreColourCool = scoreColourCool + 8;
if (scoreColourCool > 255) {
scoreColourCool = 255;
}
scoreText.textColor = 16776960 + scoreColourCool;
}
if (levelColourCool < 255) {
levelColourCool = levelColourCool + 8;
if (levelColourCool > 255) {
levelColourCool = 255;
}
levelText.textColor = 16776960 + levelColourCool;
}
countTo360 = countTo360 + 0.1;
if (countTo360 > 360) {
countTo360 = countTo360 - 360;
}
if (mousePlankton != undefined) {
mousePlankton.graphic._x = _root._xmouse;
mousePlankton.graphic._y = _root._ymouse;
mousePlankton.worldZ = cameraZ;
}
var _local2 = 0;
while (_local2 < LAYER_COUNT) {
layers[_local2].update();
_local2++;
}
if (cameraState == CAMERA_STATE_ZOOM_IN) {
cameraZ = cameraZ + CAMERA_SPEED;
if (cameraZ > cameraTargetZ) {
cameraZ = cameraTargetZ;
cameraState = CAMERA_STATE_STATIC;
cameraLayer++;
if (mousePlankton != undefined) {
mousePlankton.setDepth(cameraLayer);
}
}
} else if (cameraState == CAMERA_STATE_ZOOM_OUT) {
cameraZ = cameraZ - CAMERA_SPEED;
if (cameraZ < cameraTargetZ) {
cameraZ = cameraTargetZ;
cameraState = CAMERA_STATE_STATIC;
cameraLayer--;
if (mousePlankton != undefined) {
mousePlankton.setDepth(cameraLayer);
}
}
}
}
}
static function setGameVisible(flag) {
var _local1 = 0;
while (_local1 < PLANKTON_COUNT) {
if (allPlankton[_local1].active) {
allPlankton[_local1].graphic._visible = flag;
}
_local1++;
}
_local1 = 0;
while (_local1 < BUBBLE_COUNT) {
bubbles[_local1].graphic._visible = flag;
_local1++;
}
_local1 = 0;
while (_local1 < LIGHT_COUNT) {
lights[_local1].graphic._visible = flag;
_local1++;
}
_local1 = 0;
while (_local1 < LIFE_COUNT) {
if (_local1 >= livesLost) {
lives[_local1]._visible = flag;
}
_local1++;
}
scoreText._visible = flag;
levelText._visible = flag;
}
static function dropMousePlankton() {
if (cameraState != CAMERA_STATE_STATIC) {
return(undefined);
}
if (gameOver || (almostGameOver)) {
return(undefined);
}
var _local1 = layers[cameraLayer];
_local1.insertPlankton(mousePlankton);
mousePlankton.graphic._rotation = 0;
if (((mousePlankton.imageId == _local1.id) && (_local1.id != mousePlanktonSourceLayer)) && (mousePlankton.birthLayer != _local1.id)) {
playSound(SOUND_DROP_BABY);
addPoints(1000);
babySaved();
} else {
playSound(SOUND_DROP_ADULT);
}
mousePlankton = undefined;
}
static function setMousePlankton(p) {
if (gameOver || (almostGameOver)) {
return(undefined);
}
mousePlankton = p;
mousePlankton.countTo360 = 90;
mousePlanktonSourceLayer = p.layer.id;
playSound(SOUND_PLANKTON_AMBIENT0 + mousePlankton.imageId);
if ((p.imageId != mousePlanktonSourceLayer) && (!p.rescued)) {
addPoints(Math.floor((1 - p.size) * 10) * 100);
p.rescued = true;
}
}
static function zoomCamera(dir) {
if ((gameOver || (almostGameOver)) || (state != STATE_GAME)) {
return(undefined);
}
if (dir > 0) {
if ((cameraState == CAMERA_STATE_STATIC) && (cameraLayer < (LAYER_COUNT - 1))) {
cameraState = CAMERA_STATE_ZOOM_IN;
cameraTargetZ = LAYER_DEPTH_SEPARATION * (cameraLayer + 1);
playSound(SOUND_BUBBLE);
}
} else if ((cameraState == CAMERA_STATE_STATIC) && (cameraLayer > 0)) {
cameraState = CAMERA_STATE_ZOOM_OUT;
cameraTargetZ = LAYER_DEPTH_SEPARATION * (cameraLayer - 1);
playSound(SOUND_ZOOM_OUT);
}
}
static function keyPressed() {
var _local1 = Key.getCode();
switch (_local1) {
case 65 :
zoomCamera(1);
break;
case 90 :
zoomCamera(-1);
}
}
static function activatePlankton(layer, type, startX, startY, size) {
var _local1 = 0;
while (_local1 < PLANKTON_COUNT) {
if (!allPlankton[_local1].active) {
allPlankton[_local1].activate(layer, type, startX, startY, size);
return(allPlankton[_local1]);
}
_local1++;
}
}
static function loadSounds() {
var _local1 = 0;
while (_local1 < SOUNDCOUNT) {
var _local2 = new Sound();
_local2.attachSound("sound" + _local1);
sounds.push(_local2);
_local1++;
}
}
static function playSound(i, loop, volume) {
if (SOUND) {
if (volume != undefined) {
sounds[i].setVolume(volume);
}
sounds[i].start(0, loop);
}
}
static function stopAllSound() {
var _local1 = 0;
while (_local1 < SOUNDCOUNT) {
sounds[_local1].stop();
_local1++;
}
}
static var GAME_ID = 4;
static var GAME_NAME = "primordial_soup";
static var SOUND = true;
static var SKIP_SPLASH = false;
static var NEVER_DIE = false;
static var PREVENT_THEFT = false;
static var HIGHSCORES_AVAILABLE = false;
static var STATE_INACTIVE = 0;
static var STATE_GAME = 1;
static var STATE_HELP = 2;
static var TO_RADIANS = (Math.PI/180);
static var PLANKTON_COUNT = 20;
static var LAYER_COUNT = 3;
static var MOVING_SYMBOL_COUNT = 15;
static var LIFE_COUNT = 3;
static var LAYER_DEPTH_SEPARATION = 1 / (LAYER_COUNT - 1);
static var BUBBLE_COUNT = 20;
static var LIGHT_COUNT = 10;
static var WIDTH = Stage.width;
static var HEIGHT = Stage.height;
static var HALFWIDTH = WIDTH / 2;
static var HALFHEIGHT = HEIGHT / 2;
static var WORLDWIDTH = 400;
static var WORLDHEIGHT = 300;
static var HALFWORLDWIDTH = WORLDWIDTH / 2;
static var HALFWORLDHEIGHT = WORLDHEIGHT / 2;
static var BABIES_PER_LEVEL = 10;
static var INITIAL_BABY_SPEED = 0.3;
static var BABY_SPEED_LEVEL_INCREASE = 0.1;
static var POSITION_PERSPECTIVE = 0.7;
static var SCALE_PERSPECTIVE = 1;
static var CAMERA_STATE_STATIC = 0;
static var CAMERA_STATE_ZOOM_IN = 1;
static var CAMERA_STATE_ZOOM_OUT = 2;
static var CAMERA_SPEED = 0.08;
static var allPlankton = new Array();
static var layers = new Array();
static var movingSymbols = new Array();
static var bubbles = new Array();
static var lights = new Array();
static var cameraZ = 0;
static var cameraTargetZ = 0;
static var cameraLayer = 0;
static var cameraState = CAMERA_STATE_STATIC;
static var mousePlankton = undefined;
static var countTo360 = 0;
static var bgMatrix = new flash.geom.Matrix();
static var lives = new Array();
static var SOUNDCOUNT = 21;
static var SOUND_OFF_THE_WRIST_MUSIC = 0;
static var SOUND_TITLE_MUSIC = 1;
static var SOUND_LEVEL_COMPLETE_MUSIC = 2;
static var SOUND_GAME_OVER_MUSIC = 3;
static var SOUND_PLANKTON_AMBIENT0 = 4;
static var SOUND_PLANKTON_AMBIENT1 = 5;
static var SOUND_PLANKTON_AMBIENT2 = 6;
static var SOUND_PICKUP_ADULT = 7;
static var SOUND_DROP_ADULT = 8;
static var SOUND_PICKUP_BABY = 9;
static var SOUND_DROP_BABY = 10;
static var SOUND_LOVE = 11;
static var SOUND_HATE = 12;
static var SOUND_DIE = 13;
static var SOUND_FEAR0 = 14;
static var SOUND_FEAR1 = 15;
static var SOUND_BIRTH = 16;
static var SOUND_BUBBLE = 17;
static var SOUND_ZOOM_IN = 18;
static var SOUND_ZOOM_OUT = 19;
static var SOUND_AMBIENT_MUSIC = 20;
static var sounds = new Array();
}
Symbol 158 MovieClip [__Packages.Plankton] Frame 0
class Plankton
{
var id, graphic, active, layer, imageId, worldZ, size, birthLayer, worldX, worldY, layerScale, angle, speed, rotateSpeed, countTo360, busyCount, fearCount, underAttack, rescued, state, maxAlpha, celebrateSpinSpeed, targetPlankton, targetX, targetY, sinTo360, cosTo360, exclaim;
function Plankton (i) {
id = i;
graphic = _root.attachMovie("all", "plankton" + id, id + 100);
var self = this;
graphic.onEnterFrame = function () {
self.update();
};
graphic._visible = false;
active = false;
}
function activate(l, imgId, startX, startY, _size) {
layer = l;
imageId = imgId;
worldZ = layer.z;
size = _size;
birthLayer = l.id;
setDepth(layer.id);
worldX = startX;
worldY = startY;
updateGraphic();
graphic._xscale = layerScale;
graphic._yscale = layerScale;
graphic._rotation = 0;
angle = Math.random() * 360;
speed = 1;
rotateSpeed = 0;
countTo360 = Math.floor(Math.random() * 360);
busyCount = 20 + Math.floor(Math.random() * 40);
fearCount = 0;
active = true;
underAttack = false;
graphic._visible = true;
setFrame(1);
rescued = false;
state = STATE_IDLE;
}
function setDepth(i) {
graphic.swapDepths((id + 100) + ((2 - i) * 1000));
}
function setFrame(i) {
graphic.gotoAndStop(i + (imageId * 4));
}
function updateGraphic() {
if (state == STATE_DEAD) {
return(undefined);
}
var _local2 = worldZ - Engine.cameraZ;
if (_local2 >= 0) {
graphic._x = (worldX / (1 + (_local2 * Engine.POSITION_PERSPECTIVE))) + Engine.HALFWIDTH;
graphic._y = (worldY / (1 + (_local2 * Engine.POSITION_PERSPECTIVE))) + Engine.HALFHEIGHT;
layerScale = (100 * size) / (1 + (_local2 * Engine.SCALE_PERSPECTIVE));
} else {
graphic._x = (worldX * (1 + ((-_local2) * Engine.POSITION_PERSPECTIVE))) + Engine.HALFWIDTH;
graphic._y = (worldY * (1 + ((-_local2) * Engine.POSITION_PERSPECTIVE))) + Engine.HALFHEIGHT;
layerScale = (100 * size) * (1 + ((-_local2) * Engine.SCALE_PERSPECTIVE));
}
if (Engine.cameraLayer == layer.id) {
maxAlpha = 100;
} else if (_local2 > 0) {
maxAlpha = 50;
} else {
var _local3 = _local2;
if (_local3 < (-Engine.LAYER_DEPTH_SEPARATION)) {
_local3 = -Engine.LAYER_DEPTH_SEPARATION;
}
_local3 = (-Engine.LAYER_DEPTH_SEPARATION) - _local3;
graphic._alpha = (maxAlpha = Math.floor((_local3 * 100) / (-Engine.LAYER_DEPTH_SEPARATION)));
}
}
function celebrate() {
becomeNormal();
state = STATE_CELEBRATING;
celebrateSpinSpeed = CELEBRATE_INITIAL_SPIN_SPEED;
}
function fallInLove(l, targetOffsetX, targetOffsetY) {
state = STATE_HEADING_FOR_LOVER;
targetPlankton = l;
targetX = worldX + targetOffsetX;
targetY = worldY + targetOffsetY;
angle = getAngle(targetOffsetX, targetOffsetY);
}
function attack(t) {
if (Engine.gameOver) {
return(undefined);
}
targetPlankton = t;
targetPlankton.underAttack = true;
setFrame(2);
speed = 4;
state = STATE_HEADING_FOR_ENEMY;
Engine.playSound(Engine.SOUND_HATE);
}
function getDistance(dx, dy) {
return(Math.sqrt((dx * dx) + (dy * dy)));
}
function getAngle(dx, dy) {
var _local1 = ((Math.atan2(dy, dx) * 180) / Math.PI) + 90;
if (_local1 < 0) {
_local1 = _local1 + 360;
}
return(_local1);
}
function deactivate() {
active = false;
graphic._visible = false;
if (layer != undefined) {
layer.removeMe(this);
}
}
function update() {
if ((!active) || (Engine.state != Engine.STATE_GAME)) {
return(undefined);
}
countTo360 = countTo360 + COUNT_TO_360_SPEED;
var _local4 = false;
if (countTo360 > 360) {
countTo360 = countTo360 - 360;
_local4 = true;
}
if (state != STATE_DEAD) {
sinTo360 = Math.sin(countTo360 * TO_RADIANS);
cosTo360 = Math.cos(countTo360 * TO_RADIANS);
}
_local4 = _local4 && (cosTo360 >= 0);
graphic._xscale = layerScale + ((sinTo360 * PULSE_AMOUNT) * size);
graphic._yscale = layerScale + ((cosTo360 * PULSE_AMOUNT) * size);
if (exclaim != undefined) {
if (!exclaim.active) {
exclaim = undefined;
} else {
exclaim.worldX = worldX;
exclaim.worldY = worldY - EXCLAIM_OFFSET_Y;
}
}
if (((state != STATE_DEAD) && (state != STATE_OLD_AGE)) && (maxAlpha != 0)) {
graphic._alpha = maxAlpha - ((sinTo360 + 1) * 10);
}
if ((this != Engine.mousePlankton) && (size < 1)) {
size = size + GROW_SPEED;
if (size > 1) {
size = 1;
speed = 1;
busyCount = 100;
}
}
if (this == Engine.mousePlankton) {
graphic._rotation = graphic._rotation + (sinTo360 * 10);
return(undefined);
}
if (state != STATE_WAITING_FOR_LOVER) {
if (size < 1) {
speed = Engine.WORLDWIDTH - getDistance(graphic._x - _root._xmouse, graphic._y - _root._ymouse);
speed = speed / (150 * size);
speed = speed * Engine.babySpeed;
}
worldX = worldX + ((Math.sin(angle * TO_RADIANS) * (cosTo360 + 1.5)) * speed);
worldY = worldY - ((Math.cos(angle * TO_RADIANS) * (cosTo360 + 1.5)) * speed);
}
if ((state != STATE_HEADING_FOR_LOVER) && (state != STATE_DEAD)) {
if (worldX > Engine.HALFWORLDWIDTH) {
worldX = Engine.HALFWORLDWIDTH;
angle = (Math.random() * 90) + 225;
} else if (worldX < (-Engine.HALFWORLDWIDTH)) {
worldX = -Engine.HALFWORLDWIDTH;
angle = (Math.random() * 90) + 45;
} else if (worldY > Engine.HALFWORLDHEIGHT) {
worldY = Engine.HALFWORLDHEIGHT;
angle = (Math.random() * 90) - 45;
} else if (worldY < (-Engine.HALFWORLDHEIGHT)) {
worldY = -Engine.HALFWORLDHEIGHT;
angle = (Math.random() * 90) + 135;
}
}
updateGraphic();
switch (state) {
case STATE_CELEBRATING :
graphic._rotation = graphic._rotation + celebrateSpinSpeed;
graphic.angle = graphic._rotation;
celebrateSpinSpeed = celebrateSpinSpeed - CELEBRATE_SPIN_SPEED_DECAY;
if (celebrateSpinSpeed < 0) {
celebrateSpinSpeed = 0;
state = STATE_CELEBRATE_COOLDOWN;
}
break;
case STATE_CELEBRATE_COOLDOWN :
if (graphic._rotation > 10) {
graphic._rotation = graphic._rotation - 10;
} else if (graphic._rotation < -10) {
graphic._rotation = graphic._rotation + 10;
} else {
graphic._rotation = 0;
state = STATE_IDLE;
}
break;
case STATE_OLD_AGE :
graphic._alpha = graphic._alpha - 0.4;
if (graphic._alpha < 0) {
deactivate();
}
break;
case STATE_DEAD :
size = size + 0.1;
graphic._alpha = graphic._alpha - 1;
graphic._rotation = graphic._rotation + DEAD_SPIN_SPEED;
if (graphic._alpha < 0) {
deactivate();
Engine.lostLife();
Engine.playSound(Engine.SOUND_DIE);
}
break;
case STATE_IDLE :
if (_local4) {
if (size < 1) {
var _local5 = 60 * (2 - size);
angle = angle + ((Math.random() * _local5) - (_local5 / 2));
} else {
angle = angle + ((Math.random() * 2) - 1);
}
if ((imageId != layer.id) && (!Engine.gameOver)) {
if ((++fearCount) > 5) {
fearCount = 0;
if (size < 0.8) {
Engine.playSound(Engine.SOUND_FEAR0);
} else {
Engine.playSound(Engine.SOUND_FEAR1);
}
}
exclaim = Engine.requestMovingSymbol("exclaimClip", layer.id, worldX, worldY - EXCLAIM_OFFSET_Y, worldZ, 0.5);
}
}
if (busyCount > 0) {
busyCount--;
}
break;
case STATE_HEADING_FOR_ENEMY :
if (((!targetPlankton.active) || (targetPlankton.layer == undefined)) || (targetPlankton.layer != layer)) {
targetPlankton.underAttack = false;
becomeNormal();
targetPlankton = undefined;
return(undefined);
}
angle = getAngle(targetPlankton.worldX - worldX, targetPlankton.worldY - worldY);
var _local6 = getDistance(worldX - targetPlankton.worldX, worldY - targetPlankton.worldY);
if (_local6 < 40) {
becomeNormal();
targetPlankton.kill(angle);
angle = angle + 180;
}
break;
case STATE_HEADING_FOR_LOVER :
if (targetPlankton != undefined) {
_local6 = getDistance(worldX - targetX, worldY - targetY);
if (_local6 < 40) {
state = (targetPlankton.state = STATE_WAITING_FOR_LOVER);
setFrame(3);
targetPlankton.setFrame(3);
busyCount = LOVE_BUSY_TIME;
if (!Engine.gameOver) {
Engine.playSound(Engine.SOUND_LOVE);
}
}
}
break;
case STATE_WAITING_FOR_LOVER :
graphic._rotation = cosTo360 * 10;
if (targetPlankton == undefined) {
break;
}
busyCount--;
if (_local4) {
Engine.requestMovingSymbol("heartClip", layer.id, (targetX + (Math.random() * 20)) - 10, targetY - 20, worldZ, 0.5 + Math.random());
}
if (busyCount != 0) {
break;
}
becomeNormal();
targetPlankton.becomeNormal();
var _local3;
if ((Math.random() * 10) < Engine.level) {
do {
_local3 = Math.floor(Math.random() * (Engine.LAYER_COUNT - 0.001));
} while (_local3 == imageId);
} else {
_local3 = Math.floor(Math.random() * (Engine.LAYER_COUNT - 0.001));
}
if (!Engine.gameOver) {
Engine.playSound(Engine.SOUND_BIRTH);
}
layer.createPlanktonInThisLayer(_local3, targetX, targetY, 0.3);
if (layer.plankton.length <= Layer.MAX_PLANKTON_PER_LAYER) {
break;
}
state = STATE_OLD_AGE;
}
}
function kill(a) {
angle = a;
state = STATE_DEAD;
setFrame(4);
cosTo360 = 1;
speed = 1;
Engine.planktonKilled();
}
function becomeNormal() {
underAttack = false;
graphic._rotation = 0;
speed = 1;
setFrame(1);
state = STATE_IDLE;
busyCount = REST_TIME_AFTER_ACTIVITY - ((Engine.level - 1) * 200);
if (busyCount < 30) {
busyCount = 30;
}
}
static var TO_RADIANS = (Math.PI/180);
static var BASE_SCALE = 100;
static var COUNT_TO_360_SPEED = 15;
static var PULSE_AMOUNT = 15;
static var LAYER_SCALE_PERSPECTIVE = 0.5;
static var LOVE_SQR_DIST = 10000;
static var HATE_SQR_DIST = 1000000;
static var LOVE_BUSY_TIME = 200;
static var REST_TIME_AFTER_ACTIVITY = 100;
static var GROW_SPEED = 0.0008;
static var DEAD_SPIN_SPEED = 8;
static var EXCLAIM_OFFSET_Y = 25;
static var CELEBRATE_INITIAL_SPIN_SPEED = 40;
static var CELEBRATE_SPIN_SPEED_DECAY = 0.5;
static var STATE_IDLE = 0;
static var STATE_HEADING_FOR_LOVER = 1;
static var STATE_HEADING_FOR_ENEMY = 2;
static var STATE_WAITING_FOR_LOVER = 3;
static var STATE_DEAD = 4;
static var STATE_OLD_AGE = 5;
static var STATE_CELEBRATING = 6;
static var STATE_CELEBRATE_COOLDOWN = 7;
}
Symbol 159 MovieClip [__Packages.Layer] Frame 0
class Layer
{
var id, z, plankton, ambientCount;
function Layer (id, z) {
this.id = id;
this.z = z;
plankton = new Array();
ambientCount = 0;
}
function init() {
while (plankton.length > 0) {
plankton.pop();
}
var _local2 = 0;
while (_local2 < INITIAL_PLANKTON_PER_LAYER) {
createPlanktonInThisLayer(id % 3, (Math.random() * Engine.WORLDWIDTH) - Engine.HALFWORLDWIDTH, (Math.random() * Engine.WORLDHEIGHT) - Engine.HALFWORLDHEIGHT, 1);
_local2++;
}
}
function checkPlanktonClick(x, y) {
var _local2;
var _local5;
var _local4;
var _local6;
var _local8 = 1000;
var _local7;
var _local3 = 0;
while (_local3 < plankton.length) {
_local2 = plankton[_local3];
if (_local2.state != Plankton.STATE_IDLE) {
} else {
_local5 = x - _local2.graphic._x;
_local4 = y - _local2.graphic._y;
_local6 = _local2.graphic._width / 2;
if (((_local5 * _local5) + (_local4 * _local4)) < (_local6 * _local6)) {
if ((_local7 == undefined) || (_local2.size < _local8)) {
_local7 = _local2;
_local8 = _local2.size;
}
}
}
_local3++;
}
if (_local7 != undefined) {
Engine.setMousePlankton(_local7);
removeMe(_local7);
_local7.layer = undefined;
}
}
function createPlanktonInThisLayer(type, x, y, size) {
var _local2 = Engine.activatePlankton(this, type, x, y, size);
plankton.push(_local2);
}
function insertPlankton(p) {
plankton.push(p);
p.layer = this;
p.worldX = _root._xmouse - Engine.HALFWIDTH;
p.worldY = _root._ymouse - Engine.HALFHEIGHT;
p.worldZ = z;
}
function removeMe(pl) {
var _local3 = plankton.length;
var _local2 = _local3;
while (_local2-- , _local2 >= 0) {
if (plankton[_local2] == pl) {
var _local4 = plankton[_local3 - 1];
plankton[_local3 - 1] = plankton[_local2];
plankton[_local2] = _local4;
plankton.pop();
return(undefined);
}
}
}
function checkOverpopulated(count) {
if (count > MAX_PLANKTON_PER_LAYER) {
var _local4 = 0;
var _local2 = 0;
while (_local2 < count) {
if ((plankton[_local2].state != Plankton.STATE_DEAD) && (plankton[_local2].state != Plankton.STATE_OLD_AGE)) {
_local4++;
}
_local2++;
}
if (_local4 <= MAX_PLANKTON_PER_LAYER) {
return(undefined);
}
_local2 = 0;
while (_local2 < count) {
if (((plankton[_local2].imageId == id) && (plankton[_local2].state == Plankton.STATE_IDLE)) && (plankton[_local2].size == 1)) {
plankton[_local2].state = Plankton.STATE_OLD_AGE;
return(undefined);
}
_local2++;
}
_local2 = 0;
while (_local2 < count) {
if ((plankton[_local2].state == Plankton.STATE_IDLE) && (plankton[_local2].size == 1)) {
plankton[_local2].state = Plankton.STATE_OLD_AGE;
return(undefined);
}
_local2++;
}
}
}
function update() {
if (Engine.gameOver) {
return(undefined);
}
var _local9 = plankton.length;
checkOverpopulated(_local9);
if (((++ambientCount) > AMBIENT_SOUND_DELAY) && (Engine.cameraLayer == id)) {
ambientCount = 0;
}
var _local5;
var _local4;
var _local8;
var _local2;
var _local3;
var _local7 = 0;
while (_local7 < (_local9 - 1)) {
var _local6 = _local7 + 1;
while (_local6 < _local9) {
_local2 = plankton[_local7];
_local3 = plankton[_local6];
if ((((_local2.state != Plankton.STATE_IDLE) || (_local2.busyCount > 0)) || (_local2.size < 1)) || (_local2 == Engine.mousePlankton)) {
} else if ((((_local3.state != Plankton.STATE_IDLE) || (_local3.busyCount > 0)) || (_local3.size < 1)) || (_local3 == Engine.mousePlankton)) {
} else {
_local5 = _local2.worldX - _local3.worldX;
_local4 = _local2.worldY - _local3.worldY;
_local8 = (_local5 * _local5) + (_local4 * _local4);
if (((((!_local2.underAttack) && (!_local3.underAttack)) && (_local2.imageId == _local3.imageId)) && (_local2.imageId == id)) && (_local8 > 250)) {
_local2.fallInLove(_local3, -(_local5 / 2), -(_local4 / 2));
_local3.fallInLove(undefined, _local5 / 2, _local4 / 2);
} else if ((_local8 < Plankton.HATE_SQR_DIST) && (_local2.imageId != _local3.imageId)) {
if ((_local2.imageId == id) && (Math.random() < 0.75)) {
_local2.attack(_local3);
} else {
_local3.attack(_local2);
}
}
}
_local6++;
}
_local7++;
}
}
static var INITIAL_PLANKTON_PER_LAYER = 3;
static var MAX_PLANKTON_PER_LAYER = 5;
static var AMBIENT_SOUND_DELAY = 100;
}
Symbol 160 MovieClip [__Packages.MovingSymbol] Frame 0
class MovingSymbol
{
var active, graphic, scale, layerId, worldX, worldY, worldZ, lifetime;
function MovingSymbol () {
active = false;
}
function init(name, lid, x, y, z, _scale) {
if (graphic.name != name) {
graphic = _root.attachMovie(name, name, _root.getNextHighestDepth());
}
var self = this;
graphic.onEnterFrame = function () {
self.onEnterFrame();
};
scale = _scale;
layerId = lid;
worldX = x;
worldY = y;
worldZ = z;
lifetime = 100;
updateGraphic();
active = true;
}
function onEnterFrame() {
if (!active) {
return(undefined);
}
worldY = worldY - RISE_SPEED;
lifetime = lifetime - DECAY_SPEED;
if (lifetime < 0) {
graphic.removeMovieClip();
active = false;
} else {
updateGraphic();
}
}
function updateGraphic() {
var _local2 = worldZ - Engine.cameraZ;
if (_local2 >= 0) {
graphic._x = (worldX / (1 + (_local2 * Engine.POSITION_PERSPECTIVE))) + Engine.HALFWIDTH;
graphic._y = (worldY / (1 + (_local2 * Engine.POSITION_PERSPECTIVE))) + Engine.HALFHEIGHT;
graphic._xscale = (graphic._yscale = (100 * scale) / (1 + (_local2 * Engine.SCALE_PERSPECTIVE)));
} else {
graphic._x = (worldX * (1 + ((-_local2) * Engine.POSITION_PERSPECTIVE))) + Engine.HALFWIDTH;
graphic._y = (worldY * (1 + ((-_local2) * Engine.POSITION_PERSPECTIVE))) + Engine.HALFHEIGHT;
graphic._xscale = (graphic._yscale = (100 * scale) * (1 + ((-_local2) * Engine.SCALE_PERSPECTIVE)));
}
if (Engine.cameraLayer == layerId) {
graphic._alpha = lifetime;
} else if (_local2 > 0) {
graphic._alpha = lifetime / 2;
} else {
graphic._alpha = 0;
}
}
static var DECAY_SPEED = 3;
static var RISE_SPEED = 0.7;
}
Symbol 161 MovieClip [__Packages.Bubble] Frame 0
class Bubble extends MovieClip
{
var id, z, graphic, worldX, worldY, scale, layerScale;
function Bubble (id) {
super();
this.id = id;
z = Math.floor(Math.random() * Engine.LAYER_COUNT);
var _local5 = (id + ((2 - z) * 1000)) + 50;
graphic = _root.attachMovie("bubbleClip", "bubble" + id, _local5);
worldX = (Math.random() * WORLDWIDTH) - HALFWORLDWIDTH;
worldY = (Math.random() * WORLDHEIGHT) - HALFWORLDHEIGHT;
var self = this;
graphic.onEnterFrame = function () {
self.onEnterFrame();
};
scale = 0.8 / (1 + (z / 2));
}
function onEnterFrame() {
var _local2 = z - Engine.cameraZ;
worldY = worldY - (scale * SPEED);
if (worldY < (-(HALFWORLDHEIGHT + 100))) {
worldY = HALFWORLDHEIGHT + 20;
worldX = (Math.random() * WORLDWIDTH) - HALFWORLDWIDTH;
if (!Engine.gameOver) {
}
}
graphic._xscale = (graphic._yscale = (scale * layerScale) + (Math.sin((graphic._y * 10) * Plankton.TO_RADIANS) * 15));
if (_local2 >= 0) {
graphic._x = ((worldX + (Math.sin(worldY / 10) * 3)) / (1 + (_local2 * Engine.POSITION_PERSPECTIVE))) + Engine.HALFWIDTH;
graphic._y = (worldY / (1 + (_local2 * Engine.POSITION_PERSPECTIVE))) + Engine.HALFHEIGHT;
layerScale = 100 / (1 + (_local2 * Engine.SCALE_PERSPECTIVE));
} else {
graphic._x = ((worldX + (Math.sin(worldY / 10) * 3)) * (1 + ((-_local2) * Engine.POSITION_PERSPECTIVE))) + Engine.HALFWIDTH;
graphic._y = (worldY * (1 + ((-_local2) * Engine.POSITION_PERSPECTIVE))) + Engine.HALFHEIGHT;
layerScale = 100 * (1 + ((-_local2) * Engine.SCALE_PERSPECTIVE));
}
}
static var WORLDWIDTH = Engine.WIDTH * 2;
static var WORLDHEIGHT = Engine.HEIGHT * 2;
static var HALFWORLDWIDTH = WORLDWIDTH / 2;
static var HALFWORLDHEIGHT = WORLDHEIGHT / 2;
var SPEED = 2;
}
Symbol 162 MovieClip [__Packages.Light] Frame 0
class Light extends MovieClip
{
var id, graphic, countTo360;
function Light (id) {
super();
this.id = id;
graphic = _root.attachMovie("lightClip", "light" + id, id);
graphic._x = Math.random() * Engine.WIDTH;
graphic._y = Math.random() * Engine.HEIGHT;
var self = this;
graphic.onEnterFrame = function () {
self.onEnterFrame();
};
countTo360 = Math.random() * 360;
}
function onEnterFrame() {
countTo360 = countTo360 + COUNT_TO_360_SPEED;
var _local2 = Math.sin(countTo360);
var _local3 = Math.cos(countTo360);
graphic._xscale = BASE_SCALE + (_local2 * PULSE_AMOUNT);
graphic._yscale = BASE_SCALE + (_local2 * PULSE_AMOUNT);
graphic._alpha = BASE_ALPHA + ((_local3 + 1) * ((100 - BASE_ALPHA) / 2));
}
var BASE_SCALE = 100;
var BASE_ALPHA = 30;
var COUNT_TO_360_SPEED = 0.2;
var PULSE_AMOUNT = 15;
}
Symbol 163 MovieClip [__Packages.Text] Frame 0
class Text
{
static var textFormat, textList;
function Text () {
}
static function init(format) {
textFormat = format;
textList = new Vector();
}
static function clear() {
if (textList.length > 0) {
textList[0].destroy();
textList.pop();
}
}
static function floobyText(text, x, y, handle, time, size) {
clear();
if (size != undefined) {
textFormat.size = size;
}
var _local1 = new FloobyText(text, x, y, textFormat, handle, time);
textList.push(_local1);
}
static function update() {
var _local1 = textList.length;
while (_local1-- , _local1 >= 0) {
if (!textList[_local1].update()) {
textList.removeElementAt(_local1);
}
}
}
static var LEFT = 0;
static var CENTRE = 1;
static var RIGHT = 2;
}
Symbol 164 MovieClip [__Packages.Vector] Frame 0
class Vector extends Array
{
var length, pop;
function Vector () {
super();
}
function removeElementAt(i) {
var _local2 = length;
if (i == (_local2 - 1)) {
pop();
return(undefined);
}
var _local4 = this[_local2 - 1];
this[_local2 - 1] = this[i];
this[i] = _local4;
pop();
return(undefined);
}
function removeElement(object) {
var _local3 = length;
var _local2 = _local3;
while (_local2-- , _local2 >= 0) {
if (this[_local2] == object) {
var _local4 = this[_local3 - 1];
this[_local3 - 1] = this[_local2];
this[_local2] = _local4;
pop();
return(undefined);
}
}
}
}
Symbol 165 MovieClip [__Packages.FloobyText] Frame 0
class FloobyText
{
var textFields, text, deathTime, size, startX, startY, angleDiv, lifeTime;
function FloobyText (t, x, y, textFormat, handle, time) {
textFields = new Array();
text = t;
var _local5;
var _local3;
deathTime = time;
size = textFormat.size;
var _local4 = 0;
while (_local4 < text.length) {
_local5 = text.charAt(_local4);
_local3 = _root.createTextField("t" + _local5, _root.getNextHighestDepth(), x + (_local4 * size), y, size, size);
_local3.setNewTextFormat(textFormat);
_local3.embedFonts = true;
_local3.selectable = false;
_local3.textColor = 16777215 /* 0xFFFFFF */;
_local3.text = _local5;
textFields.push(_local3);
_local3._alpha = 0;
_local4++;
}
var _local9 = ((text.length - 1) * size) + textFields[textFields.length - 1].textWidth;
startX = x;
startY = y;
if (handle == Text.RIGHT) {
startX = startX - _local9;
} else if (handle == Text.CENTRE) {
startX = startX - (_local9 / 2);
}
_local4 = 0;
while (_local4 < text.length) {
textFields[_local4]._x = startX + (_local4 * size);
_local4++;
}
angleDiv = 360 / text.length;
lifeTime = 0;
}
function update() {
var _local6;
var _local8;
var _local5;
var _local9;
var _local7;
var _local3;
var _local2;
var _local4 = textFields.length;
while (_local4-- , _local4 >= 0) {
_local5 = (lifeTime / 8) + ((_local4 * angleDiv) * Engine.TO_RADIANS);
_local6 = Math.sin(_local5);
_local8 = Math.cos(_local5);
_local2 = textFields[_local4];
_local2._xscale = 100 + (_local6 * 20);
_local2._yscale = 100 + (_local8 * 20);
_local9 = (_local2._xscale * _local2.textWidth) / 100;
_local7 = (_local2._yscale * _local2.textHeight) / 100;
_local3 = _local2.textWidth - _local9;
_local2._x = (startX + (_local4 * size)) + (_local3 / 2);
_local3 = _local2.textHeight - _local7;
_local2._y = startY + (_local3 / 2);
if ((deathTime != 0) && (lifeTime >= (deathTime - FADE_OUT_TIME))) {
_local3 = ((lifeTime - (deathTime - FADE_OUT_TIME)) * 100) / FADE_OUT_TIME;
_local2._alpha = 100 - _local3;
} else {
_local3 = ((100 * lifeTime) / FADE_IN_TIME) - (_local4 * 5);
if (_local3 > 100) {
_local3 = 100;
}
_local2._alpha = _local3;
}
}
lifeTime++;
if ((deathTime != 0) && (lifeTime > deathTime)) {
destroy();
return(false);
}
return(true);
}
function destroy() {
var _local2 = textFields.length;
while (_local2-- , _local2 >= 0) {
textFields[_local2].removeTextField();
}
Engine.notifyTextFinished(text);
}
static var FADE_IN_TIME = 100;
static var FADE_OUT_TIME = 100;
}
Symbol 166 MovieClip [__Packages.HighScores] Frame 0
class HighScores
{
static var SERVER_URL, SERVLET_URL, colour0, colour1, borderColour, panel, textFormat, g, gameIdParam, gameNameParam, errorText, vars;
function HighScores () {
}
static function init(gameName, gameId, score, lowIsBest, c0, c1, bc, tFormat, mouseClip) {
SERVER_URL = _root._url;
SERVER_URL = SERVER_URL.substring(7, SERVER_URL.length);
SERVER_URL = SERVER_URL.substring(0, SERVER_URL.indexOf("/"));
SERVER_URL = ("http://" + SERVER_URL) + "/";
SERVLET_URL = SERVER_URL + "servlet/hiServlet";
colour0 = c0;
colour1 = c1;
borderColour = bc;
panel = _root.createEmptyMovieClip("highScorePanel", _root.getNextHighestDepth());
textFormat = tFormat;
textFormat.color = 16777215 /* 0xFFFFFF */;
borderedGradientFillRoundRect(panel, 0, 0, WIDTH, HEIGHT, CURVE_DISTANCE, BORDER_SIZE, colour0, colour1, borderColour, 100);
g = panel.createEmptyMovieClip("highScorePanel", panel.getNextHighestDepth());
gameIdParam = "?gameId=" + gameId;
gameNameParam = gameName;
panel._x = PANEL_X;
panel._y = PANEL_Y;
var _local4 = BORDER_SIZE + PADDING;
var _local8 = g.createTextField("scoreText", g.getNextHighestDepth(), 0, _local4, WIDTH, HEIGHT);
textFormat.size = BIG_TEXT_SIZE;
_local8.setNewTextFormat(textFormat);
_local8.embedFonts = true;
_local8.selectable = false;
_local8.text = "YOU SCORED " + score;
_local8._x = (WIDTH - _local8.textWidth) / 2;
_local4 = _local4 + (textFormat.size + LINE_SPACING);
createSmallText(g, BORDER_SIZE + PADDING, _local4, textFormat, "ENTER NAME");
_local4 = _local4 + (textFormat.size + LINE_SPACING);
var nameEntry = createInputBox(g, _local4, borderColour, textFormat, 20);
_local4 = _local4 + ((textFormat.size + LINE_SPACING) + PADDING);
var _local9 = g.createEmptyMovieClip("security", g.getNextHighestDepth());
_local9.loadMovie((SERVLET_URL + "?type=genCode&cachebuster=") + new Date().getTime());
_local9._x = BORDER_SIZE + PADDING;
_local9._y = _local4;
_local4 = _local4 + 40;
createSmallText(g, BORDER_SIZE + PADDING, _local4, textFormat, "ENTER CODE ABOVE");
_local4 = _local4 + (textFormat.size + LINE_SPACING);
var codeEntry = createInputBox(g, _local4, borderColour, textFormat, 5);
_local4 = _local4 + ((textFormat.size + LINE_SPACING) + PADDING);
var _local11 = createButton(g, BORDER_SIZE + PADDING, _local4, BUTTON_WIDTH, BIG_TEXT_SIZE + PADDING, colour0, colour1, borderColour, textFormat, "SUBMIT");
var _local10 = createButton(g, (BORDER_SIZE + (PADDING * 2)) + BUTTON_WIDTH, _local4, BUTTON_WIDTH, BIG_TEXT_SIZE + PADDING, colour0, colour1, borderColour, textFormat, "CANCEL");
_local4 = _local4 + ((textFormat.size + LINE_SPACING) + (PADDING * 2));
textFormat.color = 16711680 /* 0xFF0000 */;
errorText = createSmallText(g, BORDER_SIZE + PADDING, _local4, textFormat, "");
_local10.onRelease = function () {
HighScores.close();
};
_local11.onRelease = function () {
if (nameEntry.text.length == 0) {
HighScores.error("MUST ENTER NAME");
return(undefined);
}
if (codeEntry.text.length == 0) {
HighScores.error("MUST ENTER CODE");
return(undefined);
}
HighScores.name = nameEntry.text;
var _local3 = "rocket";
HighScores.vars = new LoadVars();
var _local4 = (((((("save|" + nameEntry.text) + "|") + codeEntry.text) + "|") + score) + "|") + gameId;
var _local5 = "";
var _local2 = 0;
var _local1 = 0;
while (_local2 < _local4.length) {
if (_local1 >= _local3.length) {
_local1 = 0;
}
_local5 = _local5 + String.fromCharCode((_local4.charCodeAt(_local2) ^ _local3.charCodeAt(_local1)) + 1);
_local2++;
_local1++;
}
trace("encrypted");
HighScores.vars.ffdata = _local5;
HighScores.vars.lowIsBest = (lowIsBest ? "true" : "false");
HighScores.vars.sendAndLoad(HighScores.SERVLET_URL, HighScores.vars, "POST");
trace("sent and loaded");
HighScores.vars.onLoad = HighScores.showHiScoreSaveResult;
};
mouseClip.swapDepths(_root.getNextHighestDepth());
}
static function close() {
panel.removeMovieClip();
Engine.notifyHighScoresClosed();
}
static function error(text) {
errorText.text = text;
errorText._x = (WIDTH - errorText.textWidth) / 2;
}
static function showHiScoreSaveResult(success) {
var _local1 = parseInt(vars.res);
if ((_local1 == -1) || (!success)) {
error("SERVER PROBLEM");
} else if (_local1 == 0) {
displayResult("Sorry, a better result already exists with that name", _local1);
} else if (_local1 == 1) {
displayResult("Congratulations! You made it into the high-score table", _local1);
}
}
static function displayResult(text, res) {
g.removeMovieClip();
var _local1 = panel.createTextField("resultText", panel.getNextHighestDepth(), BORDER_SIZE + PADDING, BORDER_SIZE + PADDING, (WIDTH - (BORDER_SIZE * 2)) - (PADDING * 2), HEIGHT);
textFormat.size = BIG_TEXT_SIZE;
textFormat.align = "center";
textFormat.color = 16777215 /* 0xFFFFFF */;
_local1.setNewTextFormat(textFormat);
_local1.embedFonts = true;
_local1.selectable = false;
_local1.multiline = true;
_local1.text = text;
_local1.wordWrap = true;
var _local2 = HEIGHT - ((BORDER_SIZE + BIG_TEXT_SIZE) + PADDING);
var _local4 = createButton(panel, BORDER_SIZE + PADDING, _local2, BUTTON_WIDTH, BIG_TEXT_SIZE + PADDING, colour0, colour1, borderColour, textFormat, "SHOW ME");
var _local3 = createButton(panel, (BORDER_SIZE + (PADDING * 2)) + BUTTON_WIDTH, _local2, BUTTON_WIDTH, BIG_TEXT_SIZE + PADDING, colour0, colour1, borderColour, textFormat, "CLOSE");
_local3.onRelease = function () {
HighScores.panel.removeMovieClip();
Engine.notifyHighScoresClosed();
};
_local4.onRelease = function () {
getURL (((((((((HighScores.SERVER_URL + "index.jsp?content=") + HighScores.gameNameParam) + "/") + HighScores.SCORE_TABLE_JSP) + HighScores.gameIdParam) + "&name=") + HighScores.name) + "&cachebuster=") + new Date().getTime());
};
}
static function createButton(clip, x, y, width, height, colour0, colour1, borderColour, textFormat, text) {
var _local1 = clip.createEmptyMovieClip("button", clip.getNextHighestDepth());
borderedGradientFillRoundRect(_local1, 0, 0, width, height, 10, 2, colour0, colour1, borderColour, 100);
_local1._x = x;
_local1._y = y;
var _local2 = createSmallText(_local1, 0, 0, textFormat, text);
_local2._x = (width - _local2.textWidth) / 2;
_local2._y = (height - _local2.textHeight) / 2;
return(_local1);
}
static function createSmallText(clip, x, y, textFormat, text) {
var _local1 = clip.createTextField("enterText", clip.getNextHighestDepth(), x, y, WIDTH, HEIGHT);
textFormat.size = SMALL_TEXT_SIZE;
textFormat.align = "left";
_local1.setNewTextFormat(textFormat);
_local1.embedFonts = true;
_local1.selectable = false;
_local1.text = text;
_local1.autoSize = "left";
return(_local1);
}
static function createInputBox(g, y, borderColour, textFormat, maxChars) {
var enterNameBox = g.createTextField("enterNameBox", g.getNextHighestDepth(), BORDER_SIZE + PADDING, y, INPUTWIDTH, BIG_TEXT_SIZE + PADDING);
textFormat.size = BIG_TEXT_SIZE;
enterNameBox.type = "input";
enterNameBox.maxChars = maxChars;
enterNameBox.setNewTextFormat(textFormat);
var _local1 = new Object();
enterNameBox.onChanged = function () {
enterNameBox.text = enterNameBox.text.toUpperCase();
};
enterNameBox.embedFonts = true;
enterNameBox.selectable = true;
enterNameBox.border = true;
enterNameBox.borderColor = borderColour;
enterNameBox.text = "";
return(enterNameBox);
}
static function fillCircle(target_mc, radius, fillColor, fillAlpha) {
var x = radius;
var y = radius;
with (target_mc) {
beginFill(fillColor, fillAlpha);
moveTo(x + radius, y);
curveTo(radius + x, (0.414213562373095 * radius) + y, (0.707106781186547 * radius) + x, (0.707106781186547 * radius) + y);
curveTo((0.414213562373095 * radius) + x, radius + y, x, radius + y);
curveTo((-0.414213562373095 * radius) + x, radius + y, (-0.707106781186547 * radius) + x, (0.707106781186547 * radius) + y);
curveTo((-radius) + x, (0.414213562373095 * radius) + y, (-radius) + x, y);
curveTo((-radius) + x, (-0.414213562373095 * radius) + y, (-0.707106781186547 * radius) + x, (-0.707106781186547 * radius) + y);
curveTo((-0.414213562373095 * radius) + x, (-radius) + y, x, (-radius) + y);
curveTo((0.414213562373095 * radius) + x, (-radius) + y, (0.707106781186547 * radius) + x, (-0.707106781186547 * radius) + y);
curveTo(radius + x, (-0.414213562373095 * radius) + y, radius + x, y);
endFill();
}
}
static function drawCircle(target_mc, radius, thickness, fillColor, fillAlpha) {
var x = radius;
var y = radius;
with (target_mc) {
lineStyle(thickness, fillColor, fillAlpha, true);
moveTo(x + radius, y);
curveTo(radius + x, (0.414213562373095 * radius) + y, (0.707106781186547 * radius) + x, (0.707106781186547 * radius) + y);
curveTo((0.414213562373095 * radius) + x, radius + y, x, radius + y);
curveTo((-0.414213562373095 * radius) + x, radius + y, (-0.707106781186547 * radius) + x, (0.707106781186547 * radius) + y);
curveTo((-radius) + x, (0.414213562373095 * radius) + y, (-radius) + x, y);
curveTo((-radius) + x, (-0.414213562373095 * radius) + y, (-0.707106781186547 * radius) + x, (-0.707106781186547 * radius) + y);
curveTo((-0.414213562373095 * radius) + x, (-radius) + y, x, (-radius) + y);
curveTo((0.414213562373095 * radius) + x, (-radius) + y, (0.707106781186547 * radius) + x, (-0.707106781186547 * radius) + y);
curveTo(radius + x, (-0.414213562373095 * radius) + y, radius + x, y);
endFill();
}
}
static function drawBorder(g) {
g.moveTo(CURVE_DISTANCE, 0);
g.lineTo(WIDTH - CURVE_DISTANCE, 0);
g.curveTo(WIDTH, 0, WIDTH, CURVE_DISTANCE);
g.lineTo(WIDTH, HEIGHT - CURVE_DISTANCE);
g.curveTo(WIDTH, HEIGHT, WIDTH - CURVE_DISTANCE, HEIGHT);
g.lineTo(CURVE_DISTANCE, HEIGHT);
g.curveTo(0, HEIGHT, 0, HEIGHT - CURVE_DISTANCE);
g.lineTo(0, CURVE_DISTANCE);
g.curveTo(0, 0, CURVE_DISTANCE, 0);
}
static function borderedGradientFillRoundRect(g, x, y, width, height, curveDist, thickness, colour0, colour1, borderColour, alpha) {
gradientFillRoundRect(g, x, y, width, height, curveDist, colour0, colour1, alpha);
drawRoundRect(g, x, y, width, height, curveDist, thickness, borderColour, alpha);
}
static function gradientFillRoundRect(g, x, y, width, height, curveDist, colour0, colour1, alpha) {
var _local1 = new flash.geom.Matrix();
_local1.createGradientBox(width, height, (Math.PI/2), 0, 0);
g.beginGradientFill("linear", new Array(colour0, colour1), new Array(100, 100), new Array(0, 200), _local1, "reflect", "RGB", 0.9);
roundRect(g, x, y, width, height, curveDist);
g.endFill();
}
static function fillRoundRect(g, x, y, width, height, curveDist, colour, alpha) {
g.beginFill(colour, alpha);
roundRect(g, x, y, width, height, curveDist);
g.endFill();
}
static function drawRoundRect(g, x, y, width, height, curveDist, thickness, colour, alpha) {
g.lineStyle(thickness, colour, alpha, true);
roundRect(g, x, y, width, height, curveDist);
}
static function roundRect(g, x, y, width, height, curveDist) {
g.moveTo(x + curveDist, y);
g.lineTo((x + width) - curveDist, y);
g.curveTo(x + width, y, x + width, y + curveDist);
g.lineTo(x + width, (y + height) - curveDist);
g.curveTo(x + width, y + height, (x + width) - curveDist, y + height);
g.lineTo(x + curveDist, y + height);
g.curveTo(x, y + height, x, (y + height) - curveDist);
g.lineTo(x, y + curveDist);
g.curveTo(x, y, x + curveDist, y);
}
static var PANEL_X = 5;
static var PANEL_Y = 5;
static var WIDTH = 280;
static var HEIGHT = 240;
static var CURVE_DISTANCE = 20;
static var BORDER_SIZE = 6;
static var PADDING = 4;
static var BIG_TEXT_SIZE = 20;
static var SMALL_TEXT_SIZE = 15;
static var LINE_SPACING = 8;
static var INPUTWIDTH = WIDTH - ((BORDER_SIZE + PADDING) * 2);
static var BUTTON_WIDTH = ((WIDTH - (BORDER_SIZE * 2)) - (PADDING * 3)) / 2;
static var SCORE_TABLE_JSP = "highscore.jsp";
}
Symbol 122 Button
on (release) {
Text.clear();
Engine.stopAllSound();
Engine.playSound(Engine.SOUND_ZOOM_IN);
gotoAndStop ("game");
Engine.reset();
Engine.showHelp();
}
on (rollOver) {
_root.playButton._xscale = (_root.playButton._yscale = _root.playButton._yscale + 5);
}
on (rollOut) {
_root.playButton._xscale = (_root.playButton._yscale = _root.playButton._yscale - 5);
}
Symbol 123 Button
on (release) {
getURL ("http://www.offthewrist.com");
}
Symbol 124 Button
on (release) {
getURL ("http://www.offthewrist.com");
}
Symbol 129 Button
on (release) {
Engine.showHelp();
}
Symbol 150 Button
on (release) {
getURL ("http://www.offthewrist.com");
}
Symbol 153 Button
on (release) {
getURL ("http://www.offthewrist.com/index.jsp?content=/bhb/content.html&lhs=/lhs_games.html&top=/blank.html&rhs=/blank.html&id=otw_bhbbigban");
}
Symbol 156 Button
on (release) {
Text.clear();
gotoAndStop ("game");
Engine.reset();
}