Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package
- {
- import flash.display.MovieClip;
- import flash.events.Event;
- public class EnemyShip extends MovieClip
- {
- var xSpeed:Number;
- var ySpeed:Number;
- var exploded:Boolean = false;
- function EnemyShip()
- {
- Game.list.push(this);
- this.x = 600;
- this.y = Math.random() * 600;
- xSpeed = Math.random() * 5 + 2;
- ySpeed = Math.random() * 5 + 2;
- addEventListener("enterFrame", enterFrame);
- }
- function kill()
- {if(exploded == false)
- {
- if (Game.tinyach == false)
- {
- Game.updateach("Achievement Unlocked: Tiny Titan");
- Game.updateScore(500);
- Game.tinyach = true;
- Game.achMenu.tiny.gotoAndStop(2);
- }
- Game.enemieskilled += 1;
- if (Game.ship.ShieldPower == 1)
- {
- Game.updateScore(25);
- }
- if (Game.ship.ShieldPower == 2)
- {
- Game.updateScore(25*.7);
- }
- if (Game.ship.ShieldPower > 3)
- {
- Game.updateScore(25*1.3);
- }
- var explosion = new Explosion();
- stage.addChild(explosion);
- explosion.x = this.x;
- explosion.y = this.y;
- explosion.xSpeed = this.xSpeed;
- explosion.ySpeed = this.ySpeed;
- removeEventListener("enterFrame", enterFrame);
- stage.removeChild(this);
- exploded = true;
- for (var i in Game.list)
- {
- if (Game.list[i] == this)
- {
- Game.list.splice(i,1);
- }
- }
- }}
- function gameoverdie()
- {
- var explosion = new Explosion();
- stage.addChild(explosion);
- explosion.x = this.x;
- explosion.y = this.y;
- explosion.xSpeed = this.xSpeed;
- explosion.ySpeed = this.ySpeed;
- if (exploded == false)
- {
- exploded = true;
- removeEventListener("enterFrame", enterFrame);
- stage.removeChild(this);
- for (var i in Game.list)
- {
- if (Game.list[i] == this)
- {
- Game.list.splice(i,1);
- }
- }
- }
- }
- function enterFrame(e:Event)
- {
- if (Game.Paused == false)
- {
- rotation -= 1;
- this.x -= xSpeed;
- this.y -= ySpeed;
- if (Game.ship.invuln == false)
- {
- if (PixelPerfectCollisionDetection.isColliding(Game.ship,this,Game.ship,true))
- {
- for (var i in Game.list)
- {
- Game.ship.die();
- Game.updateScore(25);
- break;
- }
- }
- }
- if (this.x >= 600)
- {
- this.x = 1;
- }
- if (this.x <= 0)
- {
- this.x = 599;
- }
- if (this.y <= 0)
- {
- this.y = 599;
- }
- if (this.y >= 600)
- {
- this.y = 1;
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement