home *** CD-ROM | disk | FTP | other *** search
/ 600 Games / 600games.iso / Classicos / pepsi_pinball.swf / scripts / frame_8 / DoAction_4.as < prev    next >
Encoding:
Text File  |  2006-05-18  |  19.4 KB  |  668 lines

  1. function initGame()
  2. {
  3.    numBalls = 5;
  4.    currBall = 0;
  5.    score = 0;
  6.    bonus = 0;
  7.    breakOutMode = false;
  8.    soundIndice = 0;
  9.    activeBumperStrength = 2;
  10.    activeLargeBumperStrength = 1.75;
  11.    passiveBumperStrength = 0.75;
  12.    flipperStrength = 15;
  13.    initAllObjects();
  14. }
  15. function launchNewBall()
  16. {
  17.    currBall++;
  18.    display_mc.gotoAndPlay("start");
  19.    mainRamp.gotoAndPlay(2);
  20.    ball.mode = "rampDown";
  21.    score_mc.disp_currBall = currBall;
  22.    playSound(M_launchNewBall_snd);
  23. }
  24. function display(mode, str1, str2, str3, str4, str5, str6, str7, str8, str9, str10, str11, str12)
  25. {
  26.    var displayObj = new Object();
  27.    var i = 1;
  28.    while(i <= 12)
  29.    {
  30.       var str = eval("str" + i);
  31.       displayObj["str" + i] = str;
  32.       trace("DISPLAY: " + str);
  33.       if(str == -1)
  34.       {
  35.          count = i;
  36.          break;
  37.       }
  38.       i++;
  39.    }
  40.    if(mode == 0)
  41.    {
  42.       display_mc.gotoAndPlay("start");
  43.       display_mc.displayObj = displayObj;
  44.    }
  45.    else if(mode == 1)
  46.    {
  47.       this.attachMovie("B_scoreBoard","scoreBoard",5000);
  48.       scoreBoard.displayObj = displayObj;
  49.       scoreBoard._x = 348;
  50.       scoreBoard._y = 307.5;
  51.    }
  52.    else if(mode == 2)
  53.    {
  54.       this.attachMovie("mainScoreBoard","scoreBoard",5000);
  55.       scoreBoard.displayObj = displayObj;
  56.       scoreBoard._x = 357;
  57.       scoreBoard._y = 251;
  58.    }
  59.    return 800 * (count - 1) + 2200;
  60. }
  61. function endBall()
  62. {
  63.    trace("END BALL");
  64.    ball.mode = "stop";
  65.    var dispBonus = score_mc.mainBonus;
  66.    if(score_mc.bonusLevel == 0)
  67.    {
  68.       var dispTotal = score_mc.mainScore + score_mc.mainBonus;
  69.       dispTimer = display(1,"Ball Lost!","Bonus",addSpace(dispBonus),-1);
  70.    }
  71.    else
  72.    {
  73.       var dispMult = score_mc.bonusMult;
  74.       var dispBonusMult = score_mc.mainBonus * score_mc.bonusMult;
  75.       var dispTotal = score_mc.mainScore + dispBonusMult;
  76.       dispTimer = display(1,"Ball Lost!","Bonus",addSpace(dispBonus),"x" + dispMult,addSpace(dispBonusMult),-1);
  77.    }
  78.    score_mc.mainScore = dispTotal;
  79.    timer = setInterval(function()
  80.    {
  81.       score_mc.resetAfterBall();
  82.       launchNewBall();
  83.       clearInterval(timer);
  84.    }
  85.    ,dispTimer);
  86. }
  87. function endGame()
  88. {
  89.    trace("END GAME");
  90.    ball.mode = "stop";
  91.    BG_pepsiTitle.animateLight();
  92.    playSoundLoop(T_musicIntro_snd,100);
  93.    var dispBonus = score_mc.mainBonus;
  94.    if(score_mc.bonusLevel == 0)
  95.    {
  96.       var dispTotal = score_mc.mainScore + score_mc.mainBonus;
  97.       dispTimer = display(1,"Game Over!","Bonus",addSpace(dispBonus),-2,addSpace(dispTotal),-1);
  98.    }
  99.    else
  100.    {
  101.       var dispMult = score_mc.bonusMult;
  102.       var dispBonusMult = score_mc.mainBonus * score_mc.bonusMult;
  103.       var dispTotal = score_mc.mainScore + dispBonusMult;
  104.       dispTimer = display(1,"Game Over!","Bonus",addSpace(dispBonus),"x" + dispMult,addSpace(dispBonusMult),-2,addSpace(dispTotal),-1);
  105.    }
  106.    score_mc.mainScore = dispTotal;
  107.    timer = setInterval(function()
  108.    {
  109.       clearInterval(timer);
  110.    }
  111.    ,dispTimer);
  112. }
  113. function submitScore()
  114. {
  115.    toSend = new LoadVars();
  116.    toSend.gobbledeegook = score_mc.mainScore;
  117.    toSend.send("submitscore.asp","_self","POST");
  118. }
  119. function initAllObjects()
  120. {
  121.    initBonus();
  122.    initBall();
  123.    initWalls();
  124.    initFlippers();
  125.    initBumpers();
  126.    initTargets();
  127.    initMainRamp();
  128.    initLargeBumpers();
  129.    initSwitches();
  130.    initCart();
  131. }
  132. function initBonus()
  133. {
  134.    numBonus = count("bonus");
  135.    var bonusLabel = new Array("x2","x4","x6","x8","x10","hold");
  136.    bonus = new Array();
  137.    i = 0;
  138.    while(i < numBonus)
  139.    {
  140.       var mc = _root["bonus" + i];
  141.       mc.disp_label_mc.text = bonusLabel[i];
  142.       bonus.push(new tBonus(mc));
  143.       i++;
  144.    }
  145. }
  146. function initBall()
  147. {
  148.    radius = 12.5;
  149.    gravity = 0.275;
  150.    bounce = 0.8;
  151.    friction = 0.998;
  152.    maxSpeed = 15;
  153.    toRad = 0.017453292519943295;
  154.    toDeg = 57.29577951308232;
  155.    TOP = 0;
  156.    BOTTOM = 547;
  157.    LEFT = 0;
  158.    RIGHT = 694;
  159.    var mc = ball_mc;
  160.    var pos = new Position(ballLaunch._x,ballLaunch._y);
  161.    var vel = new Position(0,-10);
  162.    ball = new tBall(mc,pos,vel);
  163. }
  164. function initWalls()
  165. {
  166.    numWalls = count("dot");
  167.    numWalls--;
  168.    wall = new Array();
  169.    i = 0;
  170.    while(i < numWalls)
  171.    {
  172.       var mc = attachMovie("wall","wall" + i,1000 + i);
  173.       mc._visible = showWall;
  174.       mc.n = i;
  175.       mc._x = _root["dot" + i]._x;
  176.       mc._y = _root["dot" + i]._y;
  177.       var pos = new Position(mc._x,mc._y);
  178.       var end = new Position(_root["dot" + (i + 1)]._x,_root["dot" + (i + 1)]._y);
  179.       mc._width = dist(pos.x,pos.y,end.x,end.y);
  180.       var angleRad = Math.atan2(end.y - pos.y,end.x - pos.x);
  181.       var angleDeg = mc._rotation = angleRad * toDeg;
  182.       wall.push(new tWall(mc,angleRad,pos));
  183.       i++;
  184.    }
  185. }
  186. function initMainRamp()
  187. {
  188.    numLeftWalls = count("leftDot",_root.mainRamp) - 1;
  189.    numRightWalls = count("rightDot",_root.mainRamp) - 1;
  190.    rampWall = new Array();
  191.    i = 0;
  192.    while(i < numLeftWalls)
  193.    {
  194.       var mc = attachMovie("wall","rampWall" + i,2000 + i);
  195.       mc._visible = showWall;
  196.       mc._x = _root.mainRamp["leftDot" + i]._x + mainRamp._x;
  197.       mc._y = _root.mainRamp["leftDot" + i]._y + mainRamp._y;
  198.       var pos = new Position(mc._x,mc._y);
  199.       var endx = _root.mainRamp["leftDot" + (i + 1)]._x + mainRamp._x;
  200.       var endy = _root.mainRamp["leftDot" + (i + 1)]._y + mainRamp._y;
  201.       var end = new Position(endx,endy);
  202.       mc._width = dist(pos.x,pos.y,end.x,end.y);
  203.       var angleRad = Math.atan2(end.y - pos.y,end.x - pos.x);
  204.       var angleDeg = mc._rotation = angleRad * toDeg;
  205.       rampWall.push(new tWall(mc,angleRad,pos));
  206.       i++;
  207.    }
  208.    i = 0;
  209.    while(i < numRightWalls)
  210.    {
  211.       var indice = i + 100;
  212.       var mc = attachMovie("wall","rampWall" + indice,2000 + indice);
  213.       mc._visible = showWall;
  214.       mc._x = _root.mainRamp["rightDot" + i]._x + mainRamp._x;
  215.       mc._y = _root.mainRamp["rightDot" + i]._y + mainRamp._y;
  216.       var pos = new Position(mc._x,mc._y);
  217.       var endx = _root.mainRamp["rightDot" + (i + 1)]._x + mainRamp._x;
  218.       var endy = _root.mainRamp["rightDot" + (i + 1)]._y + mainRamp._y;
  219.       var end = new Position(endx,endy);
  220.       mc._width = dist(pos.x,pos.y,end.x,end.y);
  221.       var angleRad = Math.atan2(end.y - pos.y,end.x - pos.x);
  222.       var angleDeg = mc._rotation = angleRad * toDeg;
  223.       rampWall.push(new tWall(mc,angleRad,pos));
  224.       i++;
  225.    }
  226. }
  227. function initFlippers()
  228. {
  229.    numFlippers = count("flipper");
  230.    flipper = new Array();
  231.    i = 0;
  232.    while(i < numFlippers)
  233.    {
  234.       var mc = _root["flipper" + i];
  235.       var pos = new Position(mc._x,mc._y);
  236.       var length = mc._width;
  237.       var angle = mc._rotation;
  238.       flipper[i] = new tFlipper(mc,angle,length,pos);
  239.       flipper[i].type = flipper[i].mc.type;
  240.       flipper[i].strength = flipperStrength;
  241.       flipper[i].angleSup = -5.22;
  242.       flipper[i].angleInf = 5.22;
  243.       i++;
  244.    }
  245. }
  246. function initBumpers()
  247. {
  248.    numBumpers = count("bumper");
  249.    bumper = new Array();
  250.    var i = 0;
  251.    while(i < numBumpers)
  252.    {
  253.       var mc = _root["bumper" + i];
  254.       var bRadius = mc._width;
  255.       if(i <= 2)
  256.       {
  257.          var strength = activeBumperStrength;
  258.       }
  259.       else
  260.       {
  261.          var strength = passiveBumperStrength;
  262.       }
  263.       var pos = new Position(mc._x,mc._y);
  264.       var clip = _root["sombrero" + i];
  265.       bumper[i] = new tBumper(mc,bRadius,strength,pos,clip);
  266.       i++;
  267.    }
  268. }
  269. function initTargets()
  270. {
  271.    saloon_mc.setDoorClose();
  272.    numTargetHit = 0;
  273.    numTargets = count("target",_root.allTargets);
  274.    target = new Array();
  275.    var letter = "PEPSISALOON";
  276.    var i = 0;
  277.    while(i < numTargets)
  278.    {
  279.       var mc = _root.allTargets["target" + i];
  280.       mc.gotoAndStop("on");
  281.       var x = mc._x + mc.bumper0._x + allTargets._x;
  282.       var y = mc._y + mc.bumper0._y + allTargets._y;
  283.       mc.disp_letter = letter.charAt(i);
  284.       var pos = new Position(x,y);
  285.       var bRadius = mc.bumper0._width;
  286.       var hitStatus = true;
  287.       target[i] = new tTarget(mc,bRadius,1.5,pos,hitStatus);
  288.       i++;
  289.    }
  290. }
  291. function initLargeBumpers()
  292. {
  293.    var numLargeBumpers = count("largeBumper");
  294.    largeBumper = new Array();
  295.    j = 0;
  296.    while(j < numLargeBumpers)
  297.    {
  298.       largeBumper[j] = new Object();
  299.       largeBumper[j].mc = _root["largeBumper" + j];
  300.       var numSmallBumpers = count("bumper",largeBumper[j].mc);
  301.       largeBumper[j].bumper = new Array();
  302.       i = 0;
  303.       while(i < numSmallBumpers)
  304.       {
  305.          var mc = _root["largeBumper" + j]["bumper" + i];
  306.          var bRadius = mc._width;
  307.          var strength = activeLargeBumperStrength;
  308.          var pos = new Position(mc._x,mc._y);
  309.          pos.x += largeBumper[j].mc._x;
  310.          pos.y += largeBumper[j].mc._y;
  311.          largeBumper[j].bumper[i] = new tBumper(mc,bRadius,strength,pos);
  312.          i++;
  313.       }
  314.       var numWalls = count("dot",largeBumper[j].mc) / 2;
  315.       largeBumper[j].wall = new Array();
  316.       i = 0;
  317.       while(i < numWalls)
  318.       {
  319.          wallDepth++;
  320.          var str = "wall" + wallDepth;
  321.          _root["largeBumper" + j].attachMovie("wall",str,wallDepth);
  322.          var mc = _root["largeBumper" + j][str];
  323.          mc._x = _root["largeBumper" + j]["dot" + i * 2]._x;
  324.          mc._y = _root["largeBumper" + j]["dot" + i * 2]._y;
  325.          var pos = new Position(mc._x,mc._y);
  326.          var endx = _root["largeBumper" + j]["dot" + (i * 2 + 1)]._x;
  327.          var endy = _root["largeBumper" + j]["dot" + (i * 2 + 1)]._y;
  328.          var end = new Position(endx,endy);
  329.          mc._width = dist(pos.x,pos.y,end.x,end.y);
  330.          var angleRad = Math.atan2(end.y - pos.y,end.x - pos.x);
  331.          mc._rotation = angleRad * toDeg;
  332.          pos.x += largeBumper[j].mc._x;
  333.          pos.y += largeBumper[j].mc._y;
  334.          largeBumper[j].wall.push(new tWall(mc,angleRad,pos));
  335.          i++;
  336.       }
  337.       j++;
  338.    }
  339.    largeBumper[0].bumper[0].strength = 0.75;
  340.    largeBumper[0].bumper[5].strength = 0.75;
  341. }
  342. function initSwitches()
  343. {
  344.    gateFlag = new Array(false,false,false);
  345.    numSwitches = count("switch",_root.switch_mc);
  346.    gateSwitch = new Array();
  347.    var i = 0;
  348.    while(i < numSwitches)
  349.    {
  350.       var mc = switch_mc["switch" + i];
  351.       mc.gotoAndStop("off");
  352.       gateSwitch.push(new tSwitch(mc,false));
  353.       i++;
  354.    }
  355. }
  356. function initCart()
  357. {
  358.    cart = new Object();
  359.    cart.mc = eval(_root.cart_mc);
  360.    var numSmallBumpers = count("bumper",cart.mc);
  361.    cart.bumper = new Array();
  362.    i = 0;
  363.    while(i < numSmallBumpers)
  364.    {
  365.       var mc = cart.mc["bumper" + i];
  366.       var bRadius = mc._width / 2;
  367.       var strength = activeLargeBumperStrength;
  368.       var pos = new Position(mc._x,mc._y);
  369.       pos.x += cart.mc._x;
  370.       pos.y += cart.mc._y;
  371.       cart.pos = new Position(pos.x,pos.y);
  372.       cart.bumper[i] = new tBumper(mc,bRadius,strength,pos);
  373.       i++;
  374.    }
  375. }
  376. function moveBall()
  377. {
  378.    ball.oldPos.x = ball.pos.x;
  379.    ball.oldPos.y = ball.pos.y;
  380.    ball.vel.y += gravity;
  381.    ball.vel.x *= friction;
  382.    ball.vel.y *= friction;
  383.    var velocity = new tVector(ball.vel.x,ball.vel.y);
  384.    if(velocity.norm > maxSpeed)
  385.    {
  386.       ball.vel.x = maxSpeed * Math.cos(velocity.phiRad);
  387.       ball.vel.y = maxSpeed * Math.sin(velocity.phiRad);
  388.    }
  389.    ball.pos.x += ball.vel.x;
  390.    ball.pos.y += ball.vel.y;
  391.    ball.mc._x = ball.pos.x;
  392.    ball.mc._y = ball.pos.y;
  393. }
  394. function scaleBall()
  395. {
  396.    var size;
  397.    var minSize = 20;
  398.    var maxSize = 25;
  399.    var minY = 68;
  400.    var maxY = 487;
  401.    var size = (ball.pos.y - minY) / (maxY - minY);
  402.    var size = (maxSize - minSize) * size + minSize;
  403.    var scale = size * 4;
  404.    ball.mc._xscale = scale;
  405.    ball.mc._yscale = scale;
  406.    radius = size / 2;
  407. }
  408. function checkOutScreen()
  409. {
  410.    if(ball.pos.y > BOTTOM || ball.pos.x < LEFT || ball.pos.x > RIGHT || ball.pos.y < TOP)
  411.    {
  412.       if(currBall == numBalls)
  413.       {
  414.          endGame();
  415.       }
  416.       else
  417.       {
  418.          endBall();
  419.       }
  420.    }
  421. }
  422. function checkWalls()
  423. {
  424.    for(i in wall)
  425.    {
  426.       if(wall[i].mc.hitTest(ball.mc))
  427.       {
  428.          doWallCollision(wall[i],ball);
  429.          if(saloonDoorOpen && saloonHitZone.hitTest(ball.pos.x,ball.pos.y,true))
  430.          {
  431.             ball.mode = "saloonEntrance";
  432.          }
  433.       }
  434.    }
  435. }
  436. function checkMainRamp()
  437. {
  438.    for(i in rampWall)
  439.    {
  440.       if(rampWall[i].mc.hitTest(ball.mc))
  441.       {
  442.          doWallCollision(rampWall[i],ball);
  443.       }
  444.    }
  445. }
  446. function checkFlippers()
  447. {
  448.    for(i in flipper)
  449.    {
  450.       if(flipper[i].mc.hitTest(ball.mc))
  451.       {
  452.          if(flipper[i].mc.hitZoneInf.hitTest(ball.pos.x,ball.pos.y,true))
  453.          {
  454.             var angleSurf = flipper[i].angle + flipper[i].angleInf;
  455.             var angleVel = Math.atan2(ball.vel.y,ball.vel.x) * toDeg;
  456.             var normVel = dist(0,0,ball.vel.x,ball.vel.y);
  457.             normVel *= bounce;
  458.             do
  459.             {
  460.                ball.pos.y += 0.25;
  461.             }
  462.             while(flipper[i].mc.hitZoneInf.hitTest(ball.pos.x,ball.pos.y,true));
  463.             
  464.             var newAngleVel = - angleVel + angleSurf;
  465.             if(flipper[i].moving)
  466.             {
  467.                var fl = new tVector();
  468.                var fSpeed = Math.abs(ball.pos.x - flipper[i].pos.x) / 55 * flipper[i].strength;
  469.                fl.x = fSpeed * Math.sin(angleSurf * toRad);
  470.                fl.y = (- fSpeed) * Math.cos(angleSurf * toRad);
  471.             }
  472.             ball.vel.x = normVel * Math.cos(newAngleVel * toRad) + fl.x;
  473.             ball.vel.y = normVel * Math.sin(newAngleVel * toRad) + fl.y;
  474.          }
  475.          if(flipper[i].mc.hitZoneSup.hitTest(ball.pos.x,ball.pos.y,true))
  476.          {
  477.             var angleSurf = flipper[i].angle + flipper[i].angleSup;
  478.             var angleVel = Math.atan2(ball.vel.y,ball.vel.x) * toDeg;
  479.             var normVel = dist(0,0,ball.vel.x,ball.vel.y);
  480.             normVel *= bounce;
  481.             do
  482.             {
  483.                ball.pos.y -= 0.25;
  484.             }
  485.             while(flipper[i].mc.hitZoneSup.hitTest(ball.pos.x,ball.pos.y,true));
  486.             
  487.             var newAngleVel = - angleVel + angleSurf;
  488.             if(flipper[i].moving)
  489.             {
  490.                var fl = new tVector();
  491.                var fSpeed = Math.abs(ball.pos.x - flipper[i].pos.x) / 55 * flipper[i].strength;
  492.                fl.x = fSpeed * Math.sin(angleSurf * toRad);
  493.                fl.y = (- fSpeed) * Math.cos(angleSurf * toRad);
  494.             }
  495.             ball.vel.x = normVel * Math.cos(newAngleVel * toRad) + fl.x;
  496.             ball.vel.y = normVel * Math.sin(newAngleVel * toRad) + fl.y;
  497.          }
  498.          if(flipper[i].mc.endHitZone.hitTest(ball.pos.x,ball.pos.y,true))
  499.          {
  500.             var end = new Position(flipper[i].mc._x,flipper[i].mc._y);
  501.             if(flipper[i].mc.type == "left")
  502.             {
  503.                end.x += 55 * Math.cos(flipper[i].angle * toRad);
  504.                end.y += 55 * Math.sin(flipper[i].angle * toRad);
  505.             }
  506.             else
  507.             {
  508.                end.x += -55 * Math.cos(flipper[i].angle * toRad);
  509.                end.y += -55 * Math.sin(flipper[i].angle * toRad);
  510.             }
  511.             var bv = new tVector(ball.vel.x,ball.vel.y);
  512.             var bm = new tVector(ball.pos.x - end.x,ball.pos.y - end.y);
  513.             bm = normalizeVect(bm);
  514.             bm = new tVector(bm.x * bv.norm * bounce,bm.y * bv.norm * bounce);
  515.             var fl = new tVector();
  516.             var fSpeed = flipper[i].strength;
  517.             fl.x = fSpeed * Math.sin(flipper[i].angle * toRad) * flipper[i].moving;
  518.             fl.y = (- fSpeed) * Math.cos(flipper[i].angle * toRad) * flipper[i].moving;
  519.             var sum = sumVect(bv,bm,fl);
  520.             ball.vel.x = sum.x;
  521.             ball.vel.y = sum.y;
  522.          }
  523.       }
  524.    }
  525. }
  526. function checkBumpers()
  527. {
  528.    for(i in bumper)
  529.    {
  530.       if(bumper[i].mc.hitTest(ball.mc))
  531.       {
  532.          doPointCollision(bumper[i],ball);
  533.          bumper[i].clip.gotoAndPlay("play");
  534.          score_mc.addScore("bumper");
  535.          if(bumper[i].strength == activeBumperStrength)
  536.          {
  537.             playSound(M_bumper_snd);
  538.          }
  539.       }
  540.    }
  541. }
  542. function checkTargets()
  543. {
  544.    if(allTargets.hitTest(ball.mc))
  545.    {
  546.       for(var i in target)
  547.       {
  548.          if(target[i].hitStatus && target[i].mc.bumper0.hitTest(ball.mc))
  549.          {
  550.             doPointCollision(target[i],ball);
  551.             target[i].hitStatus = false;
  552.             target[i].mc.gotoAndStop("off");
  553.             score_mc.addScore("target");
  554.             playSound(M_target_snd);
  555.             numTargetHit++;
  556.             if(numTargetHit >= target.length)
  557.             {
  558.                numTargetHit = 0;
  559.                saloon_mc.setDoorOpen();
  560.                score_mc.addScore("saloonDoor");
  561.                playSound(M_saloonDoor_snd);
  562.             }
  563.          }
  564.       }
  565.    }
  566. }
  567. function checkLargeBumpers()
  568. {
  569.    for(var j in largeBumper)
  570.    {
  571.       if(largeBumper[j].mc.hitTest(ball.mc))
  572.       {
  573.          for(var i in largeBumper[j].bumper)
  574.          {
  575.             if(largeBumper[j].bumper[i].mc.hitTest(ball.mc))
  576.             {
  577.                doPointCollision(largeBumper[j].bumper[i],ball);
  578.                score_mc.addScore("largeBumper");
  579.                var volume = calculateVolume(ball.vel) - 40;
  580.                playSoundVolume(M_barrel_snd,volume);
  581.             }
  582.          }
  583.       }
  584.    }
  585. }
  586. function checkSwitches()
  587. {
  588.    if(switch_mc.hitTest(ball.mc))
  589.    {
  590.       for(var i in gateSwitch)
  591.       {
  592.          if(gateSwitch[i].mc.hitZone.hitTest(ball.pos.x,ball.pos.y,true))
  593.          {
  594.             if(!gateFlag[validatingGate])
  595.             {
  596.                gateSwitch[i].setOn();
  597.                score_mc.addScore("switch");
  598.                if(gateSwitch[0].hitStatus && gateSwitch[1].hitStatus && gateSwitch[2].hitStatus)
  599.                {
  600.                   validatingGate = i;
  601.                   gateFlag[validatingGate] = true;
  602.                   score_mc.bonusUp();
  603.                   score_mc.addScore("allSwitch");
  604.                   score_mc.addScore("switch");
  605.                   playSound(M_ding_mc);
  606.                   for(var j in gateSwitch)
  607.                   {
  608.                      gateSwitch[j].setOff();
  609.                   }
  610.                }
  611.             }
  612.          }
  613.          else if(i == validatingGate)
  614.          {
  615.             gateFlag[validatingGate] = false;
  616.          }
  617.       }
  618.    }
  619. }
  620. function checkCart()
  621. {
  622.    if(cart.mc.hitTest(ball.mc))
  623.    {
  624.       var collision = true;
  625.       if(cart.mc.hitZone.hitTest(ball.pos.x,ball.pos.y,true))
  626.       {
  627.          var velocity = new tVector(ball.vel.x,ball.vel.y);
  628.          if(velocity.phiDeg <= -90 && velocity.phiDeg >= -180)
  629.          {
  630.             collision = false;
  631.             ball.mode = "cartEntrance";
  632.             score_mc.addScore("cart");
  633.             stopSound(T_musicIntro_snd);
  634.             playSound(T_musicFinalTheme_snd);
  635.          }
  636.       }
  637.       if(collision)
  638.       {
  639.          for(var i in cart.bumper)
  640.          {
  641.             doPointCollision(cart.bumper[i],ball);
  642.          }
  643.       }
  644.    }
  645. }
  646. function checkRightRamp()
  647. {
  648.    if(rightRampHitZone.hitTest(ball.mc))
  649.    {
  650.       if(rightRampHitZone.hitTest(ball.pos.x,ball.pos.y,true))
  651.       {
  652.          var velocity = new tVector(ball.vel.x,ball.vel.y);
  653.          if(velocity.phiDeg >= -111 && velocity.phiDeg <= 129)
  654.          {
  655.             ball.mode = "rightRamp";
  656.             stopSound(T_musicIntro_snd);
  657.             playSound(T_musicFinalTheme_snd);
  658.          }
  659.       }
  660.    }
  661. }
  662. showNormal = false;
  663. showWall = false;
  664. showBumper = false;
  665. showHitZone = false;
  666. debug = false;
  667. gotoAndStop(13);
  668.