home *** CD-ROM | disk | FTP | other *** search
/ 404 Jogos / CLJG.iso / Aventura / starisland.swf / scripts / __Packages / org / cove / flade / primitives / Wheel.as < prev   
Encoding:
Text File  |  2007-12-10  |  2.9 KB  |  101 lines

  1. class org.cove.flade.primitives.Wheel extends org.cove.flade.primitives.CircleParticle
  2. {
  3.    var rp;
  4.    var coeffSlip;
  5.    var leftright;
  6.    var isVisible;
  7.    var curr;
  8.    var dmc;
  9.    var radius;
  10.    var prev;
  11.    function Wheel(x, y, r, rootmc)
  12.    {
  13.       super(x,y,r,rootmc);
  14.       this.rp = new org.cove.flade.primitives.RimParticle(r,0.5);
  15.       this.coeffSlip = 0.5;
  16.       this.leftright = 0;
  17.    }
  18.    function GetRadius()
  19.    {
  20.       return this.rp.GetRadius();
  21.    }
  22.    function SetRadius(r)
  23.    {
  24.       super(r);
  25.       this.rp.SetRadius(r);
  26.    }
  27.    function verlet(sysObj)
  28.    {
  29.       this.rp.verlet(sysObj);
  30.       super.verlet(sysObj);
  31.    }
  32.    function resolveCollision(normal, sysObj)
  33.    {
  34.       super.resolveCollision(normal,sysObj);
  35.       this.resolve(normal);
  36.    }
  37.    function paint()
  38.    {
  39.       if(this.isVisible)
  40.       {
  41.          var _loc3_ = this.curr.x;
  42.          var _loc2_ = this.curr.y;
  43.          var _loc5_ = this.rp.curr.x;
  44.          var _loc4_ = this.rp.curr.y;
  45.          this.dmc.clear();
  46.          this.dmc.lineStyle(0,2237064,100);
  47.          org.cove.flade.graphics.Graphics.paintCircle(this.dmc,_loc3_,_loc2_,this.radius);
  48.          this.dmc.lineStyle(0,10066329,100);
  49.          org.cove.flade.graphics.Graphics.paintLine(this.dmc,_loc5_ + _loc3_,_loc4_ + _loc2_,_loc3_,_loc2_);
  50.          org.cove.flade.graphics.Graphics.paintLine(this.dmc,- _loc5_ + _loc3_,- _loc4_ + _loc2_,_loc3_,_loc2_);
  51.          org.cove.flade.graphics.Graphics.paintLine(this.dmc,- _loc4_ + _loc3_,_loc5_ + _loc2_,_loc3_,_loc2_);
  52.          org.cove.flade.graphics.Graphics.paintLine(this.dmc,_loc4_ + _loc3_,- _loc5_ + _loc2_,_loc3_,_loc2_);
  53.       }
  54.    }
  55.    function setTraction(t)
  56.    {
  57.       this.coeffSlip = t;
  58.    }
  59.    function resolve(n)
  60.    {
  61.       var _loc3_ = - this.rp.curr.y;
  62.       var _loc2_ = this.rp.curr.x;
  63.       var _loc6_ = Math.sqrt(_loc3_ * _loc3_ + _loc2_ * _loc2_);
  64.       _loc3_ /= _loc6_;
  65.       _loc2_ /= _loc6_;
  66.       var _loc14_ = _loc3_ * this.rp.speed;
  67.       var _loc12_ = _loc2_ * this.rp.speed;
  68.       var _loc13_ = this.curr.x - this.prev.x;
  69.       var _loc11_ = this.curr.y - this.prev.y;
  70.       var _loc10_ = _loc13_ + _loc14_;
  71.       var _loc9_ = _loc11_ + _loc12_;
  72.       var _loc5_ = (- n.y) * _loc10_ + n.x * _loc9_;
  73.       var _loc4_ = undefined;
  74.       if(_loc5_ > 0)
  75.       {
  76.          if(this.leftright == -1)
  77.          {
  78.             _loc4_ = - (1 - this.coeffSlip);
  79.          }
  80.          else
  81.          {
  82.             _loc4_ = 1;
  83.          }
  84.       }
  85.       else if(this.leftright == 1)
  86.       {
  87.          _loc4_ = - (1 - this.coeffSlip);
  88.       }
  89.       else
  90.       {
  91.          _loc4_ = 1;
  92.       }
  93.       this.rp.prev.x = this.rp.curr.x - _loc5_ * _loc3_ * _loc4_;
  94.       this.rp.prev.y = this.rp.curr.y - _loc5_ * _loc2_ * _loc4_;
  95.       var _loc8_ = 1 - this.coeffSlip;
  96.       this.curr.x += _loc8_ * this.rp.speed * (- n.y);
  97.       this.curr.y += _loc8_ * this.rp.speed * n.x;
  98.       this.rp.speed *= this.coeffSlip;
  99.    }
  100. }
  101.