Advertisement
Guest User

Untitled

a guest
Jun 22nd, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. stop();
  2.  
  3. lives = 3;
  4. score = 0;
  5.  
  6. i = 0;
  7. enemies = [];
  8.  
  9. spawnEnemy = function(){
  10.     _root.attachMovie("enemy", "enemy"+i, _root.getNextHighestDepth());
  11.     _root["enemy"+i]._x = random(Stage.width);
  12.     _root["enemy"+i]._y = 0;
  13.     enemies.push("enemy"+i);
  14.    
  15.     _root["enemy"+i].onEnterFrame = function(){
  16.         this._y += 3;
  17.        
  18.         if(this.hitTest(_root.player)){
  19.             for(e = 0; e < _root.enemies.length; e++){
  20.                 if(_root.enemies[e] == this._name){
  21.                     _root.enemies.splice(e, 1);
  22.                 }
  23.             }
  24.            
  25.             this.removeMovieClip();
  26.             _root.lives--;
  27.         }
  28.        
  29.         if(this._y > Stage.height){
  30.             for(e = 0; e < _root.enemies.length; e++){
  31.                 if(_root.enemies[e] == this._name){
  32.                     _root.enemies.splice(e, 1);
  33.                 }
  34.             }
  35.            
  36.             this.removeMovieClip();
  37.         }
  38.     }
  39.    
  40.     i++;
  41. }
  42.  
  43. onEnterFrame = function(){
  44.     if(lives < 0){
  45.         nextFrame();
  46.     }
  47. }
  48.  
  49. enemy_interval = setInterval(spawnEnemy, 2000);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement