Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package{
- import flash.display.MovieClip;
- public class EnemyC extends MovieClip
- {
- public var SpeedX:Number, SpeedY:Number, Xlast:Number=0, Ylast:Number=0, angle:Number=0, curRot:Number=0, factor:Number=6,Dead:Boolean=false, DeathFrame:Number=20, FrameD:Number=20, Variance:Number=0.8+Math.random()*0.2;
- public var Bloody:Boolean=false, Albino:Boolean=false, HitDelay:Number=500;
- public var Remove:Boolean = false;
- public var DeathPlayed:Boolean=false;
- public function EnemyC()
- {
- if(Math.random()<0.5)
- {
- gotoAndPlay(1);
- }
- else
- {
- gotoAndPlay(26);
- }
- height=0.65*height;
- width=0.65*width;
- angle=Math.random()*360; //Math.random()*360
- if(angle<0)
- {
- angle+=360;
- }
- rotation=angle;
- SpeedX=0.12*Math.cos(angle*Math.PI/180);
- SpeedY=0.12*Math.sin(angle*Math.PI/180);
- x=100;
- y=100;
- }
- public function Reverse()
- {
- SpeedY=-SpeedY;
- SpeedX=-SpeedX;
- }
- public function Move(DT:Number)
- {
- if(Dead==false)
- {
- Xlast=x;
- Ylast=y;
- if(x>Globals.StageWidth-20)
- {
- SpeedX=-SpeedX;
- x-=1;
- }
- if(x<20)
- {
- x+=1;
- SpeedX=-SpeedX;
- }
- if(y<20)
- {
- SpeedY=-SpeedY;
- y+=1;
- }
- if(y>Globals.StageHeight-20)
- {
- SpeedY=-SpeedY;
- y-=1;
- }
- if(DT<100)
- {
- x += DT*SpeedX;
- y += DT*SpeedY;
- }
- else
- {
- x += 33*SpeedX;
- y += 33*SpeedY;
- }
- //Rotation(DT);
- rotate(DT);
- }
- else
- {
- if(currentFrame==28)
- {
- }
- }
- if (Dead == true)
- {
- if(DeathPlayed==false)
- {
- DeathPlayed=true;
- rotation=0;
- gotoAndPlay(51);
- }
- }
- if(HitDelay>0)
- {
- HitDelay-=DT;
- }
- }
- public function rotate(DT:Number)
- {
- var dist_x = x-Xlast;
- var dist_y = y-Ylast;
- var angle2 = Math.atan2(dist_y, dist_x);
- var Rot:Number=0;
- Rot = angle2/Math.PI*180-90+180;
- curRot=rotation;
- if(Rot < 0)
- {
- Rot+=360;
- }
- if(curRot<0)
- {
- curRot +=360;
- }
- //trace(Rot, curRot);
- if(Rot-curRot < 0)
- {
- if(Math.abs(Rot-curRot) > 8)
- {
- if(Math.abs(Rot-curRot)<180)
- {
- rotation -=8;
- }
- else
- {
- rotation +=8;
- }
- }
- }
- else
- {
- if(Math.abs(Rot-curRot) > 8)
- {
- if(Math.abs(Rot-curRot)<180)
- {
- rotation +=8;
- }
- else
- {
- rotation -=8;
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement