home *** CD-ROM | disk | FTP | other *** search
/ 600 Games / 600games.iso / Acao / midnightstrike1.swf / scripts / __Packages / com / neodelight / v2D / PointSprite.as < prev    next >
Encoding:
Text File  |  2007-04-02  |  4.2 KB  |  119 lines

  1. class com.neodelight.v2D.PointSprite extends com.neodelight.v2D.Sprite
  2. {
  3.    var size;
  4.    var boundingRect;
  5.    var collisionStyle;
  6.    var spareOwner;
  7.    var owner;
  8.    var colGhosts;
  9.    var flex;
  10.    var v;
  11.    var pos;
  12.    var tpos;
  13.    var colNewVx;
  14.    var colNewVy;
  15.    var colPos;
  16.    var colPartner;
  17.    var colType;
  18.    var colNewPartnerVx;
  19.    var colNewPartnerVy;
  20.    function PointSprite(mc, f, weight, flags, collisionPartners)
  21.    {
  22.       super(mc,f,weight,flags,collisionPartners,undefined);
  23.       this.size.x = 0;
  24.       this.size.y = 0;
  25.       this.size.z = 0;
  26.       this.boundingRect.p1.x = this.boundingRect.p0.x;
  27.       this.boundingRect.p1.y = this.boundingRect.p1.y;
  28.       this.collisionStyle = 5;
  29.       this.updateTotalBoundingRect();
  30.    }
  31.    function move()
  32.    {
  33.       super.move();
  34.    }
  35.    function collisionCheck2(partner)
  36.    {
  37.       if(this.spareOwner && this.owner == partner)
  38.       {
  39.          return undefined;
  40.       }
  41.       if(this.boundingRect.p0.x <= partner.pos.x + partner.size.x && this.boundingRect.p1.x >= partner.pos.x && this.boundingRect.p0.y <= partner.pos.y + partner.size.y && this.boundingRect.p1.y >= partner.pos.y)
  42.       {
  43.          this.colGhosts.push({pos:0,obj:partner});
  44.          if(this.flex)
  45.          {
  46.             if(this.v.x > 0)
  47.             {
  48.                if(Math.round(this.pos.x * 1000) / 1000 < Math.round(partner.pos.x * 1000) / 1000 && Math.round(this.tpos.x * 1000) / 1000 >= Math.round(partner.pos.x * 1000) / 1000)
  49.                {
  50.                   this.colNewVx = Math.abs(this.v.x) * this.flex * -1;
  51.                }
  52.             }
  53.             else if(this.v.x < 0)
  54.             {
  55.                if(Math.round(this.pos.x * 1000) / 1000 > Math.round((partner.pos.x + partner.size.x) * 1000) / 1000 && Math.round(this.tpos.x * 1000) / 1000 <= Math.round((partner.pos.x + partner.size.x) * 1000) / 1000)
  56.                {
  57.                   this.colNewVx = Math.abs(this.v.x) * this.flex;
  58.                }
  59.             }
  60.             if(this.v.y > 0)
  61.             {
  62.                if(Math.round(this.pos.y * 1000) / 1000 < Math.round(partner.pos.y * 1000) / 1000 && Math.round(this.tpos.y * 1000) / 1000 >= Math.round(partner.pos.y * 1000) / 1000)
  63.                {
  64.                   this.colNewVy = Math.abs(this.v.y) * this.flex * -1;
  65.                }
  66.             }
  67.             else if(this.v.y < 0)
  68.             {
  69.                if(Math.round(this.pos.y * 1000) / 1000 > Math.round((partner.pos.y + partner.size.y) * 1000) / 1000 && Math.round(this.tpos.y * 1000) / 1000 <= Math.round((partner.pos.y + partner.size.y) * 1000) / 1000)
  70.                {
  71.                   this.colNewVy = Math.abs(this.v.y) * this.flex;
  72.                }
  73.             }
  74.          }
  75.       }
  76.    }
  77.    function collisionCheck30(partner)
  78.    {
  79.       if(this.v.y > 0)
  80.       {
  81.          var _loc2_ = (partner.pos.y - this.pos.y) / (this.tpos.y - this.pos.y);
  82.          if(_loc2_ <= this.colPos)
  83.          {
  84.             if(_loc2_ == this.colPos)
  85.             {
  86.                this.colGhosts.push({pos:_loc2_,obj:this.colPartner});
  87.             }
  88.             var _loc4_ = this.pos.x + _loc2_ * (this.tpos.x - this.pos.x) - partner.pos.x;
  89.             if(_loc4_ <= partner.size.x && _loc4_ >= 0)
  90.             {
  91.                this.colPos = _loc2_;
  92.                this.colType = partner.collisionStyle;
  93.                this.colPartner = partner;
  94.                if(this.flex > 0)
  95.                {
  96.                   this.colNewVy = Math.abs(this.v.y) * -1 * this.flex;
  97.                   this.colNewVx = this.v.x * this.flex;
  98.                }
  99.                else
  100.                {
  101.                   this.colNewVx = undefined;
  102.                   this.colNewVy = 0;
  103.                }
  104.                this.colNewPartnerVx = undefined;
  105.                this.colNewPartnerVy = undefined;
  106.             }
  107.          }
  108.       }
  109.    }
  110.    function getBoundingRect()
  111.    {
  112.       this.boundingRect.p0.x = Math.min(this.pos.x,this.tpos.x);
  113.       this.boundingRect.p0.y = Math.min(this.pos.y,this.tpos.y);
  114.       this.boundingRect.p1.x = Math.max(this.pos.x,this.tpos.x);
  115.       this.boundingRect.p1.y = Math.max(this.pos.y,this.tpos.y);
  116.       return this.boundingRect;
  117.    }
  118. }
  119.