Advertisement
Guest User

Untitled

a guest
Dec 17th, 2012
13
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package
  2. {
  3.     import flash.display.MovieClip;
  4.     import flash.events.Event;
  5.  
  6.     public class EnemyShip extends MovieClip
  7.     {
  8.  
  9.         var xSpeed:Number;
  10.         var ySpeed:Number;
  11.         var exploded:Boolean = false;
  12.  
  13.         function EnemyShip()
  14.         {
  15.             Game.list.push(this);
  16.             this.x = 600;
  17.             this.y = Math.random() * 600;
  18.             xSpeed = Math.random() * 5 + 2;
  19.             ySpeed = Math.random() * 5 + 2;
  20.             addEventListener("enterFrame", enterFrame);
  21.         }
  22.  
  23.         function kill()
  24.         {if(exploded == false)
  25.         {
  26.             if (Game.tinyach == false)
  27.             {
  28.                 Game.updateach("Achievement Unlocked: Tiny Titan");
  29.                 Game.updateScore(500);
  30.                 Game.tinyach = true;
  31.                 Game.achMenu.tiny.gotoAndStop(2);
  32.             }
  33.             Game.enemieskilled +=  1;
  34.             if (Game.ship.ShieldPower == 1)
  35.             {
  36.                 Game.updateScore(25);
  37.             }
  38.             if (Game.ship.ShieldPower == 2)
  39.             {
  40.                 Game.updateScore(25*.7);
  41.             }
  42.             if (Game.ship.ShieldPower > 3)
  43.             {
  44.                 Game.updateScore(25*1.3);
  45.             }
  46.             var explosion = new Explosion();
  47.             stage.addChild(explosion);
  48.             explosion.x = this.x;
  49.             explosion.y = this.y;
  50.             explosion.xSpeed = this.xSpeed;
  51.             explosion.ySpeed = this.ySpeed;
  52.             removeEventListener("enterFrame", enterFrame);
  53.             stage.removeChild(this);
  54.             exploded = true;
  55.             for (var i in Game.list)
  56.             {
  57.                 if (Game.list[i] == this)
  58.                 {
  59.                     Game.list.splice(i,1);
  60.                 }
  61.             }
  62.         }}
  63.         function gameoverdie()
  64.         {
  65.  
  66.             var explosion = new Explosion();
  67.             stage.addChild(explosion);
  68.             explosion.x = this.x;
  69.             explosion.y = this.y;
  70.             explosion.xSpeed = this.xSpeed;
  71.             explosion.ySpeed = this.ySpeed;
  72.            
  73.             if (exploded == false)
  74.             {
  75.                 exploded = true;
  76.                 removeEventListener("enterFrame", enterFrame);
  77.                 stage.removeChild(this);
  78.                 for (var i in Game.list)
  79.                 {
  80.                     if (Game.list[i] == this)
  81.                     {
  82.                         Game.list.splice(i,1);
  83.                     }
  84.                 }
  85.             }
  86.         }
  87.         function enterFrame(e:Event)
  88.         {
  89.             if (Game.Paused == false)
  90.             {
  91.                 rotation -=  1;
  92.                 this.x -=  xSpeed;
  93.                 this.y -=  ySpeed;
  94.  
  95.                 if (Game.ship.invuln == false)
  96.                 {
  97.                     if (PixelPerfectCollisionDetection.isColliding(Game.ship,this,Game.ship,true))
  98.                     {
  99.                         for (var i in Game.list)
  100.                         {
  101.                             Game.ship.die();
  102.                             Game.updateScore(25);
  103.  
  104.                             break;
  105.                         }
  106.                     }
  107.                 }
  108.                 if (this.x >= 600)
  109.                 {
  110.                     this.x = 1;
  111.                 }
  112.                 if (this.x <= 0)
  113.                 {
  114.                     this.x = 599;
  115.                 }
  116.                 if (this.y <= 0)
  117.                 {
  118.                     this.y = 599;
  119.                 }
  120.                 if (this.y >= 600)
  121.                 {
  122.                     this.y = 1;
  123.                 }
  124.             }
  125.         }
  126.  
  127.     }
  128. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement