Advertisement
Guest User

Untitled

a guest
Jun 28th, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.91 KB | None | 0 0
  1. package{
  2.  
  3. import flash.display.MovieClip;
  4.  
  5. public class EnemyC extends MovieClip
  6. {
  7. 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;
  8. public var Bloody:Boolean=false, Albino:Boolean=false, HitDelay:Number=500;
  9. public var Remove:Boolean = false;
  10. public var DeathPlayed:Boolean=false;
  11. public function EnemyC()
  12. {
  13. if(Math.random()<0.5)
  14. {
  15. gotoAndPlay(1);
  16. }
  17. else
  18. {
  19. gotoAndPlay(26);
  20. }
  21. height=0.65*height;
  22. width=0.65*width;
  23.  
  24. angle=Math.random()*360; //Math.random()*360
  25.  
  26. if(angle<0)
  27. {
  28. angle+=360;
  29. }
  30.  
  31. rotation=angle;
  32.  
  33.  
  34.  
  35. SpeedX=0.12*Math.cos(angle*Math.PI/180);
  36. SpeedY=0.12*Math.sin(angle*Math.PI/180);
  37.  
  38.  
  39.  
  40. x=100;
  41. y=100;
  42.  
  43.  
  44. }
  45.  
  46. public function Reverse()
  47. {
  48. SpeedY=-SpeedY;
  49. SpeedX=-SpeedX;
  50. }
  51.  
  52. public function Move(DT:Number)
  53. {
  54. if(Dead==false)
  55. {
  56. Xlast=x;
  57. Ylast=y;
  58.  
  59. if(x>Globals.StageWidth-20)
  60. {
  61. SpeedX=-SpeedX;
  62.  
  63. x-=1;
  64. }
  65.  
  66. if(x<20)
  67. {
  68. x+=1;
  69. SpeedX=-SpeedX;
  70.  
  71. }
  72.  
  73. if(y<20)
  74. {
  75. SpeedY=-SpeedY;
  76. y+=1;
  77.  
  78.  
  79. }
  80. if(y>Globals.StageHeight-20)
  81. {
  82. SpeedY=-SpeedY;
  83. y-=1;
  84.  
  85. }
  86.  
  87.  
  88. if(DT<100)
  89. {
  90. x += DT*SpeedX;
  91. y += DT*SpeedY;
  92. }
  93. else
  94. {
  95. x += 33*SpeedX;
  96. y += 33*SpeedY;
  97. }
  98.  
  99. //Rotation(DT);
  100.  
  101. rotate(DT);
  102. }
  103. else
  104. {
  105. if(currentFrame==28)
  106. {
  107.  
  108. }
  109.  
  110.  
  111. }
  112.  
  113.  
  114.  
  115.  
  116. if (Dead == true)
  117. {
  118. if(DeathPlayed==false)
  119. {
  120. DeathPlayed=true;
  121. rotation=0;
  122. gotoAndPlay(51);
  123. }
  124. }
  125.  
  126. if(HitDelay>0)
  127. {
  128. HitDelay-=DT;
  129. }
  130. }
  131.  
  132. public function rotate(DT:Number)
  133. {
  134. var dist_x = x-Xlast;
  135. var dist_y = y-Ylast;
  136.  
  137.  
  138. var angle2 = Math.atan2(dist_y, dist_x);
  139.  
  140. var Rot:Number=0;
  141.  
  142. Rot = angle2/Math.PI*180-90+180;
  143. curRot=rotation;
  144.  
  145.  
  146. if(Rot < 0)
  147. {
  148. Rot+=360;
  149. }
  150. if(curRot<0)
  151. {
  152. curRot +=360;
  153. }
  154.  
  155. //trace(Rot, curRot);
  156.  
  157.  
  158.  
  159.  
  160.  
  161. if(Rot-curRot < 0)
  162. {
  163. if(Math.abs(Rot-curRot) > 8)
  164. {
  165. if(Math.abs(Rot-curRot)<180)
  166. {
  167. rotation -=8;
  168. }
  169. else
  170. {
  171. rotation +=8;
  172. }
  173. }
  174. }
  175. else
  176. {
  177. if(Math.abs(Rot-curRot) > 8)
  178. {
  179. if(Math.abs(Rot-curRot)<180)
  180. {
  181. rotation +=8;
  182. }
  183. else
  184. {
  185. rotation -=8;
  186. }
  187.  
  188. }
  189. }
  190.  
  191.  
  192. }
  193.  
  194.  
  195.  
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202.  
  203.  
  204.  
  205.  
  206.  
  207.  
  208. }
  209.  
  210. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement