home *** CD-ROM | disk | FTP | other *** search
- class org.cove.flade.primitives.Wheel extends org.cove.flade.primitives.CircleParticle
- {
- var rp;
- var coeffSlip;
- var leftright;
- var isVisible;
- var curr;
- var dmc;
- var radius;
- var prev;
- function Wheel(x, y, r, rootmc)
- {
- super(x,y,r,rootmc);
- this.rp = new org.cove.flade.primitives.RimParticle(r,0.5);
- this.coeffSlip = 0.5;
- this.leftright = 0;
- }
- function GetRadius()
- {
- return this.rp.GetRadius();
- }
- function SetRadius(r)
- {
- super(r);
- this.rp.SetRadius(r);
- }
- function verlet(sysObj)
- {
- this.rp.verlet(sysObj);
- super.verlet(sysObj);
- }
- function resolveCollision(normal, sysObj)
- {
- super.resolveCollision(normal,sysObj);
- this.resolve(normal);
- }
- function paint()
- {
- if(this.isVisible)
- {
- var _loc3_ = this.curr.x;
- var _loc2_ = this.curr.y;
- var _loc5_ = this.rp.curr.x;
- var _loc4_ = this.rp.curr.y;
- this.dmc.clear();
- this.dmc.lineStyle(0,2237064,100);
- org.cove.flade.graphics.Graphics.paintCircle(this.dmc,_loc3_,_loc2_,this.radius);
- this.dmc.lineStyle(0,10066329,100);
- org.cove.flade.graphics.Graphics.paintLine(this.dmc,_loc5_ + _loc3_,_loc4_ + _loc2_,_loc3_,_loc2_);
- org.cove.flade.graphics.Graphics.paintLine(this.dmc,- _loc5_ + _loc3_,- _loc4_ + _loc2_,_loc3_,_loc2_);
- org.cove.flade.graphics.Graphics.paintLine(this.dmc,- _loc4_ + _loc3_,_loc5_ + _loc2_,_loc3_,_loc2_);
- org.cove.flade.graphics.Graphics.paintLine(this.dmc,_loc4_ + _loc3_,- _loc5_ + _loc2_,_loc3_,_loc2_);
- }
- }
- function setTraction(t)
- {
- this.coeffSlip = t;
- }
- function resolve(n)
- {
- var _loc3_ = - this.rp.curr.y;
- var _loc2_ = this.rp.curr.x;
- var _loc6_ = Math.sqrt(_loc3_ * _loc3_ + _loc2_ * _loc2_);
- _loc3_ /= _loc6_;
- _loc2_ /= _loc6_;
- var _loc14_ = _loc3_ * this.rp.speed;
- var _loc12_ = _loc2_ * this.rp.speed;
- var _loc13_ = this.curr.x - this.prev.x;
- var _loc11_ = this.curr.y - this.prev.y;
- var _loc10_ = _loc13_ + _loc14_;
- var _loc9_ = _loc11_ + _loc12_;
- var _loc5_ = (- n.y) * _loc10_ + n.x * _loc9_;
- var _loc4_ = undefined;
- if(_loc5_ > 0)
- {
- if(this.leftright == -1)
- {
- _loc4_ = - (1 - this.coeffSlip);
- }
- else
- {
- _loc4_ = 1;
- }
- }
- else if(this.leftright == 1)
- {
- _loc4_ = - (1 - this.coeffSlip);
- }
- else
- {
- _loc4_ = 1;
- }
- this.rp.prev.x = this.rp.curr.x - _loc5_ * _loc3_ * _loc4_;
- this.rp.prev.y = this.rp.curr.y - _loc5_ * _loc2_ * _loc4_;
- var _loc8_ = 1 - this.coeffSlip;
- this.curr.x += _loc8_ * this.rp.speed * (- n.y);
- this.curr.y += _loc8_ * this.rp.speed * n.x;
- this.rp.speed *= this.coeffSlip;
- }
- }
-