home *** CD-ROM | disk | FTP | other *** search
- class Rope
- {
- var refChopper;
- var bmpRope;
- var bmpCanvas;
- var begPos;
- var endPos;
- var bHasCargo;
- var length;
- var maxLength;
- var mode;
- var angle;
- var maxAngle;
- var angleVel;
- var refCargo;
- var scrPos;
- function Rope(refChopperNew)
- {
- this.refChopper = refChopperNew;
- this.bmpRope = flash.display.BitmapData.loadBitmap("rope");
- this.bmpCanvas = Game.bmpShots;
- this.begPos = new flash.geom.Point();
- this.endPos = new flash.geom.Point();
- this.bHasCargo = false;
- this.length = 0;
- this.maxLength = 100;
- this.mode = 0;
- this.angle = 0;
- this.maxAngle = 1.0471975511965976;
- this.angleVel = 0;
- this.refCargo = null;
- }
- function step(begPosNew, chopVel)
- {
- this.begPos = begPosNew.clone();
- if(this.mode == 1)
- {
- if(this.refCargo.sType == "vehicle")
- {
- if(this.length > 62)
- {
- this.length -= 2;
- }
- else if(this.length < 58)
- {
- this.length += 2;
- }
- }
- else if(this.length < this.maxLength)
- {
- this.length += 2;
- }
- }
- else if(this.mode == 2)
- {
- if(this.length > 0)
- {
- this.length -= 2;
- }
- else
- {
- this.refCargo = null;
- this.bHasCargo = false;
- this.length = 0;
- this.angleVel = 0;
- this.setMode(0);
- }
- }
- if(this.length > 0)
- {
- this.angle += 3.141592653589793 * chopVel.x / 240;
- if(this.angle > this.maxAngle)
- {
- this.angle += (this.maxAngle - this.angle) * 0.1;
- }
- else if(this.angle < - this.maxAngle)
- {
- this.angle += (- this.maxAngle - this.angle) * 0.1;
- }
- var _loc3_ = 0.006;
- var _loc2_ = (- this.angle) * _loc3_;
- this.angleVel += _loc2_;
- this.angleVel *= 0.97;
- this.angle += this.angleVel;
- do
- {
- this.endPos.x = this.begPos.x - this.length * Math.sin(this.angle);
- this.endPos.y = this.begPos.y - this.length * Math.cos(this.angle);
- if(this.checkCollision() || this.endPos.y < 30)
- {
- this.length -= 1;
- }
- }
- while(this.checkCollision() || this.endPos.y < 30);
-
- return this.endPos;
- }
- }
- function draw(scrPosNew)
- {
- this.scrPos = scrPosNew.clone();
- var _loc4_ = new flash.display.BitmapData(1,this.length);
- _loc4_.copyPixels(this.bmpRope,this.bmpRope.rectangle,new flash.geom.Point(0,0));
- var _loc2_ = new flash.geom.Matrix();
- _loc2_.rotate(this.angle);
- var _loc3_ = new flash.geom.Matrix();
- if(this.angle > 0)
- {
- _loc3_.translate(this.scrPos.x,Game.screenH - this.scrPos.y);
- }
- else
- {
- _loc3_.translate(this.scrPos.x,Game.screenH - this.scrPos.y);
- }
- _loc2_.concat(_loc3_);
- var _loc5_ = true;
- this.bmpCanvas.draw(_loc4_,_loc2_,null,null,null,_loc5_);
- }
- function setMode(modeNew)
- {
- this.mode = modeNew;
- if(this.mode == 1)
- {
- this.endPos = this.begPos.clone();
- }
- }
- function switchMode(Void)
- {
- if(this.mode == 0 || this.mode == 2)
- {
- this.setMode(1);
- }
- else if(this.mode == 1)
- {
- this.setMode(2);
- if(this.refCargo.sType == "vehicle")
- {
- this.refCargo.mode = 2;
- this.refCargo.vel = this.refChopper.speed.clone();
- }
- }
- }
- function checkCollision(Void)
- {
- var _loc3_ = this.scrPos.x + (this.endPos.x - this.begPos.x);
- var _loc2_ = Game.screenH - this.endPos.y;
- return Game.bmpDead.hitTest(new flash.geom.Point(0,0),250,new flash.geom.Point(_loc3_,_loc2_));
- }
- }
-