home *** CD-ROM | disk | FTP | other *** search
- class Particle
- {
- var position;
- var velocity;
- var type;
- var alpha;
- var frame;
- var flightTime;
- var bmpCanvas;
- var screenPos;
- function Particle(pos)
- {
- this.position = pos.clone();
- var _loc3_ = 12 * (1 - 2 * Math.random());
- var _loc2_ = 7 + 9 * Math.random();
- this.velocity = new flash.geom.Point(_loc3_,_loc2_);
- this.type = Math.floor(4 * Math.random());
- this.alpha = 100;
- this.frame = 0;
- this.flightTime = 5 + Math.round(25 * Math.random());
- this.bmpCanvas = Game.bmpShots;
- }
- function getPosition(Void)
- {
- return this.position.clone();
- }
- function step(Void)
- {
- this.velocity.y -= 1.2;
- this.velocity.x *= 0.97;
- this.position.x += this.velocity.x;
- this.position.y += this.velocity.y;
- this.frame = this.frame + 1;
- this.frame %= 4;
- if(this.flightTime-- <= 0 || this.position.y < 0)
- {
- Game.getInstance().removeShrapnel(this);
- }
- else if(this.flightTime < 10)
- {
- this.alpha = 10 * this.flightTime;
- }
- }
- function draw(leftEdge)
- {
- var _loc7_ = this.position.x - leftEdge;
- var _loc6_ = this.position.y;
- this.screenPos = new flash.geom.Point(_loc7_,_loc6_);
- var _loc3_ = _root.attachMovie("shrapnel","mcShr",_root.getNextHighestDepth());
- _loc3_.gotoAndStop(this.type);
- var _loc8_ = (50 + 50 * (30 - this.flightTime) / 30) / 100;
- var _loc4_ = new flash.geom.Matrix();
- _loc4_.scale(_loc8_,_loc8_);
- var _loc5_ = new flash.geom.Matrix();
- _loc5_.translate(_loc7_,Game.screenH - _loc6_);
- _loc4_.concat(_loc5_);
- var _loc9_ = new flash.geom.ColorTransform(1,1,1,this.alpha / 100,0,0,0,0);
- this.bmpCanvas.draw(_loc3_,_loc4_,_loc9_,null,null,true);
- _loc3_.removeMovieClip();
- }
- }
-