home *** CD-ROM | disk | FTP | other *** search
- function placeSophie()
- {
- _root.sophieClip._y = _root["floor" + _root.sophie.targetFloor] - _root.sophieClip._height;
- _root.sophie.myFloor = _root.sophie.targetFloor;
- myXmax = _root["holeArray" + _root.sophie.myFloor][0].xMax;
- myXmin = _root["holeArray" + _root.sophie.myFloor][0].xMin;
- if(_root.sophie.targetX < myXmax)
- {
- _root.sophieClip._x = -20;
- }
- else
- {
- _root.sophieClip._x = Stage.width + 20;
- }
- _root.turnSophie();
- }
- function turnSophie()
- {
- if(_root.sophieClip._x < _root.sophie.targetX)
- {
- _root.sophieClip.gotoAndStop("walkRight");
- _root.sophie.xdir = 1;
- }
- else
- {
- _root.sophieClip.gotoAndStop("walkLeft");
- _root.sophie.xdir = -1;
- }
- }
- function turnToWalkOff()
- {
- myXmax = _root["holeArray" + _root.sophie.myFloor][0].xMax;
- myXmin = _root["holeArray" + _root.sophie.myFloor][0].xMin;
- if(_root.sophieClip._x < myXmax && _root.sophie.xdir != -1)
- {
- if(_root.sophie.pecked)
- {
- _root.sophieClip.gotoAndStop("runLeft");
- }
- else
- {
- _root.sophieClip.gotoAndStop("walkLeft");
- }
- _root.sophie.xdir = -1;
- }
- else if(_root.sophieClip._x > myXmin && _root.sophie.xdir != 1)
- {
- if(_root.sophie.pecked)
- {
- _root.sophieClip.gotoAndStop("runRight");
- }
- else
- {
- _root.sophieClip.gotoAndStop("walkRight");
- }
- _root.sophie.xdir = 1;
- }
- else if(_root.sophie.xdir == -1)
- {
- if(_root.sophie.pecked)
- {
- _root.sophieClip.gotoAndStop("runLeft");
- }
- else
- {
- _root.sophieClip.gotoAndStop("walkLeft");
- }
- }
- else if(_root.sophie.pecked)
- {
- _root.sophieClip.gotoAndStop("runRight");
- }
- else
- {
- _root.sophieClip.gotoAndStop("walkRight");
- }
- }
- function getFloor(thisY)
- {
- if(thisY < _root.floor1)
- {
- return 1;
- }
- if(thisY < _root.floor2)
- {
- return 2;
- }
- if(thisY < _root.floor3)
- {
- return 3;
- }
- return 4;
- }
- function chooseTarget(myStr)
- {
- myToy = null;
- i = 0;
- while(i < _root.hiddenToys.length)
- {
- if(_root.toys[_root.hiddenToys[i].myClip]._visible)
- {
- if(random(10) > 8)
- {
- myToy = i;
- break;
- }
- }
- i++;
- }
- if(myToy != null)
- {
- _root.sophie.targetX = _root.hiddenToys[myToy].myX;
- _root.sophie.targetY = _root.hiddenToys[myToy].myY;
- _root.sophie.targetFloor = _root.getFloor(_root.sophie.targetY);
- }
- else if(random(10) < _root.sophie.homing && _root.hiddenToys.length > 0)
- {
- myToy = random(_root.hiddenToys.length);
- _root.sophie.targetX = _root.hiddenToys[myToy].myX;
- _root.sophie.targetY = _root.hiddenToys[myToy].myY;
- _root.sophie.targetFloor = _root.getFloor(_root.sophie.targetY);
- }
- else
- {
- _root.sophie.targetFloor = random(3) + 1;
- _root.sophie.myHideBlock = _root["floor" + _root.sophie.targetFloor + "Blocks"][random(_root["floor" + _root.sophie.targetFloor + "Blocks"].length)];
- _root.sophie.myItemInBlock = random(_root[_root.sophie.myHideBlock].length);
- if(!_root[_root.sophie.myHideBlock][_root.sophie.myItemInBlock].inspected && !_root[_root.sophie.myHideBlock][_root.sophie.myItemInBlock].hit)
- {
- _root.sophie.targetX = _root[_root.sophie.myHideBlock][_root.sophie.myItemInBlock].myX;
- _root.sophie.targetY = _root[_root.sophie.myHideBlock][_root.sophie.myItemInBlock].myY;
- }
- else
- {
- _root.sophie.targetFloor = _root.sophie.myFloor;
- }
- }
- }
- function rightSideOfHole()
- {
- myXmax = _root["holeArray" + _root.sophie.myFloor][0].xMax;
- myXmin = _root["holeArray" + _root.sophie.myFloor][0].xMin;
- if(_root.sophieClip._x < myXmin && _root.sophie.targetX < myXmin)
- {
- return 1;
- }
- if(_root.sophieClip._x > myXmax && _root.sophie.targetX > myXmax)
- {
- return 1;
- }
- return 0;
- }
- function sophieHeartBeat()
- {
- if(_root.sophie.behaviour == "start")
- {
- if(_root.sophie.targetFloor != _root.sophie.myFloor || _root.sophie.myFloor < 4 && !_root.rightSideOfHole())
- {
- _root.sophie.behaviour = "walkOff";
- }
- else if(_root.sophie.targetFloor == _root.sophie.myFloor && _root.rightSideOfHole() || _root.sophie.targetFloor == _root.sophie.myFloor && _root.sophie.myFloor == 4)
- {
- _root.sophie.behaviour = "walkTo";
- }
- }
- else if(_root.sophie.behaviour == "walkTo")
- {
- if(Math.abs(_root.sophieClip._x - _root.sophie.targetX) < _root.sophie.speed + 2)
- {
- _root.sophieClip._x = _root.sophie.targetX;
- _root.sophie.behaviour = "action";
- }
- _root.sophieClip._x += _root.sophie.xdir * _root.sophie.speed;
- }
- else if(_root.sophie.behaviour == "action")
- {
- i = 0;
- while(i < _root.hiddenToys.length)
- {
- if(Math.abs(_root.sophie.targetX - _root.hiddenToys[i].myX) < 5 && Math.abs(_root.sophie.targetY - _root.hiddenToys[i].myY) < 5)
- {
- _root.foundClip.myTextColour = "0xFF3333";
- _root.foundClip.myFoundText = "Sophie Found The " + _root.hiddenToys[i].myToy;
- _root.foundClip.myFace = 2;
- _root.foundClip.gotoAndPlay(2);
- _root.sophieFound.start(0,1);
- _root.sophieToys.push(_root.hiddenToys[i]);
- _root.toys[_root.hiddenToys[i].myClip]._visible = 1;
- _root.toys[_root.hiddenToys[i].myClip]._xscale = 90;
- _root.toys[_root.hiddenToys[i].myClip]._yscale = 90;
- _root.toys[_root.hiddenToys[i].myClip].pulse.gotoAndStop("found");
- _root.toys[_root.hiddenToys[i].myClip]._x = 404 + _root.sophieToys.length * 38;
- _root.toys[_root.hiddenToys[i].myClip]._y = 495;
- _root.hiddenToys.splice(i,1);
- if(_root.sophieToys.length == 5)
- {
- _root.gameOver();
- }
- break;
- }
- i++;
- }
- _root.sophieClip.gotoAndStop("rummage");
- }
- else if(_root.sophie.behaviour == "actionDone")
- {
- _root[_root.sophie.myHideBlock][_root.sophie.myItemInBlock].inspected = 1;
- _root.chooseTarget("actionDone");
- if(_root.sophie.targetFloor == _root.sophie.myFloor && _root.rightSideOfHole())
- {
- _root.turnSophie();
- _root.sophie.behaviour = "walkTo";
- }
- else
- {
- _root.turnToWalkOff();
- _root.sophie.behaviour = "walkOff";
- }
- }
- else if(_root.sophie.behaviour == "walkOff")
- {
- if(_root.sophie.xdir == -1 && _root.sophieClip._x < -20 || _root.sophie.xdir == 1 && _root.sophieClip._x > 630)
- {
- _root.sophie.pecked = 0;
- if(_root.sophie.targetX == undefined)
- {
- _root.chooseTarget();
- _root.sophie.behaviour = "actionDone";
- }
- else
- {
- _root.placeSophie();
- _root.sophie.waitCounter = 0;
- _root.sophie.behaviour = "wait";
- }
- }
- else
- {
- _root.sophieClip._x += _root.sophie.xdir * _root.sophie.speed;
- }
- }
- else if(_root.sophie.behaviour == "wait")
- {
- _root.sophie.waitCounter = _root.sophie.waitCounter + 1;
- if(_root.sophie.waitCounter > _root.sophie.waitTime)
- {
- _root.sophie.waitCounter = 0;
- _root.sophie.behaviour = "start";
- }
- }
- else if(_root.sophie.behaviour == "pecked")
- {
- }
- }
- function hideToys()
- {
- this.hiddenBlocks1 = new Object();
- this.hiddenBlocks2 = new Object();
- this.hiddenBlocks3 = new Object();
- this.hiddenBlocks4 = new Object();
- i = 0;
- while(i < _root.toyArray.length)
- {
- if(i < 2)
- {
- myFloor = 1;
- }
- else if(i < 5)
- {
- myFloor = 2;
- }
- else if(i < 8)
- {
- myFloor = 3;
- }
- else
- {
- myFloor = 4;
- }
- myHideBlock = _root["floor" + myFloor + "Blocks"][random(_root["floor" + myFloor + "Blocks"].length)];
- myItemInBlock = random(_root[myHideBlock].length);
- if(this["hiddenBlocks" + myFloor][myHideBlock] != undefined || _root[myHideBlock][myItemInBlock]._name == "cupboardDoor")
- {
- i--;
- }
- else
- {
- this["hiddenBlocks" + myFloor][myHideBlock] = 1;
- uid = _root.toys.getNextHighestDepth();
- clipName = "toy" + uid;
- _root.toys.attachMovie("toy",clipName,uid);
- if(myHideBlock == "superBlocky3x3")
- {
- _root.toys[clipName].inCupboard = 1;
- }
- _root.toys[clipName]._visible = 0;
- _root.toys[clipName].gotoAndStop(i + 1);
- _root.toys[clipName]._x = _root[myHideBlock][myItemInBlock].myX;
- _root.toys[clipName]._y = _root[myHideBlock][myItemInBlock].myY;
- _root.hiddenToys.push({myToy:_root.toyArray[i],myClip:clipName,myX:_root[myHideBlock][myItemInBlock].myX,myY:_root[myHideBlock][myItemInBlock].myY});
- }
- i++;
- }
- }
- function checkSophiesTarget(thisX, thisY)
- {
- }
- function gameOver()
- {
- _root.gameFinished = 1;
- if(_root.emuToys.length > _root.sophieToys.length)
- {
- _root.winner = "Emu";
- _root.emuState = "win";
- _root.sophieState = "lose";
- }
- else
- {
- _root.winner = "Sophie";
- _root.emuState = "lose";
- _root.sophieState = "win";
- }
- _root.endGameClip.play();
- }
- function peckDetector(peckHeight, peckFloor, peckSquare)
- {
- mySuperBlock = "superBlocky" + peckFloor + "x" + peckSquare;
- peckX = _root.emu._x + _root.emu.xdir * (_root.emu._width / 2);
- i = 0;
- while(i < _root.hiddenToys.length)
- {
- if(Math.abs(peckX - _root.hiddenToys[i].myX) < _root.proximity && Math.abs(_root.emu._y - peckHeight - _root.hiddenToys[i].myY) < _root.proximity * 2)
- {
- if(_root.toys[_root.hiddenToys[i].myClip]._visible)
- {
- _root.foundClip.myTextColour = "0x3366CC";
- _root.foundClip.myFoundText = "You Found The " + _root.hiddenToys[i].myToy;
- _root.foundClip.myFace = 1;
- _root.foundClip.gotoAndPlay(2);
- _root.toyCollected.start(0,1);
- _root.emuToys.push(_root.hiddenToys[i]);
- _root.checkSophiesTarget(_root.hiddenToys[i].myX,_root.hiddenToys[i].myY);
- _root.toys[_root.hiddenToys[i].myClip]._xscale = 100;
- _root.toys[_root.hiddenToys[i].myClip]._yscale = 100;
- _root.toys[_root.hiddenToys[i].myClip].pulse.gotoAndStop("found");
- _root.toys[_root.hiddenToys[i].myClip]._x = 82 + _root.emuToys.length * 38;
- _root.toys[_root.hiddenToys[i].myClip]._y = 495;
- _root.hiddenToys.splice(i,1);
- if(_root.emuToys.length == 5)
- {
- _root.gameOver();
- }
- break;
- }
- if(_root.toys[_root.hiddenToys[i].myClip].inCupboard == 1 && _root.cupboardOpen)
- {
- _root.toys[_root.hiddenToys[i].myClip]._visible = 1;
- _root.toyFound.start(0,1);
- }
- else if(_root.toys[_root.hiddenToys[i].myClip].inCupboard != 1)
- {
- _root.toys[_root.hiddenToys[i].myClip]._visible = 1;
- _root.toyFound.start(0,1);
- }
- }
- i++;
- }
- i = 0;
- while(i < _root[mySuperBlock].length)
- {
- if(_root[mySuperBlock][i].hit == 0)
- {
- myItem = _root[mySuperBlock][i].myName;
- myBounds = _root.blocks[myItem].getBounds(this);
- if(peckX > myBounds.xMin - _root.peckProx / 2 && peckX < myBounds.xMax + _root.peckProx / 2 && _root.emu._y - peckHeight + _root.peckProx > myBounds.yMin && _root.emu._y - peckHeight - _root.peckProx < myBounds.yMax && _root.blocks[myItem].cupboardClosed != 1)
- {
- if(Math.random() >= 0.5)
- {
- _root.blocks[myItem].xdir = 1;
- }
- else
- {
- _root.blocks[myItem].xdir = -1;
- }
- _root.blocks[myItem].gotoAndStop(2);
- _root.blocks[myItem].xmov = (random(8) + 4) * _root.blocks[myItem].xdir;
- _root.blocks[myItem].bounce = 0;
- _root.blocks[myItem].ymov = - (random(9) + 1);
- _root.checkSophiesTarget(_root[mySuperBlock][i].myX,_root[mySuperBlock][i].myY);
- _root[mySuperBlock][i].hit = 1;
- _root.activeItems[myItem] = 1;
- }
- }
- i++;
- }
- }
- function collisionDetector(myItem)
- {
- mySuperBlock = "superBlocky" + _root.blocks[myItem].myFloor + "x" + (Math.floor(_root.blocks[myItem]._x / 50) + 1);
- i = 0;
- while(i < _root[mySuperBlock].length)
- {
- if(!_root[mySuperBlock][i].hit)
- {
- targetItem = _root[mySuperBlock][i].myName;
- if(_root.blocks[myItem].hitTest(_root.blocks[targetItem]) && Math.abs(_root.blocks[myItem].xmov) > _root.xCriticalWeight || _root.blocks[myItem].hitTest(_root.blocks[targetItem]) && Math.abs(_root.blocks[myItem].ymov) > _root.yCriticalWeight)
- {
- _root.checkForItem(mySuperBlock,targetItem,i);
- _root.blocks[targetItem].gotoAndStop(2);
- _root.blocks[targetItem].xdir = _root.blocks[myItem].xdir;
- _root.blocks[targetItem].bounce = 0;
- newX = Math.round(_root.blocks[myItem].xmov / 2);
- if(_root.blocks[myItem].ymov < 0)
- {
- newY = Math.round(_root.blocks[myItem].ymov / 2);
- _root.blocks[myItem].ymov = newY;
- _root.blocks[targetItem].ymov = newY;
- }
- else
- {
- _root.blocks[targetItem].ymov = 0;
- }
- _root.blocks[myItem].xmov = newX;
- _root.blocks[targetItem].xmov = newX;
- n = 0;
- while(n < _root.hiddenToys.length)
- {
- if(Math.abs(_root.blocks[targetItem]._x - _root.hiddenToys[n].myX) < _root.proximity && Math.abs(_root.blocks[targetItem]._y - _root.hiddenToys[n].myY) < _root.proximity)
- {
- if(!_root[_root.hiddenToys[n].myClip]._visible)
- {
- _root[_root.hiddenToys[n].myClip]._visible = 1;
- _root.toyFound.start(0,1);
- }
- }
- n++;
- }
- _root.checkSophiesTarget(_root[mySuperBlock][i].myX,_root[mySuperBlock][i].myY);
- _root[mySuperBlock][i].hit = 1;
- _root.activeItems[targetItem] = 1;
- }
- }
- i++;
- }
- }
- function fallFoam(item)
- {
- if(_root.foams[item].ymov < _root.terminal)
- {
- _root.foams[item].ymov += _root.accel;
- }
- if(Math.abs(_root.foams[item].xmov) / _root.foams[item].xmov == _root.foams[item].xdir)
- {
- _root.foams[item].xmov -= _root.foams[item].xdir * _root.resistance;
- if(Math.abs(_root.foams[item].xmov) < 1)
- {
- _root.foams[item].xmov = 0;
- }
- _root.foams[item]._x += _root.foams[item].xmov;
- }
- if(_root.foams[item]._x > Stage.width)
- {
- _root.foams[item].xdir = -1;
- _root.foams[item].xmov = Math.abs(_root.foams[item].xmov) * _root.foams[item].xdir;
- }
- else if(_root.foams[item]._x < 0)
- {
- _root.foams[item].xdir = 1;
- _root.foams[item].xmov = Math.abs(_root.foams[item].xmov) * _root.foams[item].xdir;
- }
- if(_root.foams[item]._y + _root.foams[item]._height + _root.foams[item].ymov > _root["floor" + _root.foams[item].myFloor])
- {
- i = 0;
- while(i < _root["holeArray" + _root.foams[item].myFloor].length)
- {
- if(_root.foams[item]._x > _root["holeArray" + _root.foams[item].myFloor][i].xMin && _root.foams[item]._x < _root["holeArray" + _root.foams[item].myFloor][i].xMax)
- {
- _root.foams[item].myFloor = _root.foams[item].myFloor + 1;
- }
- i++;
- }
- }
- if(_root.foams[item]._y + _root.foams[item]._height + _root.foams[item].ymov >= _root["floor" + _root.foams[item].myFloor])
- {
- if(Math.abs(_root.foams[item].ymov) <= 2 || _root.foams[item].bounce > 8)
- {
- _root.foams[item]._y = _root["floor" + _root.foams[item].myFloor] - _root.foams[item]._height;
- _root.foams[item].gotoAndStop(3);
- _root.foams[item].ymov = 0;
- delete _root.activeItems[item];
- }
- else
- {
- _root.foams[item].bounce = _root.foams[item].bounce + 1;
- if(_root.foams[item]._y + _root.foams[item]._height + _root.foams[item].ymov - _root["floor" + _root.foams[item].myFloor] > 8)
- {
- _root.foams[item]._y = _root["floor" + _root.foams[item].myFloor] - _root.foams[item]._height - _root.foams[item].ymov;
- }
- else
- {
- _root.foams[item]._y = _root["floor" + _root.foams[item].myFloor] - _root.foams[item]._height;
- }
- _root.foams[item].ymov = - _root.foams[item].ymov * _root.restitution;
- }
- }
- else
- {
- _root.foams[item]._y += _root.foams[item].ymov;
- }
- }
- function fall(item)
- {
- if(_root.blocks[item].ymov < _root.terminal)
- {
- _root.blocks[item].ymov += _root.accel;
- }
- if(Math.abs(_root.blocks[item].xmov) / _root.blocks[item].xmov == _root.blocks[item].xdir)
- {
- _root.blocks[item].xmov -= _root.blocks[item].xdir * _root.resistance;
- if(Math.abs(_root.blocks[item].xmov) < 1)
- {
- _root.blocks[item].xmov = 0;
- }
- _root.blocks[item]._x += _root.blocks[item].xmov;
- }
- if(_root.blocks[item]._x > Stage.width)
- {
- _root.blocks[item].xdir = -1;
- _root.blocks[item].xmov = Math.abs(_root.blocks[item].xmov) * _root.blocks[item].xdir;
- }
- else if(_root.blocks[item]._x < 0)
- {
- _root.blocks[item].xdir = 1;
- _root.blocks[item].xmov = Math.abs(_root.blocks[item].xmov) * _root.blocks[item].xdir;
- }
- _root.collisionDetector(item);
- if(_root.blocks[item]._y + _root.blocks[item]._height + _root.blocks[item].ymov > _root["floor" + _root.blocks[item].myFloor])
- {
- i = 0;
- while(i < _root["holeArray" + _root.blocks[item].myFloor].length)
- {
- if(_root.blocks[item]._x > _root["holeArray" + _root.blocks[item].myFloor][i].xMin && _root.blocks[item]._x < _root["holeArray" + _root.blocks[item].myFloor][i].xMax)
- {
- _root.blocks[item].myFloor = _root.blocks[item].myFloor + 1;
- }
- i++;
- }
- }
- if(_root.blocks[item]._y + _root.blocks[item]._height + _root.blocks[item].ymov >= _root["floor" + _root.blocks[item].myFloor])
- {
- if(Math.abs(_root.blocks[item].ymov) <= 2 || _root.blocks[item].bounce > 8)
- {
- _root.blocks[item]._y = _root["floor" + _root.blocks[item].myFloor] - _root.blocks[item]._height;
- _root.blocks[item].gotoAndStop(3);
- _root.blocks[item].ymov = 0;
- delete _root.activeItems[item];
- }
- else
- {
- _root.blocks[item].bounce = _root.blocks[item].bounce + 1;
- if(_root.blocks[item]._y + _root.blocks[item]._height + _root.blocks[item].ymov - _root["floor" + _root.blocks[item].myFloor] > 8)
- {
- _root.blocks[item]._y = _root["floor" + _root.blocks[item].myFloor] - _root.blocks[item]._height - _root.blocks[item].ymov;
- }
- else
- {
- _root.blocks[item]._y = _root["floor" + _root.blocks[item].myFloor] - _root.blocks[item]._height;
- }
- _root.blocks[item].ymov = - _root.blocks[item].ymov * _root.restitution;
- }
- }
- else
- {
- _root.blocks[item]._y += _root.blocks[item].ymov;
- }
- }
- _root.accel = 2;
- _root.terminal = 12;
- _root.restitution = 0.8;
- _root.resistance = 0.1;
- _root.emu.landing = 0;
- _root.emu.speed = 0;
- _root.proximity = 25;
- _root.peckProx = 20;
- _root.emu.peckPointer = 1;
- _root.peckReleased = 1;
- _root.emu.inLift = 0;
- _root.emu.emuHeight = 55;
- _root.xCriticalWeight = 40;
- _root.yCriticalWeight = 40;
- _root.activeItems = new Object();
- _root.activeFoams = new Object();
- _root.floor1 = 119;
- _root.floor2 = 239;
- _root.floor3 = 360;
- _root.floor4 = 479;
- _root.peckHeight1 = -30;
- _root.peckHeight2 = -15;
- _root.peckHeight3 = 0;
- _root.peckHeight4 = 18;
- _root.toyArray = new Array("Teddy","Rollerskate","Ball","Train","Glasses","Robot","Rattle","Horn","Ducky","Car","Boomerang");
- _root.hiddenToys = new Array();
- _root.emuToys = new Array();
- _root.sophieToys = new Array();
- _root.sophie = new Object();
- _root.sophie.homing = 0;
- _root.sophie.behaviour = "start";
- _root.sophie.targetX = 0;
- _root.sophie.targetY = 0;
- _root.sophie.counter = 0;
- _root.sophie.speed = 8;
- _root.sophie.xdir = -1;
- _root.sophie.pecked = 0;
- _root.sophie.waitCounter = 0;
- _root.sophie.waitTime = 10;
- _root.sophie.myFloor = 1;
- _root.sophie.pausedState = 0;
- _root.chooseTarget("initial");
- _root.placeSophie();
- _root.cupboardOpen = 0;
- _root.gameFinished = 0;
- _root.gameTimer = getTimer() + 15000;
- hideToys();
- stop();
-