home *** CD-ROM | disk | FTP | other *** search
- class Shot implements WorkObject
- {
- var bmpShot;
- var bmpCanvas;
- var position;
- var velocity;
- var acc;
- var rotation;
- var ct;
- var colorInd;
- var bChopper;
- var screenPos;
- function Shot(sLinkageId, pos, vel)
- {
- this.bmpShot = flash.display.BitmapData.loadBitmap(sLinkageId);
- this.bmpCanvas = Game.bmpShots;
- this.position = pos.clone();
- this.position.x -= this.bmpShot.width / 2;
- this.position.y -= this.bmpShot.height / 2;
- this.velocity = vel.clone();
- var _loc4_ = vel.x * 0.05;
- var _loc3_ = vel.y * 0.05;
- this.acc = new flash.geom.Point(_loc4_,_loc3_);
- this.rotation = Math.atan2(vel.y,vel.x);
- var _loc5_ = Math.random();
- this.ct = new flash.geom.ColorTransform(_loc5_,1,1,1,0,0,0,0);
- this.colorInd = Math.floor(180 * Math.random());
- this.bChopper = true;
- }
- function step(Void)
- {
- this.velocity.x += this.acc.x;
- this.velocity.y += this.acc.y;
- this.position.x += this.velocity.x;
- this.position.y += this.velocity.y;
- if(this.bChopper)
- {
- if(this.checkCollision() || this.position.y < 20)
- {
- Game.getInstance().removeAllyShot(this);
- }
- }
- if(this.screenPos.y < 0 || this.screenPos.y > Game.screenH || this.screenPos.x < 0 || this.screenPos.x > Game.screenW)
- {
- Game.getInstance().removeAllyShot(this);
- }
- }
- function draw(leftEdge)
- {
- var _loc6_ = this.position.x - leftEdge;
- var _loc5_ = this.position.y;
- this.screenPos = new flash.geom.Point(_loc6_,_loc5_);
- var _loc2_ = new flash.display.BitmapData(this.bmpShot.width,this.bmpShot.height,true,0);
- _loc2_.copyPixels(this.bmpShot,this.bmpShot.rectangle,new flash.geom.Point(0,0),null,null,true);
- var _loc3_ = new flash.geom.Matrix();
- _loc3_.translate((- _loc2_.width) / 2,(- _loc2_.height) / 2);
- var _loc7_ = new flash.geom.Matrix();
- _loc7_.rotate(- this.rotation);
- _loc3_.concat(_loc7_);
- var _loc4_ = new flash.geom.Matrix();
- _loc4_.translate(_loc6_,Game.screenH - _loc5_);
- _loc3_.concat(_loc4_);
- if(this.ct != null)
- {
- this.colorInd += 600;
- var _loc12_ = 0.2 + 0.8 * (Math.sin(3.141592653589793 * this.colorInd / 180) + 1) / 2;
- this.ct = new flash.geom.ColorTransform(1,_loc12_,0,1,0,0,0,100);
- }
- var _loc9_ = this.ct;
- var _loc8_ = "normal";
- var _loc10_ = null;
- var _loc11_ = true;
- this.bmpCanvas.draw(_loc2_,_loc3_,_loc9_,_loc8_,_loc10_,_loc11_);
- }
- function checkCollision(Void)
- {
- var _loc3_ = this.screenPos.x;
- var _loc2_ = Game.screenH - (this.screenPos.y - 10);
- return Game.bmpDead.hitTest(new flash.geom.Point(0,0),250,new flash.geom.Point(_loc3_,_loc2_));
- }
- }
-