home *** CD-ROM | disk | FTP | other *** search
/ 600 Games / 600games.iso / Nave / naval.swf / scripts / __Packages / CShot.as < prev    next >
Encoding:
Text File  |  2006-06-13  |  2.1 KB  |  73 lines

  1. class CShot extends MovieClip
  2. {
  3.    var pos;
  4.    var oldPos;
  5.    var dir;
  6.    var speed;
  7.    var myType;
  8.    static var LENGTH = 50;
  9.    function CShot()
  10.    {
  11.       super();
  12.    }
  13.    function init(pos_, dir_, speed_, myType_)
  14.    {
  15.       this.pos = pos_;
  16.       this.oldPos = this.pos.duplicate();
  17.       this.dir = dir_;
  18.       this.speed = speed_;
  19.       this.myType = myType_;
  20.    }
  21.    function process(dTime)
  22.    {
  23.       var _loc2_ = this.speed * dTime / 1000;
  24.       if(this.myType == 2)
  25.       {
  26.          this.oldPos.reinit(this.pos.x,this.pos.y,this.pos.z);
  27.       }
  28.       this.pos.x += this.dir.x * _loc2_;
  29.       this.pos.y += this.dir.y * _loc2_;
  30.       this.pos.z += this.dir.z * _loc2_;
  31.    }
  32.    function screenSynchronize(objTransform)
  33.    {
  34.       var _loc2_ = {x:0,y:0,k:0};
  35.       var _loc5_ = {x:0,y:0,k:0};
  36.       var _loc6_ = undefined;
  37.       var _loc4_ = undefined;
  38.       var _loc3_ = undefined;
  39.       objTransform.getScreenXY(this.pos.x,this.pos.y,this.pos.z,_loc2_);
  40.       objTransform.getScreenXY(this.pos.x - this.dir.x * CShot.LENGTH,this.pos.y - this.dir.y * CShot.LENGTH,this.pos.z - this.dir.z * CShot.LENGTH,_loc5_);
  41.       _loc4_ = _loc2_.x - _loc5_.x;
  42.       _loc3_ = _loc2_.y - _loc5_.y;
  43.       _loc6_ = Math.sqrt(_loc4_ * _loc4_ + _loc3_ * _loc3_);
  44.       this._x = _loc2_.x;
  45.       this._y = _loc2_.y;
  46.       if(this.myType == 1)
  47.       {
  48.          this._xscale = _loc6_ * 10 * 0.55 + 67.5;
  49.          this._yscale = _loc2_.k * 100 * 0.6 + 40;
  50.          this._rotation = Math.atan2(_loc3_,_loc4_) * 180 / 3.141592653589793;
  51.       }
  52.       else if(this.myType == 2)
  53.       {
  54.          this._xscale = this._yscale = _loc2_.k * 100;
  55.          this._rotation = Math.atan2(_loc3_,_loc4_) * 180 / 3.141592653589793 + 90;
  56.       }
  57.       else if(this.myType == 3)
  58.       {
  59.          this._xscale = _loc6_ * 10 * 0.55 + 67.5;
  60.          this._yscale = _loc2_.k * 110;
  61.          this._rotation = Math.atan2(_loc3_,_loc4_) * 180 / 3.141592653589793;
  62.       }
  63.       else if(this.myType == 4)
  64.       {
  65.          this._xscale = this._yscale = _loc2_.k * 100;
  66.       }
  67.    }
  68.    function disable()
  69.    {
  70.       this.removeMovieClip();
  71.    }
  72. }
  73.