Advertisement
Guest User

Untitled

a guest
Oct 5th, 2017
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class Ship extends MovieClip
  2. {
  3.         var velocity;
  4.         var shootLimiter;
  5.         var enemyTimer;
  6.         var enemies;
  7.         var score;
  8.        
  9.     function resetScore()
  10.         {
  11.                         score = 0;
  12.                         _root.scoreText.text = score;
  13.         }
  14.  
  15.         function onLoad()
  16.         {
  17.                 velocity = 10;
  18.                 shootLimiter= 0;
  19.                 enemyTimer = 0;
  20.                 enemies = [];
  21.                 resetScore();
  22.                 _root.gameOverMenu._visible = false;
  23.                
  24.         }
  25.         function onEnterFrame()
  26.         {
  27.                 shootLimiter += 1
  28.                
  29.                 if( Key.isDown(Key.RIGHT) )
  30.                 {
  31.                         _x = _x + velocity;
  32.                 }
  33.                
  34.                 if( Key.isDown(Key.LEFT) )
  35.                 {
  36.                         _x = _x - velocity;
  37.                 }
  38.                
  39.                 if( Key.isDown(Key.UP) )
  40.                 {
  41.                         _y = _y - velocity;
  42.                 }
  43.                
  44.                 if( Key.isDown(Key.DOWN) )
  45.                 {
  46.                         _y = _y + velocity;
  47.                 }
  48.                
  49.                 if( Key.isDown(Key.SPACE) && shootLimiter > 200)
  50.                 {
  51.                         shootLimiter= 0;
  52.                         var missile = _root.attachMovie( "Missile" , "Missile" + _root.getNextHighestDepth(), _root.getNextHighestDepth() );
  53.                         missile._x = _x + 50;
  54.                         missile._y = _y + 20;
  55.                 }
  56.                
  57.                 enemyTimer += 1;
  58.                
  59.                 if(enemyTimer > 60)
  60.                 {
  61.                         enemyTimer = 0;
  62.                         var enemy = _root.attachMovie("EnemyShip", "EnemyShip"+_root.getNextHighestDepth(), _root.getNextHighestDepth());
  63.                         enemies.push(enemy);
  64.                 }      
  65.                 function updateScore(points)
  66.                 {
  67.                         score += points;
  68.                         _root.scoreText.text = score;
  69.                 }
  70.         }
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement