home *** CD-ROM | disk | FTP | other *** search
- class Engine.PongWorld extends GDK.World
- {
- var __items;
- var __waitedTime;
- var __displayDelay;
- var __brickGrid;
- var __ball;
- var __maxLevelSpeed;
- var dispatchEvent;
- var target;
- var bounds;
- var corners;
- var __leftGoal;
- var __rightGoal;
- var __leftPaddle;
- var __paddleLastTouched;
- var __rightPaddle;
- var __brickPointValue;
- var humanSide;
- var __levelItems;
- var __levelItemRecurrence;
- var __currentLevelItemRecurrence;
- var __freezeItemTime;
- var __itemTime;
- var __defaultItemTime;
- var __freezeBlinkTime;
- var __itemBlinkTime;
- var __defaultBlinkTime;
- var __bonusPointValues;
- var __goodItemValue;
- var __goalValue;
- var __computerPlayer;
- var __getReady;
- var engine;
- var __humanPaddle;
- var __computerPaddle;
- var __humanGoal;
- var __computerGoal;
- var __humanPlayer;
- var __ballInGoal;
- var __currentLevelItems;
- var __itemActiveTime;
- var __currentActiveItemID;
- var __currentActiveObject;
- var useDefaultCamera = true;
- var updateID = 0;
- static var MAX_ELAPSED = 0.06666666666666667;
- static var FRAME_TIME = Game.PongLevels.FRAME_TIME;
- static var DELAY_INCREMENT = Engine.PongWorld.FRAME_TIME / 5;
- var GRID_SIZE = 15;
- var GRID_WIDTH = 300 / Engine.PongWorld.prototype.GRID_SIZE;
- var GRID_HEIGHT = 210 / Engine.PongWorld.prototype.GRID_SIZE;
- var GRID_X = 90;
- var GRID_Y = 0;
- var BALL_SIZE = 12;
- static var SOLID = Game.PongLevels.S;
- static var DESTRUCTIBLE = Game.PongLevels.D;
- var LEFT_PLAYER = "left";
- var RIGHT_PLAYER = "right";
- var DEFAULT_GOAL_SIZE = 1;
- var DEFAULT_PADDLE_SIZE = 0;
- static var GET_READY_TIME = 2;
- var x = 0;
- var y = 0;
- var __ballSpeed = Game.PongLevels.DEFAULT_SPEED;
- var __ballAngle = Game.PongLevels.DEFAULT_ANGLE;
- var __active = false;
- var canUpdate = true;
- static var __inited = false;
- function PongWorld()
- {
- super();
- if(!Engine.PongWorld.__inited)
- {
- this.init();
- }
- this.__items = new GDK.Collection();
- }
- function set active(flag)
- {
- this.__active = flag;
- }
- function get active()
- {
- return this.__active;
- }
- function update(elapsed)
- {
- if(!this.canUpdate)
- {
- return undefined;
- }
- this.canUpdate = false;
- if(elapsed > Engine.PongWorld.MAX_ELAPSED)
- {
- elapsed = Engine.PongWorld.MAX_ELAPSED;
- _root._quality = "LOW";
- }
- if(!this.active && this.__waitedTime != null)
- {
- this.__waitedTime += elapsed;
- if(this.__waitedTime >= this.__displayDelay)
- {
- this.startLevel();
- }
- }
- if(this.__brickGrid.destructibleCount <= 0)
- {
- var _loc4_ = this.__ball.defaultSpeed + elapsed * 5;
- if(_loc4_ > this.__maxLevelSpeed)
- {
- _loc4_ = this.__maxLevelSpeed;
- }
- this.__ball.defaultSpeed = _loc4_;
- }
- if(this.active)
- {
- this.checkActiveItem(elapsed);
- this.updatePlayers(elapsed);
- }
- this.sendUpdates(elapsed);
- this.onUpdate(elapsed);
- this.render(elapsed);
- this.canUpdate = true;
- }
- function onUpdate(elapsed)
- {
- this.dispatchEvent({type:"onGameUpdate",elapsed:elapsed});
- }
- function onAddDisplay()
- {
- Engine.PongSFX.setTarget(this.target);
- this.determineBounds();
- this.createBoard();
- this.dispatchEvent({type:"onWorldDisplay"});
- }
- function startLevel()
- {
- delete this.__waitedTime;
- delete this.__displayDelay;
- this.active = true;
- this.getReady();
- }
- function checkBounds(o, elapsed)
- {
- if(o != this.__ball)
- {
- return this.checkItemBounds(o);
- }
- var _loc2_ = o;
- var _loc3_ = undefined;
- var _loc4_ = _loc2_.currentPos;
- if(_loc4_.y < this.bounds.yMin)
- {
- _loc3_ = this.findIntersection4p(this.corners.tl,this.corners.tr,_loc2_.currentPos,_loc2_.lastPos);
- if(_loc3_)
- {
- _loc2_.deflectH(_loc3_);
- Engine.PongSFX.playBounce();
- return true;
- }
- }
- else if(this.bounds.yMax < _loc4_.y)
- {
- _loc3_ = this.findIntersection4p(this.corners.bl,this.corners.br,_loc2_.currentPos,_loc2_.lastPos);
- if(_loc3_)
- {
- _loc2_.deflectH(_loc3_);
- Engine.PongSFX.playBounce();
- return true;
- }
- }
- if(_loc4_.x < this.bounds.xMin)
- {
- if(this.checkGoal(this.__leftGoal,_loc2_))
- {
- this.scoreGoal(this.RIGHT_PLAYER,this.__leftGoal);
- return true;
- }
- _loc3_ = this.findIntersection4p(this.corners.tl,this.corners.bl,_loc2_.currentPos,_loc2_.lastPos);
- if(_loc3_)
- {
- _loc2_.deflectV(_loc3_);
- Engine.PongSFX.playBounce();
- return true;
- }
- }
- else if(this.bounds.xMax < _loc4_.x)
- {
- if(this.checkGoal(this.__rightGoal,_loc2_))
- {
- this.scoreGoal(this.LEFT_PLAYER,this.__rightGoal);
- return true;
- }
- _loc3_ = this.findIntersection4p(this.corners.tr,this.corners.br,_loc2_.currentPos,_loc2_.lastPos);
- if(_loc3_)
- {
- _loc2_.deflectV(_loc3_);
- Engine.PongSFX.playBounce();
- return true;
- }
- }
- return false;
- }
- function checkPaddles(o)
- {
- if(o == this.__ball)
- {
- if(o.x < this.bounds.hCenter)
- {
- if(this.__leftPaddle.checkCollision(o))
- {
- this.__paddleLastTouched = this.LEFT_PLAYER;
- return true;
- }
- return false;
- }
- if(this.__rightPaddle.checkCollision(o))
- {
- this.__paddleLastTouched = this.RIGHT_PLAYER;
- return true;
- }
- return false;
- }
- return this.checkItemPaddles(o);
- }
- function scorePointsForBrick(collBrick)
- {
- var _loc2_ = this.__paddleLastTouched;
- var _loc3_ = this.__brickPointValue;
- if(this.__brickGrid.destructibleCount <= 0 && collBrick.type == Engine.PongWorld.DESTRUCTIBLE)
- {
- var _loc5_ = new Vector(this.bounds.hCenter,this.bounds.vCenter);
- this.releaseBonusPoints(Game.PongLevels.BONUS_POINTS,_loc5_,this.humanSide,Game.PongLevels.DEFAULT_CLEAR_ALL_VALUE);
- }
- this.scorePoints(_loc3_,_loc2_,"brick");
- _loc5_ = new Vector(collBrick.x,collBrick.y,0);
- this.triggerItem(_loc2_,_loc5_);
- }
- function checkBricks(ball)
- {
- var _loc2_ = this.__brickGrid.checkCollision(ball);
- if(!_loc2_)
- {
- return false;
- }
- if(_loc2_.type == Engine.PongWorld.DESTRUCTIBLE || ball.blast)
- {
- this.scorePointsForBrick(_loc2_);
- }
- return true;
- }
- function createLevel(levelNum, levelData)
- {
- Engine.PongSFX.setMusic(levelNum);
- this.active = false;
- this.__levelItems = levelData.items;
- this.__levelItemRecurrence = this.__currentLevelItemRecurrence = levelData.recurrence;
- this.resetItems();
- this.__ballSpeed = !levelData.speed ? Game.PongLevels.DEFAULT_SPEED : levelData.speed;
- this.__ballSpeed += levelNum * Game.PongLevels.LEVEL_SPEED_INCREMENT;
- if(this.__ballSpeed > Game.PongLevels.MAX_SPEED)
- {
- this.__ballSpeed = Game.PongLevels.MAX_SPEED;
- }
- this.__maxLevelSpeed = this.__ballSpeed + Game.PongLevels.MAX_SPEED_INCREASE;
- if(this.__maxLevelSpeed > Game.PongLevels.MAX_SPEED)
- {
- this.__maxLevelSpeed = Game.PongLevels.MAX_SPEED;
- }
- this.__ballAngle = !levelData.angle ? Game.PongLevels.DEFAULT_ANGLE : levelData.angle;
- this.__freezeItemTime = !levelData.freezeItemTime ? Game.PongLevels.FREEZE_ITEM_TIME : levelData.freezeItemTime;
- this.__itemTime = this.__defaultItemTime = !levelData.itemTime ? Game.PongLevels.DEFAULT_ITEM_TIME : levelData.itemTime;
- this.__freezeBlinkTime = !levelData.freezeBlinkTime ? Game.PongLevels.FREEZE_BLINK_TIME : levelData.freezeBlinkTime;
- this.__itemBlinkTime = this.__defaultBlinkTime = !levelData.itemTime ? Game.PongLevels.DEFAULT_BLINK_TIME : levelData.blinkTime;
- this.__brickPointValue = !levelData.brickPointValue ? Game.PongLevels.DEFAULT_BRICK_POINT_VALUE : levelData.brickPointValue;
- this.__bonusPointValues = !levelData._bonusPointValues ? Game.PongLevels.DEFAULT_BONUS_POINTS_VALUES : levelData._bonusPointValues;
- this.__goodItemValue = !levelData.goodItemValue ? Game.PongLevels.DEFAULT_GOOD_ITEM_VALUE : levelData.goodItemValue;
- this.__goalValue = !levelData.goalValue ? Game.PongLevels.DEFAULT_GOAL_VALUE : levelData.goalValue;
- var _loc12_ = !levelData.computerHandicap ? Game.PongLevels.DEFAULT_COMPUTER_HANDICAP : levelData.computerHandicap;
- _loc12_ -= levelNum * Game.PongLevels.LEVEL_HANDICAP_DECREASE;
- if(_loc12_ < Game.PongLevels.MIN_HANDICAP)
- {
- _loc12_ = Game.PongLevels.MIN_HANDICAP;
- }
- this.__computerPlayer.handicap = _loc12_;
- this.resetPaddles();
- this.resetBall();
- var _loc9_ = levelData.grid;
- var _loc11_ = _loc9_.length;
- var _loc10_ = _loc9_[0].length;
- this.__brickGrid = new Engine.PongGrid(_loc10_,_loc11_);
- this.__brickGrid.world = this;
- this.__brickGrid.gridSize = this.GRID_SIZE;
- var _loc15_ = this.GRID_X + Math.floor((this.GRID_WIDTH - _loc10_) / 2) * this.GRID_SIZE;
- var _loc14_ = this.GRID_Y + Math.floor((this.GRID_HEIGHT - _loc11_) / 2) * this.GRID_SIZE;
- this.__brickGrid.moveTo(_loc15_,_loc14_);
- var _loc2_ = undefined;
- var _loc3_ = undefined;
- var _loc5_ = undefined;
- var _loc6_ = 0;
- var _loc4_ = 0;
- _loc3_ = 0;
- while(_loc3_ < _loc11_)
- {
- _loc2_ = 0;
- while(_loc2_ < _loc10_)
- {
- _loc5_ = _loc9_[_loc3_][_loc2_];
- if(_loc5_)
- {
- this.__brickGrid.addItemAt(_loc2_,_loc3_,_loc5_,{gridIndex:_loc6_,displayDelay:_loc4_});
- _loc4_ += Engine.PongWorld.DELAY_INCREMENT;
- _loc6_ = _loc6_ + 1;
- }
- _loc2_ = _loc2_ + 1;
- }
- _loc3_ = _loc3_ + 1;
- }
- this.__displayDelay = _loc4_;
- this.__waitedTime = 0;
- }
- function clearLevel()
- {
- if(!this.__brickGrid)
- {
- return undefined;
- }
- this.__brickGrid.removeAll();
- delete this.__brickGrid;
- this.clearBonusItems();
- }
- function getReady()
- {
- this.__ball.active = true;
- this.resetPaddles();
- this.resetBall();
- this.__getReady.show();
- }
- function clearGetReady()
- {
- Engine.PongSFX.startMusic();
- if(!this.__getReady.active)
- {
- return undefined;
- }
- this.__getReady.hide();
- this.dispatchEvent({type:"onBallInPlay"});
- }
- function init()
- {
- mx.events.EventDispatcher.initialize(Engine.PongWorld.prototype);
- Engine.PongWorld.__inited = true;
- }
- function scoreGoal(who, myGoal)
- {
- this.clearBonusItems();
- this.__ball.active = false;
- Engine.PongSFX.stopMusic();
- Engine.PongSFX.playGoal();
- if(who == this.humanSide)
- {
- Engine.PongSFX.playGoalCheer();
- }
- else
- {
- Engine.PongSFX.playGoalOhh();
- }
- this.scorePoints(this.__goalValue,who,"goal");
- this.dispatchEvent({type:"onGoal",who:who});
- }
- function scorePoints(points, who, source)
- {
- this.dispatchEvent({type:"onPoints",who:who,points:points,source:source});
- }
- function determineBounds()
- {
- 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)};
- 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)};
- }
- function createBoard()
- {
- this.__getReady = new Game.Objects.GetReady(Engine.PongWorld.GET_READY_TIME);
- this.addObject(this.__getReady);
- var _loc2_ = this.bounds.vCenter;
- this.__rightPaddle = new Game.Objects.Paddle(this.RIGHT_PLAYER,this.DEFAULT_PADDLE_SIZE);
- this.__rightPaddle.setBounds(this.bounds);
- this.addObject(this.__rightPaddle);
- this.__rightPaddle.addEventListener("onHoldBall",this);
- this.__rightPaddle.addEventListener("onReleaseBall",this);
- this.__leftPaddle = new Game.Objects.Paddle(this.LEFT_PLAYER,this.DEFAULT_PADDLE_SIZE);
- this.__leftPaddle.setBounds(this.bounds);
- this.addObject(this.__leftPaddle);
- this.__leftPaddle.addEventListener("onHoldBall",this);
- this.__leftPaddle.addEventListener("onReleaseBall",this);
- var _loc4_ = true;
- this.__ball = new Game.Objects.Ball(this.__ballSpeed,this.__ballAngle,_loc4_);
- this.addObject(this.__ball);
- this.__rightGoal = new Game.Objects.Goal(this.RIGHT_PLAYER,this.DEFAULT_GOAL_SIZE);
- this.__rightGoal.moveTo(this.bounds.xMax,_loc2_,0);
- this.addObject(this.__rightGoal);
- this.__leftGoal = new Game.Objects.Goal(this.LEFT_PLAYER,this.DEFAULT_GOAL_SIZE);
- this.__leftGoal.moveTo(this.bounds.xMin,_loc2_,0);
- this.addObject(this.__leftGoal);
- this.resetPaddles();
- if(this.humanSide == this.LEFT_PLAYER)
- {
- this.__humanPaddle = this.__leftPaddle;
- this.__computerPaddle = this.__rightPaddle;
- this.__humanGoal = this.__leftGoal;
- this.__computerGoal = this.__rightGoal;
- var _loc3_ = this.RIGHT_PLAYER;
- }
- else
- {
- this.__humanPaddle = this.__rightPaddle;
- this.__computerPaddle = this.__leftPaddle;
- this.__humanGoal = this.__rightGoal;
- this.__computerGoal = this.__leftGoal;
- _loc3_ = this.LEFT_PLAYER;
- }
- this.__computerPlayer = new Game.Players.ComputerPlayer(this,this.__computerPaddle,this.__ball,this.__computerGoal,_loc3_);
- this.__humanPlayer = new Game.Players.HumanPlayer(this,this.__humanPaddle,this.__ball,this.__humanGoal,this.humanSide);
- this.resetBall();
- }
- function resetPaddles()
- {
- var _loc2_ = this.bounds.vCenter;
- this.__rightPaddle.moveTo(this.bounds.xMax - 2 * this.GRID_SIZE,_loc2_,0);
- this.__rightPaddle.width = this.DEFAULT_PADDLE_SIZE;
- this.__leftPaddle.moveTo(2 * this.GRID_SIZE,_loc2_,0);
- this.__leftPaddle.width = this.DEFAULT_PADDLE_SIZE;
- this.__humanPlayer.deactivateItem();
- this.__computerPlayer.deactivateItem();
- }
- function resetBall()
- {
- this.__ballInGoal = false;
- this.__ball.defaultSpeed = this.__ballSpeed;
- this.__ball.angle = this.__ballAngle;
- this.__ball.blast = false;
- this.__humanPaddle.holdBall(this.__ball);
- this.__paddleLastTouched = this.humanSide;
- this.deactivateCurrentItem();
- }
- function checkGoal(goal, ball)
- {
- if(ball.y < goal.top)
- {
- return false;
- }
- if(ball.y > goal.bottom)
- {
- return false;
- }
- return true;
- }
- function findIntersection4p(l0p0, l0p1, l1p0, l1p1)
- {
- 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));
- if(0 <= _loc3_ && _loc3_ <= 1)
- {
- return new Vector(l0p0.x + _loc3_ * (l0p1.x - l0p0.x),l0p0.y + _loc3_ * (l0p1.y - l0p0.y),0);
- }
- return null;
- }
- function updatePlayers(elapsed)
- {
- if(!this.__active)
- {
- return undefined;
- }
- this.__humanPlayer.update(elapsed);
- this.__computerPlayer.update(elapsed);
- }
- function resetItems()
- {
- this.__currentLevelItems = [];
- var _loc2_ = this.__levelItems.length;
- while((_loc2_ = _loc2_ - 1) > -1)
- {
- this.__currentLevelItems[_loc2_] = this.__levelItems[_loc2_];
- }
- }
- function pickItem()
- {
- if(this.__currentLevelItems.length < 1)
- {
- this.resetItems();
- }
- var _loc2_ = Math.floor(Math.random() * this.__currentLevelItems.length);
- var _loc3_ = this.__currentLevelItems[_loc2_];
- this.__currentLevelItems.splice(_loc2_,1);
- return _loc3_;
- }
- function getMissileTarget(from)
- {
- if(from == this.LEFT_PLAYER)
- {
- return this.__rightGoal;
- }
- return this.__leftGoal;
- }
- function triggerItem(who, where)
- {
- if(this.__levelItems.length < 1)
- {
- return undefined;
- }
- this.__currentLevelItemRecurrence = this.__currentLevelItemRecurrence - 1;
- var _loc3_ = Math.floor(Math.random() * this.__currentLevelItemRecurrence);
- if(_loc3_ > 0)
- {
- return undefined;
- }
- var _loc2_ = this.pickItem();
- this.__currentLevelItemRecurrence = this.__levelItemRecurrence;
- this.releaseItem(_loc2_,where,this.__paddleLastTouched);
- }
- function releaseItem(itemID, where, who)
- {
- if(itemID == Game.PongLevels.BONUS_POINTS)
- {
- this.releaseBonusPoints.apply(this,arguments);
- return undefined;
- }
- var _loc4_ = undefined;
- if(who == this.LEFT_PLAYER)
- {
- _loc4_ = new Vector(-1,0,0);
- }
- else
- {
- _loc4_ = new Vector(1,0,0);
- }
- var _loc5_ = this.__ballSpeed / 4.5;
- var _loc3_ = new Game.Objects.BonusItem(itemID,_loc4_,_loc5_);
- _loc3_.moveTo(where.x,where.y,where.z);
- this.addObject(_loc3_);
- this.__items.addMember(_loc3_);
- Engine.PongSFX.playReleaseItem();
- }
- function getItems()
- {
- return this.__items;
- }
- function releaseBonusPoints(itemID, where, who, value)
- {
- var _loc5_ = undefined;
- if(who == this.humanSide)
- {
- _loc5_ = new Vector(0,-1,0);
- Engine.PongSFX.playCatchGoodItem();
- }
- else
- {
- _loc5_ = new Vector(0,1,0);
- Engine.PongSFX.playCatchBadItem();
- }
- if(value == null)
- {
- var _loc4_ = this.__bonusPointValues;
- var _loc7_ = Math.floor(Math.random() * _loc4_.length);
- value = _loc4_[_loc7_];
- }
- this.scorePoints(value,who,"bonuspoints");
- if(who != this.humanSide)
- {
- value = - value;
- }
- var _loc3_ = new Game.Objects.BonusPointsItem(itemID,_loc5_,value);
- _loc3_.moveTo(where.x,where.y,where.z);
- this.addObject(_loc3_);
- this.__items.addMember(_loc3_);
- }
- function onCatchItem(itemID, who)
- {
- if(this.isGoodItem(itemID))
- {
- this.scorePoints(this.__goodItemValue,who,"gooditem");
- Engine.PongSFX.playCatchGoodItem();
- }
- else
- {
- Engine.PongSFX.playCatchBadItem();
- }
- if(itemID == Game.PongLevels.BALL_FAST || itemID == Game.PongLevels.BALL_SLOW)
- {
- this.__itemActiveTime = 0;
- this.__itemTime = this.__defaultItemTime;
- this.__currentActiveItemID = itemID;
- this.__currentActiveObject = this.__ball;
- this.__ball.activateItem(itemID);
- return undefined;
- }
- var _loc5_ = undefined;
- var _loc6_ = undefined;
- var _loc7_ = undefined;
- var _loc4_ = undefined;
- if(who == this.humanSide && itemID != Game.PongLevels.FREEZE_OPPONENT || who != this.humanSide && itemID == Game.PongLevels.FREEZE_OPPONENT)
- {
- _loc5_ = this.__humanPaddle;
- _loc6_ = this.__humanGoal;
- _loc7_ = this.__humanPlayer;
- }
- else
- {
- _loc5_ = this.__computerPaddle;
- _loc6_ = this.__computerGoal;
- _loc7_ = this.__computerPlayer;
- }
- if(itemID == Game.PongLevels.FREEZE_OPPONENT)
- {
- itemID = Game.PongLevels.FREEZE_YOU;
- }
- if(itemID == Game.PongLevels.GOAL_WIDE || itemID == Game.PongLevels.GOAL_SMALL)
- {
- _loc4_ = _loc6_;
- }
- else
- {
- 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))
- {
- return undefined;
- }
- _loc4_ = _loc5_;
- if(itemID == Game.PongLevels.FREEZE_YOU)
- {
- Engine.PongSFX.playPaddleFreeze();
- }
- else
- {
- Engine.PongSFX.playPaddleChange();
- }
- }
- if(itemID == Game.PongLevels.FREEZE_YOU)
- {
- var _loc8_ = this.__freezeItemTime;
- var _loc9_ = this.__freezeBlinkTime;
- }
- else
- {
- _loc8_ = this.__defaultItemTime;
- _loc9_ = this.__defaultBlinkTime;
- }
- _loc7_.activateItem(_loc4_,itemID,_loc8_,_loc9_);
- }
- function isGoodItem(itemID)
- {
- return Game.PongLevels.isGoodItem(itemID);
- }
- function onHoldBall(eventObj)
- {
- this.__ball.angle = this.__ballAngle;
- }
- function onReleaseBall(eventObj)
- {
- var _loc2_ = eventObj.target;
- this.clearGetReady();
- if(this.__ball.blast)
- {
- Engine.PongSFX.playMissileTakeOff();
- }
- else
- {
- Engine.PongSFX.playPuckRelease();
- }
- }
- function deactivateCurrentItem()
- {
- if(this.__currentActiveObject == null)
- {
- return undefined;
- }
- this.__currentActiveObject.deactivateItem();
- delete this.__currentActiveObject;
- delete this.__itemActiveTime;
- delete this.__itemTime;
- }
- function checkActiveItem(elapsed)
- {
- if(!this.__currentActiveObject)
- {
- return undefined;
- }
- this.__itemActiveTime += elapsed;
- if(this.__itemActiveTime >= this.__itemTime)
- {
- this.deactivateCurrentItem();
- return undefined;
- }
- }
- function checkItemBounds(o)
- {
- if(o.motionLeft < this.bounds.xMin || this.bounds.xMax < o.motionRight)
- {
- return true;
- }
- if(o.motionTop < this.bounds.yMin || this.bounds.yMax < o.motionBottom)
- {
- return true;
- }
- return false;
- }
- function checkItemPaddles(o)
- {
- if(o.x < this.bounds.hCenter)
- {
- if(this.__leftPaddle.checkItemCollision(o))
- {
- this.onCatchItem(o.itemIndex,this.LEFT_PLAYER);
- return true;
- }
- return false;
- }
- if(this.__rightPaddle.checkItemCollision(o))
- {
- this.onCatchItem(o.itemIndex,this.RIGHT_PLAYER);
- return true;
- }
- return false;
- }
- function clearBonusItems()
- {
- this.deactivateCurrentItem();
- while(this.__items.length > 0)
- {
- var _loc2_ = this.__items[0];
- this.removeObject(_loc2_);
- }
- this.dispatchEvent({type:"onActivateItem",itemID:-1,who:this.LEFT_PLAYER});
- this.dispatchEvent({type:"onActivateItem",itemID:-1,who:this.RIGHT_PLAYER});
- }
- }
-