home *** CD-ROM | disk | FTP | other *** search
/ 600 Games / 600games.iso / Classicos / smashout.swf / scripts / __Packages / Engine / PongWorld.as < prev   
Encoding:
Text File  |  2005-11-09  |  23.3 KB  |  735 lines

  1. class Engine.PongWorld extends GDK.World
  2. {
  3.    var __items;
  4.    var __waitedTime;
  5.    var __displayDelay;
  6.    var __brickGrid;
  7.    var __ball;
  8.    var __maxLevelSpeed;
  9.    var dispatchEvent;
  10.    var target;
  11.    var bounds;
  12.    var corners;
  13.    var __leftGoal;
  14.    var __rightGoal;
  15.    var __leftPaddle;
  16.    var __paddleLastTouched;
  17.    var __rightPaddle;
  18.    var __brickPointValue;
  19.    var humanSide;
  20.    var __levelItems;
  21.    var __levelItemRecurrence;
  22.    var __currentLevelItemRecurrence;
  23.    var __freezeItemTime;
  24.    var __itemTime;
  25.    var __defaultItemTime;
  26.    var __freezeBlinkTime;
  27.    var __itemBlinkTime;
  28.    var __defaultBlinkTime;
  29.    var __bonusPointValues;
  30.    var __goodItemValue;
  31.    var __goalValue;
  32.    var __computerPlayer;
  33.    var __getReady;
  34.    var engine;
  35.    var __humanPaddle;
  36.    var __computerPaddle;
  37.    var __humanGoal;
  38.    var __computerGoal;
  39.    var __humanPlayer;
  40.    var __ballInGoal;
  41.    var __currentLevelItems;
  42.    var __itemActiveTime;
  43.    var __currentActiveItemID;
  44.    var __currentActiveObject;
  45.    var useDefaultCamera = true;
  46.    var updateID = 0;
  47.    static var MAX_ELAPSED = 0.06666666666666667;
  48.    static var FRAME_TIME = Game.PongLevels.FRAME_TIME;
  49.    static var DELAY_INCREMENT = Engine.PongWorld.FRAME_TIME / 5;
  50.    var GRID_SIZE = 15;
  51.    var GRID_WIDTH = 300 / Engine.PongWorld.prototype.GRID_SIZE;
  52.    var GRID_HEIGHT = 210 / Engine.PongWorld.prototype.GRID_SIZE;
  53.    var GRID_X = 90;
  54.    var GRID_Y = 0;
  55.    var BALL_SIZE = 12;
  56.    static var SOLID = Game.PongLevels.S;
  57.    static var DESTRUCTIBLE = Game.PongLevels.D;
  58.    var LEFT_PLAYER = "left";
  59.    var RIGHT_PLAYER = "right";
  60.    var DEFAULT_GOAL_SIZE = 1;
  61.    var DEFAULT_PADDLE_SIZE = 0;
  62.    static var GET_READY_TIME = 2;
  63.    var x = 0;
  64.    var y = 0;
  65.    var __ballSpeed = Game.PongLevels.DEFAULT_SPEED;
  66.    var __ballAngle = Game.PongLevels.DEFAULT_ANGLE;
  67.    var __active = false;
  68.    var canUpdate = true;
  69.    static var __inited = false;
  70.    function PongWorld()
  71.    {
  72.       super();
  73.       if(!Engine.PongWorld.__inited)
  74.       {
  75.          this.init();
  76.       }
  77.       this.__items = new GDK.Collection();
  78.    }
  79.    function set active(flag)
  80.    {
  81.       this.__active = flag;
  82.    }
  83.    function get active()
  84.    {
  85.       return this.__active;
  86.    }
  87.    function update(elapsed)
  88.    {
  89.       if(!this.canUpdate)
  90.       {
  91.          return undefined;
  92.       }
  93.       this.canUpdate = false;
  94.       if(elapsed > Engine.PongWorld.MAX_ELAPSED)
  95.       {
  96.          elapsed = Engine.PongWorld.MAX_ELAPSED;
  97.          _root._quality = "LOW";
  98.       }
  99.       if(!this.active && this.__waitedTime != null)
  100.       {
  101.          this.__waitedTime += elapsed;
  102.          if(this.__waitedTime >= this.__displayDelay)
  103.          {
  104.             this.startLevel();
  105.          }
  106.       }
  107.       if(this.__brickGrid.destructibleCount <= 0)
  108.       {
  109.          var _loc4_ = this.__ball.defaultSpeed + elapsed * 5;
  110.          if(_loc4_ > this.__maxLevelSpeed)
  111.          {
  112.             _loc4_ = this.__maxLevelSpeed;
  113.          }
  114.          this.__ball.defaultSpeed = _loc4_;
  115.       }
  116.       if(this.active)
  117.       {
  118.          this.checkActiveItem(elapsed);
  119.          this.updatePlayers(elapsed);
  120.       }
  121.       this.sendUpdates(elapsed);
  122.       this.onUpdate(elapsed);
  123.       this.render(elapsed);
  124.       this.canUpdate = true;
  125.    }
  126.    function onUpdate(elapsed)
  127.    {
  128.       this.dispatchEvent({type:"onGameUpdate",elapsed:elapsed});
  129.    }
  130.    function onAddDisplay()
  131.    {
  132.       Engine.PongSFX.setTarget(this.target);
  133.       this.determineBounds();
  134.       this.createBoard();
  135.       this.dispatchEvent({type:"onWorldDisplay"});
  136.    }
  137.    function startLevel()
  138.    {
  139.       delete this.__waitedTime;
  140.       delete this.__displayDelay;
  141.       this.active = true;
  142.       this.getReady();
  143.    }
  144.    function checkBounds(o, elapsed)
  145.    {
  146.       if(o != this.__ball)
  147.       {
  148.          return this.checkItemBounds(o);
  149.       }
  150.       var _loc2_ = o;
  151.       var _loc3_ = undefined;
  152.       var _loc4_ = _loc2_.currentPos;
  153.       if(_loc4_.y < this.bounds.yMin)
  154.       {
  155.          _loc3_ = this.findIntersection4p(this.corners.tl,this.corners.tr,_loc2_.currentPos,_loc2_.lastPos);
  156.          if(_loc3_)
  157.          {
  158.             _loc2_.deflectH(_loc3_);
  159.             Engine.PongSFX.playBounce();
  160.             return true;
  161.          }
  162.       }
  163.       else if(this.bounds.yMax < _loc4_.y)
  164.       {
  165.          _loc3_ = this.findIntersection4p(this.corners.bl,this.corners.br,_loc2_.currentPos,_loc2_.lastPos);
  166.          if(_loc3_)
  167.          {
  168.             _loc2_.deflectH(_loc3_);
  169.             Engine.PongSFX.playBounce();
  170.             return true;
  171.          }
  172.       }
  173.       if(_loc4_.x < this.bounds.xMin)
  174.       {
  175.          if(this.checkGoal(this.__leftGoal,_loc2_))
  176.          {
  177.             this.scoreGoal(this.RIGHT_PLAYER,this.__leftGoal);
  178.             return true;
  179.          }
  180.          _loc3_ = this.findIntersection4p(this.corners.tl,this.corners.bl,_loc2_.currentPos,_loc2_.lastPos);
  181.          if(_loc3_)
  182.          {
  183.             _loc2_.deflectV(_loc3_);
  184.             Engine.PongSFX.playBounce();
  185.             return true;
  186.          }
  187.       }
  188.       else if(this.bounds.xMax < _loc4_.x)
  189.       {
  190.          if(this.checkGoal(this.__rightGoal,_loc2_))
  191.          {
  192.             this.scoreGoal(this.LEFT_PLAYER,this.__rightGoal);
  193.             return true;
  194.          }
  195.          _loc3_ = this.findIntersection4p(this.corners.tr,this.corners.br,_loc2_.currentPos,_loc2_.lastPos);
  196.          if(_loc3_)
  197.          {
  198.             _loc2_.deflectV(_loc3_);
  199.             Engine.PongSFX.playBounce();
  200.             return true;
  201.          }
  202.       }
  203.       return false;
  204.    }
  205.    function checkPaddles(o)
  206.    {
  207.       if(o == this.__ball)
  208.       {
  209.          if(o.x < this.bounds.hCenter)
  210.          {
  211.             if(this.__leftPaddle.checkCollision(o))
  212.             {
  213.                this.__paddleLastTouched = this.LEFT_PLAYER;
  214.                return true;
  215.             }
  216.             return false;
  217.          }
  218.          if(this.__rightPaddle.checkCollision(o))
  219.          {
  220.             this.__paddleLastTouched = this.RIGHT_PLAYER;
  221.             return true;
  222.          }
  223.          return false;
  224.       }
  225.       return this.checkItemPaddles(o);
  226.    }
  227.    function scorePointsForBrick(collBrick)
  228.    {
  229.       var _loc2_ = this.__paddleLastTouched;
  230.       var _loc3_ = this.__brickPointValue;
  231.       if(this.__brickGrid.destructibleCount <= 0 && collBrick.type == Engine.PongWorld.DESTRUCTIBLE)
  232.       {
  233.          var _loc5_ = new Vector(this.bounds.hCenter,this.bounds.vCenter);
  234.          this.releaseBonusPoints(Game.PongLevels.BONUS_POINTS,_loc5_,this.humanSide,Game.PongLevels.DEFAULT_CLEAR_ALL_VALUE);
  235.       }
  236.       this.scorePoints(_loc3_,_loc2_,"brick");
  237.       _loc5_ = new Vector(collBrick.x,collBrick.y,0);
  238.       this.triggerItem(_loc2_,_loc5_);
  239.    }
  240.    function checkBricks(ball)
  241.    {
  242.       var _loc2_ = this.__brickGrid.checkCollision(ball);
  243.       if(!_loc2_)
  244.       {
  245.          return false;
  246.       }
  247.       if(_loc2_.type == Engine.PongWorld.DESTRUCTIBLE || ball.blast)
  248.       {
  249.          this.scorePointsForBrick(_loc2_);
  250.       }
  251.       return true;
  252.    }
  253.    function createLevel(levelNum, levelData)
  254.    {
  255.       Engine.PongSFX.setMusic(levelNum);
  256.       this.active = false;
  257.       this.__levelItems = levelData.items;
  258.       this.__levelItemRecurrence = this.__currentLevelItemRecurrence = levelData.recurrence;
  259.       this.resetItems();
  260.       this.__ballSpeed = !levelData.speed ? Game.PongLevels.DEFAULT_SPEED : levelData.speed;
  261.       this.__ballSpeed += levelNum * Game.PongLevels.LEVEL_SPEED_INCREMENT;
  262.       if(this.__ballSpeed > Game.PongLevels.MAX_SPEED)
  263.       {
  264.          this.__ballSpeed = Game.PongLevels.MAX_SPEED;
  265.       }
  266.       this.__maxLevelSpeed = this.__ballSpeed + Game.PongLevels.MAX_SPEED_INCREASE;
  267.       if(this.__maxLevelSpeed > Game.PongLevels.MAX_SPEED)
  268.       {
  269.          this.__maxLevelSpeed = Game.PongLevels.MAX_SPEED;
  270.       }
  271.       this.__ballAngle = !levelData.angle ? Game.PongLevels.DEFAULT_ANGLE : levelData.angle;
  272.       this.__freezeItemTime = !levelData.freezeItemTime ? Game.PongLevels.FREEZE_ITEM_TIME : levelData.freezeItemTime;
  273.       this.__itemTime = this.__defaultItemTime = !levelData.itemTime ? Game.PongLevels.DEFAULT_ITEM_TIME : levelData.itemTime;
  274.       this.__freezeBlinkTime = !levelData.freezeBlinkTime ? Game.PongLevels.FREEZE_BLINK_TIME : levelData.freezeBlinkTime;
  275.       this.__itemBlinkTime = this.__defaultBlinkTime = !levelData.itemTime ? Game.PongLevels.DEFAULT_BLINK_TIME : levelData.blinkTime;
  276.       this.__brickPointValue = !levelData.brickPointValue ? Game.PongLevels.DEFAULT_BRICK_POINT_VALUE : levelData.brickPointValue;
  277.       this.__bonusPointValues = !levelData._bonusPointValues ? Game.PongLevels.DEFAULT_BONUS_POINTS_VALUES : levelData._bonusPointValues;
  278.       this.__goodItemValue = !levelData.goodItemValue ? Game.PongLevels.DEFAULT_GOOD_ITEM_VALUE : levelData.goodItemValue;
  279.       this.__goalValue = !levelData.goalValue ? Game.PongLevels.DEFAULT_GOAL_VALUE : levelData.goalValue;
  280.       var _loc12_ = !levelData.computerHandicap ? Game.PongLevels.DEFAULT_COMPUTER_HANDICAP : levelData.computerHandicap;
  281.       _loc12_ -= levelNum * Game.PongLevels.LEVEL_HANDICAP_DECREASE;
  282.       if(_loc12_ < Game.PongLevels.MIN_HANDICAP)
  283.       {
  284.          _loc12_ = Game.PongLevels.MIN_HANDICAP;
  285.       }
  286.       this.__computerPlayer.handicap = _loc12_;
  287.       this.resetPaddles();
  288.       this.resetBall();
  289.       var _loc9_ = levelData.grid;
  290.       var _loc11_ = _loc9_.length;
  291.       var _loc10_ = _loc9_[0].length;
  292.       this.__brickGrid = new Engine.PongGrid(_loc10_,_loc11_);
  293.       this.__brickGrid.world = this;
  294.       this.__brickGrid.gridSize = this.GRID_SIZE;
  295.       var _loc15_ = this.GRID_X + Math.floor((this.GRID_WIDTH - _loc10_) / 2) * this.GRID_SIZE;
  296.       var _loc14_ = this.GRID_Y + Math.floor((this.GRID_HEIGHT - _loc11_) / 2) * this.GRID_SIZE;
  297.       this.__brickGrid.moveTo(_loc15_,_loc14_);
  298.       var _loc2_ = undefined;
  299.       var _loc3_ = undefined;
  300.       var _loc5_ = undefined;
  301.       var _loc6_ = 0;
  302.       var _loc4_ = 0;
  303.       _loc3_ = 0;
  304.       while(_loc3_ < _loc11_)
  305.       {
  306.          _loc2_ = 0;
  307.          while(_loc2_ < _loc10_)
  308.          {
  309.             _loc5_ = _loc9_[_loc3_][_loc2_];
  310.             if(_loc5_)
  311.             {
  312.                this.__brickGrid.addItemAt(_loc2_,_loc3_,_loc5_,{gridIndex:_loc6_,displayDelay:_loc4_});
  313.                _loc4_ += Engine.PongWorld.DELAY_INCREMENT;
  314.                _loc6_ = _loc6_ + 1;
  315.             }
  316.             _loc2_ = _loc2_ + 1;
  317.          }
  318.          _loc3_ = _loc3_ + 1;
  319.       }
  320.       this.__displayDelay = _loc4_;
  321.       this.__waitedTime = 0;
  322.    }
  323.    function clearLevel()
  324.    {
  325.       if(!this.__brickGrid)
  326.       {
  327.          return undefined;
  328.       }
  329.       this.__brickGrid.removeAll();
  330.       delete this.__brickGrid;
  331.       this.clearBonusItems();
  332.    }
  333.    function getReady()
  334.    {
  335.       this.__ball.active = true;
  336.       this.resetPaddles();
  337.       this.resetBall();
  338.       this.__getReady.show();
  339.    }
  340.    function clearGetReady()
  341.    {
  342.       Engine.PongSFX.startMusic();
  343.       if(!this.__getReady.active)
  344.       {
  345.          return undefined;
  346.       }
  347.       this.__getReady.hide();
  348.       this.dispatchEvent({type:"onBallInPlay"});
  349.    }
  350.    function init()
  351.    {
  352.       mx.events.EventDispatcher.initialize(Engine.PongWorld.prototype);
  353.       Engine.PongWorld.__inited = true;
  354.    }
  355.    function scoreGoal(who, myGoal)
  356.    {
  357.       this.clearBonusItems();
  358.       this.__ball.active = false;
  359.       Engine.PongSFX.stopMusic();
  360.       Engine.PongSFX.playGoal();
  361.       if(who == this.humanSide)
  362.       {
  363.          Engine.PongSFX.playGoalCheer();
  364.       }
  365.       else
  366.       {
  367.          Engine.PongSFX.playGoalOhh();
  368.       }
  369.       this.scorePoints(this.__goalValue,who,"goal");
  370.       this.dispatchEvent({type:"onGoal",who:who});
  371.    }
  372.    function scorePoints(points, who, source)
  373.    {
  374.       this.dispatchEvent({type:"onPoints",who:who,points:points,source:source});
  375.    }
  376.    function determineBounds()
  377.    {
  378.       this.bounds = {xMin:this.x,yMin:this.y,xMax:this.engine.width,yMax:this.engine.height,hCenter:Math.floor((this.engine.width - this.x) / 2),vCenter:Math.floor((this.engine.height - this.y) / 2)};
  379.       this.corners = {tl:new Vector(this.bounds.xMin,this.bounds.yMin,0),tr:new Vector(this.bounds.xMax,this.bounds.yMin,0),br:new Vector(this.bounds.xMax,this.bounds.yMax,0),bl:new Vector(this.bounds.xMin,this.bounds.yMax,0)};
  380.    }
  381.    function createBoard()
  382.    {
  383.       this.__getReady = new Game.Objects.GetReady(Engine.PongWorld.GET_READY_TIME);
  384.       this.addObject(this.__getReady);
  385.       var _loc2_ = this.bounds.vCenter;
  386.       this.__rightPaddle = new Game.Objects.Paddle(this.RIGHT_PLAYER,this.DEFAULT_PADDLE_SIZE);
  387.       this.__rightPaddle.setBounds(this.bounds);
  388.       this.addObject(this.__rightPaddle);
  389.       this.__rightPaddle.addEventListener("onHoldBall",this);
  390.       this.__rightPaddle.addEventListener("onReleaseBall",this);
  391.       this.__leftPaddle = new Game.Objects.Paddle(this.LEFT_PLAYER,this.DEFAULT_PADDLE_SIZE);
  392.       this.__leftPaddle.setBounds(this.bounds);
  393.       this.addObject(this.__leftPaddle);
  394.       this.__leftPaddle.addEventListener("onHoldBall",this);
  395.       this.__leftPaddle.addEventListener("onReleaseBall",this);
  396.       var _loc4_ = true;
  397.       this.__ball = new Game.Objects.Ball(this.__ballSpeed,this.__ballAngle,_loc4_);
  398.       this.addObject(this.__ball);
  399.       this.__rightGoal = new Game.Objects.Goal(this.RIGHT_PLAYER,this.DEFAULT_GOAL_SIZE);
  400.       this.__rightGoal.moveTo(this.bounds.xMax,_loc2_,0);
  401.       this.addObject(this.__rightGoal);
  402.       this.__leftGoal = new Game.Objects.Goal(this.LEFT_PLAYER,this.DEFAULT_GOAL_SIZE);
  403.       this.__leftGoal.moveTo(this.bounds.xMin,_loc2_,0);
  404.       this.addObject(this.__leftGoal);
  405.       this.resetPaddles();
  406.       if(this.humanSide == this.LEFT_PLAYER)
  407.       {
  408.          this.__humanPaddle = this.__leftPaddle;
  409.          this.__computerPaddle = this.__rightPaddle;
  410.          this.__humanGoal = this.__leftGoal;
  411.          this.__computerGoal = this.__rightGoal;
  412.          var _loc3_ = this.RIGHT_PLAYER;
  413.       }
  414.       else
  415.       {
  416.          this.__humanPaddle = this.__rightPaddle;
  417.          this.__computerPaddle = this.__leftPaddle;
  418.          this.__humanGoal = this.__rightGoal;
  419.          this.__computerGoal = this.__leftGoal;
  420.          _loc3_ = this.LEFT_PLAYER;
  421.       }
  422.       this.__computerPlayer = new Game.Players.ComputerPlayer(this,this.__computerPaddle,this.__ball,this.__computerGoal,_loc3_);
  423.       this.__humanPlayer = new Game.Players.HumanPlayer(this,this.__humanPaddle,this.__ball,this.__humanGoal,this.humanSide);
  424.       this.resetBall();
  425.    }
  426.    function resetPaddles()
  427.    {
  428.       var _loc2_ = this.bounds.vCenter;
  429.       this.__rightPaddle.moveTo(this.bounds.xMax - 2 * this.GRID_SIZE,_loc2_,0);
  430.       this.__rightPaddle.width = this.DEFAULT_PADDLE_SIZE;
  431.       this.__leftPaddle.moveTo(2 * this.GRID_SIZE,_loc2_,0);
  432.       this.__leftPaddle.width = this.DEFAULT_PADDLE_SIZE;
  433.       this.__humanPlayer.deactivateItem();
  434.       this.__computerPlayer.deactivateItem();
  435.    }
  436.    function resetBall()
  437.    {
  438.       this.__ballInGoal = false;
  439.       this.__ball.defaultSpeed = this.__ballSpeed;
  440.       this.__ball.angle = this.__ballAngle;
  441.       this.__ball.blast = false;
  442.       this.__humanPaddle.holdBall(this.__ball);
  443.       this.__paddleLastTouched = this.humanSide;
  444.       this.deactivateCurrentItem();
  445.    }
  446.    function checkGoal(goal, ball)
  447.    {
  448.       if(ball.y < goal.top)
  449.       {
  450.          return false;
  451.       }
  452.       if(ball.y > goal.bottom)
  453.       {
  454.          return false;
  455.       }
  456.       return true;
  457.    }
  458.    function findIntersection4p(l0p0, l0p1, l1p0, l1p1)
  459.    {
  460.       var _loc3_ = ((l1p1.x - l1p0.x) * (l0p0.y - l1p0.y) - (l1p1.y - l1p0.y) * (l0p0.x - l1p0.x)) / ((l1p1.y - l1p0.y) * (l0p1.x - l0p0.x) - (l1p1.x - l1p0.x) * (l0p1.y - l0p0.y));
  461.       if(0 <= _loc3_ && _loc3_ <= 1)
  462.       {
  463.          return new Vector(l0p0.x + _loc3_ * (l0p1.x - l0p0.x),l0p0.y + _loc3_ * (l0p1.y - l0p0.y),0);
  464.       }
  465.       return null;
  466.    }
  467.    function updatePlayers(elapsed)
  468.    {
  469.       if(!this.__active)
  470.       {
  471.          return undefined;
  472.       }
  473.       this.__humanPlayer.update(elapsed);
  474.       this.__computerPlayer.update(elapsed);
  475.    }
  476.    function resetItems()
  477.    {
  478.       this.__currentLevelItems = [];
  479.       var _loc2_ = this.__levelItems.length;
  480.       while((_loc2_ = _loc2_ - 1) > -1)
  481.       {
  482.          this.__currentLevelItems[_loc2_] = this.__levelItems[_loc2_];
  483.       }
  484.    }
  485.    function pickItem()
  486.    {
  487.       if(this.__currentLevelItems.length < 1)
  488.       {
  489.          this.resetItems();
  490.       }
  491.       var _loc2_ = Math.floor(Math.random() * this.__currentLevelItems.length);
  492.       var _loc3_ = this.__currentLevelItems[_loc2_];
  493.       this.__currentLevelItems.splice(_loc2_,1);
  494.       return _loc3_;
  495.    }
  496.    function getMissileTarget(from)
  497.    {
  498.       if(from == this.LEFT_PLAYER)
  499.       {
  500.          return this.__rightGoal;
  501.       }
  502.       return this.__leftGoal;
  503.    }
  504.    function triggerItem(who, where)
  505.    {
  506.       if(this.__levelItems.length < 1)
  507.       {
  508.          return undefined;
  509.       }
  510.       this.__currentLevelItemRecurrence = this.__currentLevelItemRecurrence - 1;
  511.       var _loc3_ = Math.floor(Math.random() * this.__currentLevelItemRecurrence);
  512.       if(_loc3_ > 0)
  513.       {
  514.          return undefined;
  515.       }
  516.       var _loc2_ = this.pickItem();
  517.       this.__currentLevelItemRecurrence = this.__levelItemRecurrence;
  518.       this.releaseItem(_loc2_,where,this.__paddleLastTouched);
  519.    }
  520.    function releaseItem(itemID, where, who)
  521.    {
  522.       if(itemID == Game.PongLevels.BONUS_POINTS)
  523.       {
  524.          this.releaseBonusPoints.apply(this,arguments);
  525.          return undefined;
  526.       }
  527.       var _loc4_ = undefined;
  528.       if(who == this.LEFT_PLAYER)
  529.       {
  530.          _loc4_ = new Vector(-1,0,0);
  531.       }
  532.       else
  533.       {
  534.          _loc4_ = new Vector(1,0,0);
  535.       }
  536.       var _loc5_ = this.__ballSpeed / 4.5;
  537.       var _loc3_ = new Game.Objects.BonusItem(itemID,_loc4_,_loc5_);
  538.       _loc3_.moveTo(where.x,where.y,where.z);
  539.       this.addObject(_loc3_);
  540.       this.__items.addMember(_loc3_);
  541.       Engine.PongSFX.playReleaseItem();
  542.    }
  543.    function getItems()
  544.    {
  545.       return this.__items;
  546.    }
  547.    function releaseBonusPoints(itemID, where, who, value)
  548.    {
  549.       var _loc5_ = undefined;
  550.       if(who == this.humanSide)
  551.       {
  552.          _loc5_ = new Vector(0,-1,0);
  553.          Engine.PongSFX.playCatchGoodItem();
  554.       }
  555.       else
  556.       {
  557.          _loc5_ = new Vector(0,1,0);
  558.          Engine.PongSFX.playCatchBadItem();
  559.       }
  560.       if(value == null)
  561.       {
  562.          var _loc4_ = this.__bonusPointValues;
  563.          var _loc7_ = Math.floor(Math.random() * _loc4_.length);
  564.          value = _loc4_[_loc7_];
  565.       }
  566.       this.scorePoints(value,who,"bonuspoints");
  567.       if(who != this.humanSide)
  568.       {
  569.          value = - value;
  570.       }
  571.       var _loc3_ = new Game.Objects.BonusPointsItem(itemID,_loc5_,value);
  572.       _loc3_.moveTo(where.x,where.y,where.z);
  573.       this.addObject(_loc3_);
  574.       this.__items.addMember(_loc3_);
  575.    }
  576.    function onCatchItem(itemID, who)
  577.    {
  578.       if(this.isGoodItem(itemID))
  579.       {
  580.          this.scorePoints(this.__goodItemValue,who,"gooditem");
  581.          Engine.PongSFX.playCatchGoodItem();
  582.       }
  583.       else
  584.       {
  585.          Engine.PongSFX.playCatchBadItem();
  586.       }
  587.       if(itemID == Game.PongLevels.BALL_FAST || itemID == Game.PongLevels.BALL_SLOW)
  588.       {
  589.          this.__itemActiveTime = 0;
  590.          this.__itemTime = this.__defaultItemTime;
  591.          this.__currentActiveItemID = itemID;
  592.          this.__currentActiveObject = this.__ball;
  593.          this.__ball.activateItem(itemID);
  594.          return undefined;
  595.       }
  596.       var _loc5_ = undefined;
  597.       var _loc6_ = undefined;
  598.       var _loc7_ = undefined;
  599.       var _loc4_ = undefined;
  600.       if(who == this.humanSide && itemID != Game.PongLevels.FREEZE_OPPONENT || who != this.humanSide && itemID == Game.PongLevels.FREEZE_OPPONENT)
  601.       {
  602.          _loc5_ = this.__humanPaddle;
  603.          _loc6_ = this.__humanGoal;
  604.          _loc7_ = this.__humanPlayer;
  605.       }
  606.       else
  607.       {
  608.          _loc5_ = this.__computerPaddle;
  609.          _loc6_ = this.__computerGoal;
  610.          _loc7_ = this.__computerPlayer;
  611.       }
  612.       if(itemID == Game.PongLevels.FREEZE_OPPONENT)
  613.       {
  614.          itemID = Game.PongLevels.FREEZE_YOU;
  615.       }
  616.       if(itemID == Game.PongLevels.GOAL_WIDE || itemID == Game.PongLevels.GOAL_SMALL)
  617.       {
  618.          _loc4_ = _loc6_;
  619.       }
  620.       else
  621.       {
  622.          if(!(itemID == Game.PongLevels.PADDLE_WIDE || itemID == Game.PongLevels.PADDLE_SMALL || itemID == Game.PongLevels.FREEZE_YOU || itemID == Game.PongLevels.PADDLE_STICKY || itemID == Game.PongLevels.MISSILE))
  623.          {
  624.             return undefined;
  625.          }
  626.          _loc4_ = _loc5_;
  627.          if(itemID == Game.PongLevels.FREEZE_YOU)
  628.          {
  629.             Engine.PongSFX.playPaddleFreeze();
  630.          }
  631.          else
  632.          {
  633.             Engine.PongSFX.playPaddleChange();
  634.          }
  635.       }
  636.       if(itemID == Game.PongLevels.FREEZE_YOU)
  637.       {
  638.          var _loc8_ = this.__freezeItemTime;
  639.          var _loc9_ = this.__freezeBlinkTime;
  640.       }
  641.       else
  642.       {
  643.          _loc8_ = this.__defaultItemTime;
  644.          _loc9_ = this.__defaultBlinkTime;
  645.       }
  646.       _loc7_.activateItem(_loc4_,itemID,_loc8_,_loc9_);
  647.    }
  648.    function isGoodItem(itemID)
  649.    {
  650.       return Game.PongLevels.isGoodItem(itemID);
  651.    }
  652.    function onHoldBall(eventObj)
  653.    {
  654.       this.__ball.angle = this.__ballAngle;
  655.    }
  656.    function onReleaseBall(eventObj)
  657.    {
  658.       var _loc2_ = eventObj.target;
  659.       this.clearGetReady();
  660.       if(this.__ball.blast)
  661.       {
  662.          Engine.PongSFX.playMissileTakeOff();
  663.       }
  664.       else
  665.       {
  666.          Engine.PongSFX.playPuckRelease();
  667.       }
  668.    }
  669.    function deactivateCurrentItem()
  670.    {
  671.       if(this.__currentActiveObject == null)
  672.       {
  673.          return undefined;
  674.       }
  675.       this.__currentActiveObject.deactivateItem();
  676.       delete this.__currentActiveObject;
  677.       delete this.__itemActiveTime;
  678.       delete this.__itemTime;
  679.    }
  680.    function checkActiveItem(elapsed)
  681.    {
  682.       if(!this.__currentActiveObject)
  683.       {
  684.          return undefined;
  685.       }
  686.       this.__itemActiveTime += elapsed;
  687.       if(this.__itemActiveTime >= this.__itemTime)
  688.       {
  689.          this.deactivateCurrentItem();
  690.          return undefined;
  691.       }
  692.    }
  693.    function checkItemBounds(o)
  694.    {
  695.       if(o.motionLeft < this.bounds.xMin || this.bounds.xMax < o.motionRight)
  696.       {
  697.          return true;
  698.       }
  699.       if(o.motionTop < this.bounds.yMin || this.bounds.yMax < o.motionBottom)
  700.       {
  701.          return true;
  702.       }
  703.       return false;
  704.    }
  705.    function checkItemPaddles(o)
  706.    {
  707.       if(o.x < this.bounds.hCenter)
  708.       {
  709.          if(this.__leftPaddle.checkItemCollision(o))
  710.          {
  711.             this.onCatchItem(o.itemIndex,this.LEFT_PLAYER);
  712.             return true;
  713.          }
  714.          return false;
  715.       }
  716.       if(this.__rightPaddle.checkItemCollision(o))
  717.       {
  718.          this.onCatchItem(o.itemIndex,this.RIGHT_PLAYER);
  719.          return true;
  720.       }
  721.       return false;
  722.    }
  723.    function clearBonusItems()
  724.    {
  725.       this.deactivateCurrentItem();
  726.       while(this.__items.length > 0)
  727.       {
  728.          var _loc2_ = this.__items[0];
  729.          this.removeObject(_loc2_);
  730.       }
  731.       this.dispatchEvent({type:"onActivateItem",itemID:-1,who:this.LEFT_PLAYER});
  732.       this.dispatchEvent({type:"onActivateItem",itemID:-1,who:this.RIGHT_PLAYER});
  733.    }
  734. }
  735.