home *** CD-ROM | disk | FTP | other *** search
- function matterHitTest(pPosX, pPosY, pSensor)
- {
- tCheckX = pPosX + sensors[pSensor].x;
- tCheckY = pPosY + sensors[pSensor].y;
- return _root.world.matter.hitTest(tCheckX,tCheckY,true);
- }
- function solidHitTest(pPosX, pPosY, pSensor)
- {
- tCheckX = pPosX + sensors[pSensor].x;
- tCheckY = pPosY + sensors[pSensor].y;
- return _root.world.matter.solid.hitTest(tCheckX,tCheckY,true);
- }
- function deadlyHitTest(pPosX, pPosY, pSensor)
- {
- tCheckX = pPosX + sensors[pSensor].x;
- tCheckY = pPosY + sensors[pSensor].y;
- return _root.world.matter.deadly.hitTest(tCheckX,tCheckY,true);
- }
- function objectsHitTest(pPosX, pPosY, pSensor)
- {
- tCheckX = pPosX + sensors[pSensor].x;
- tCheckY = pPosY + sensors[pSensor].y;
- tResults = new Array();
- tResultCount = 0;
- tRegId = 0;
- while(tRegId < _root.world.regCount)
- {
- if(_root.world.regObjects[tRegId].hitTest(tCheckX,tCheckY,false) && _root.world.regObjects[tRegId].hitTest(tCheckX,tCheckY,true))
- {
- tResults[tResultCount++] = _root.world.regObjects[tRegId];
- }
- tRegId++;
- }
- return tResults;
- }
- function Sensor(pX, pY, pBounceH, pBounceV, pActive, pDieAtDanger, pHitObjects, pPassSolid)
- {
- tThis = new Object();
- tThis.x = pX;
- tThis.y = pY;
- tThis.bounceH = pBounceH;
- tThis.bounceV = pBounceV;
- tThis.active = pActive;
- tThis.dieAtDanger = pDieAtDanger;
- tThis.hitObjects = pHitObjects;
- tThis.passSolid = pPassSolid;
- return tThis;
- }
- function refill()
- {
- _global.stat.actShots = _global.opt.startShots;
- }
- function reset()
- {
- needCollect = 0;
- _parent.resetLevel();
- _root.console.time = _global.opt.startTime;
- timerMax = 25;
- timer = timerMax;
- vx = 0;
- vy = 0;
- vr = 0;
- refill();
- mainSprite._x = 275;
- mainSprite._y = wallBottom;
- clowns[0].mode = MODE_STANDING;
- clowns[1].mode = MODE_FLYING;
- clowns[0].gotoAndStop("standing");
- clowns[1].gotoAndStop("flying");
- clowns[1]._x = clowns[1].originalX;
- clowns[1]._y = clowns[1].originalY;
- i = 0;
- while(i < 2)
- {
- clowns[i].plankX = 0.5;
- clowns[i].vx = 0;
- clowns[i].vy = 0;
- clowns[i].health = 1;
- updateHealth(clowns[i]);
- i++;
- }
- mainSprite.plank.maxRotation = 15;
- mainSprite.plank._rotation = -1 * mainSprite.plank.maxRotation;
- plankTargetX = mainSprite._x;
- clowns[0]._x = calcOnPlankX(0);
- clowns[0]._y = calcOnPlankY(0);
- }
- function setScore(pScore)
- {
- _global.stat.actScore = pScore;
- _root.console.score = _global.stat.actScore;
- }
- function addToScore(pScore)
- {
- _global.stat.actScore += pScore;
- _root.console.score = _global.stat.actScore;
- }
- function addHealthToFlying(pAdd)
- {
- flyingClown.health += pAdd;
- if(flyingClown.health > 1)
- {
- flyingClown.health = 1;
- }
- updateHealth(flyingClown);
- }
- function damageHealth(pClown, pDamage)
- {
- pClown.health -= pDamage;
- if(pClown.health < 0)
- {
- pClown.health = 0;
- updateHealth(pClown);
- pClown.gotoAndStop("dead");
- gotoAndPlay(7);
- }
- else
- {
- updateHealth(pClown);
- }
- }
- function updateHealth(pClown)
- {
- tFrame = Math.round(pClown.healthDisplay._totalframes * pClown.health);
- if(tFrame < 1)
- {
- tFrame = 1;
- }
- pClown.healthDisplay.gotoAndStop(tFrame);
- }
- function updateLifes()
- {
- if(_global.stat.actLifes < 5)
- {
- _root.console.lifes.gotoAndStop(_global.stat.actLifes + 1);
- }
- else
- {
- _root.console.lifes.gotoAndStop(6);
- _root.console.actLifes = _global.stat.actLifes;
- }
- }
- function setClownStanding(pClown)
- {
- pClown._x = mainSprite._x + pClown.plankX * pClown.mirrorX * plankWidth * 0.5;
- pClown._y = wippeTop + mainSprite.plank._rotation;
- }
- function calcOnPlankY(pId)
- {
- return axisY + Math.sin(mainSprite.plank._rotation / 180 * 3.141592653589793) * clowns[pId].mirrorX * plankWidth / 2 * clowns[pId].plankX;
- }
- function calcOnPlankX(pId)
- {
- return plankTargetX + Math.cos(mainSprite.plank._rotation / 180 * 3.141592653589793) * clowns[pId].mirrorX * plankWidth / 2 * clowns[pId].plankX;
- }
- function calcPlankLandingX(pId)
- {
- return (clowns[pId].targetX - plankTargetX) / (plankWidth / 2) * clowns[pId].mirrorX;
- }
- sensors = new Array();
- sensorAmount = 8;
- sensors[0] = Sensor(0,0,0,0,true,true,true,true);
- sensors[1] = Sensor(0,-35,0,0,true,true,true,true);
- sensors[2] = Sensor(22,-12,0,0,true,true,true,true);
- sensors[3] = Sensor(-22,-12,0,0,true,true,true,true);
- sensors[4] = Sensor(22,-24,0,0,true,true,true,true);
- sensors[5] = Sensor(-22,-24,0,0,true,true,true,true);
- sensors[6] = Sensor(0,-12,0,0,true,true,true,true);
- sensors[7] = Sensor(0,-24,0,0,true,true,true,true);
- plankWidth = 130;
- setScore(_global.stat.actScore);
- updateLifes();
- mainSprite.cycle.monkey.stop();
- mainSprite.cycle.monkeyLeg.stop();
- mainSprite.cycle.stop();
- vxMax = 5;
- vyMax = 5;
- ax = 5;
- gravity = 0.33;
- fx = 0;
- fy = 0;
- wallLeft = 0;
- wallRight = 550;
- wallTop = 32;
- wallBottom = 395;
- axisY = wallBottom - 20;
- wippeHeight = 40;
- wippeTop = wallBottom - wippeHeight;
- lifes = _global.stat.actLifes;
- updateLifes();
- clowns = new Array();
- clowns[0] = clownLeft;
- clowns[1] = clownRight;
- clowns[0].partner = clownRight;
- clowns[1].partner = clownLeft;
- clowns[0].originalX = clowns[0]._x;
- clowns[0].originalY = clowns[0]._y;
- clowns[1].originalX = clowns[1]._x;
- clowns[1].originalY = clowns[1]._y;
- MODE_FLYING = 1;
- MODE_STANDING = 0;
- MODE_RETURNING = 2;
- clowns[0].lookDir = "right";
- clowns[1].lookDir = "left";
- clowns[0].healthDisplay = _root.console.health_left;
- clowns[1].healthDisplay = _root.console.health_right;
-