home *** CD-ROM | disk | FTP | other *** search
/ Champak 48 / cdrom_image.iso / Games / bobsleddin.swf / scripts / __Packages / GameBoostPad.as < prev    next >
Encoding:
Text File  |  2007-09-28  |  2.9 KB  |  59 lines

  1. class GameBoostPad extends GenericObject
  2. {
  3.    var right;
  4.    var nearLeft;
  5.    var nearRight;
  6.    var farLeft;
  7.    var farCenter;
  8.    var farRight;
  9.    var arrowTip;
  10.    var world;
  11.    var target;
  12.    var collisionGroup = BB.ELEMENT;
  13.    var collisionEnabled = true;
  14.    var collisionSound = "SpeedBoost";
  15.    var useRotation = false;
  16.    var radius = 0;
  17.    function GameBoostPad()
  18.    {
  19.       super();
  20.       this.setObjectSound(this.collisionSound,_root);
  21.    }
  22.    function onCollision(obj)
  23.    {
  24.       this.playObjectSound();
  25.       obj.currentSpeed = Math.min(obj.currentSpeed += 600,6000);
  26.       obj.velocity.length += 1600;
  27.    }
  28.    function onAddToWorld()
  29.    {
  30.       this.radius = 50;
  31.       var _loc3_ = this.right.x * this.sector.xScale * this.radius;
  32.       var _loc2_ = this.right.y * this.sector.yScale * this.radius;
  33.       this.nearLeft = new Vector(this.x - _loc3_,this.y - _loc2_,this.z);
  34.       this.nearRight = new Vector(this.x + _loc3_,this.y + _loc2_,this.z);
  35.       this.farLeft = new Vector(this.x - _loc3_ + this.sector.direction.x * this.radius,this.y - _loc2_ + this.sector.direction.y * this.radius,this.z + this.sector.direction.z * this.radius);
  36.       this.farCenter = new Vector(this.x + this.sector.direction.x * this.radius,this.y + this.sector.direction.y * this.radius,this.z + this.sector.direction.z * this.radius);
  37.       this.farRight = new Vector(this.x + _loc3_ + this.sector.direction.x * this.radius,this.y + _loc2_ + this.sector.direction.y * this.radius,this.z + this.sector.direction.z * this.radius);
  38.       this.arrowTip = new Vector(this.x + this.sector.direction.x * this.radius * 2,this.y + this.sector.direction.y * this.radius * 2,this.z + this.sector.direction.z * this.radius * 2);
  39.       this.radius = 100;
  40.    }
  41.    function setDisplay(offsetX, offsetY, offsetZ, depthRatio)
  42.    {
  43.       var _loc2_ = this.world.camera;
  44.       var _loc3_ = _loc2_.depthFocus / (this.farRight.z - _loc2_.z);
  45.       var _loc5_ = _loc2_.depthFocus / (this.arrowTip.z - _loc2_.z);
  46.       this.target.clear();
  47.       this.target.beginFill(16772608);
  48.       this.target.lineStyle(0,15654144);
  49.       this.target.moveTo((this.nearLeft.x - _loc2_.x) * depthRatio,(this.nearLeft.y - _loc2_.y) * depthRatio);
  50.       this.target.lineTo((this.farCenter.x - _loc2_.x) * _loc3_,(this.farCenter.y - _loc2_.y) * _loc3_);
  51.       this.target.lineTo((this.nearRight.x - _loc2_.x) * depthRatio,(this.nearRight.y - _loc2_.y) * depthRatio);
  52.       this.target.lineTo((this.farRight.x - _loc2_.x) * _loc3_,(this.farRight.y - _loc2_.y) * _loc3_);
  53.       this.target.lineTo((this.arrowTip.x - _loc2_.x) * _loc5_,(this.arrowTip.y - _loc2_.y) * _loc5_);
  54.       this.target.lineTo((this.farLeft.x - _loc2_.x) * _loc3_,(this.farLeft.y - _loc2_.y) * _loc3_);
  55.       this.target.lineTo((this.nearLeft.x - _loc2_.x) * depthRatio,(this.nearLeft.y - _loc2_.y) * depthRatio);
  56.       this.target.endFill();
  57.    }
  58. }
  59.