home *** CD-ROM | disk | FTP | other *** search
- class Pirrest.PhisicsEngine.Constraint
- {
- var p1;
- var p2;
- var restLength;
- var dmc;
- function Constraint($p1, $p2)
- {
- this.init($p1,$p2);
- }
- function init($p1, $p2)
- {
- this.p1 = $p1;
- this.p2 = $p2;
- this.restLength = $p1.curr.distance($p2.curr);
- var _loc3_ = _root.main_mc.main_cont_mc.level_mc.over_mc.getNextHighestDepth();
- this.dmc = _root.main_mc.main_cont_mc.level_mc.over_mc.createEmptyMovieClip("p_" + _loc3_,_loc3_);
- }
- function resolve()
- {
- var _loc5_ = this.p1.curr.minusNew(this.p2.curr);
- var _loc3_ = this.p1.curr.distance(this.p2.curr);
- var _loc4_ = (_loc3_ - this.restLength) / _loc3_;
- var _loc2_ = _loc5_.mult(_loc4_ * 0.5);
- this.p1.curr.minus(_loc2_);
- this.p2.curr.plus(_loc2_);
- }
- function setRestLength($r)
- {
- this.restLength = $r;
- }
- function paint()
- {
- this.dmc.clear();
- this.dmc.lineStyle(0,16711680,100);
- Pirrest.PhisicsEngine.Graphics.prototype.paintLine(this.dmc,this.p1.curr.x,this.p1.curr.y,this.p2.curr.x,this.p2.curr.y);
- }
- }
-