Advertisement
Guest User

Untitled

a guest
Jun 22nd, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. onClipEvent(load){
  2.     timer = 0;
  3.     i = 0;
  4. }
  5.  
  6. onClipEvent(enterFrame){
  7.     if(timer > 0){
  8.         timer--;
  9.     }
  10.    
  11.     if(Key.isDown(Key.LEFT)){
  12.         _x -= 6;
  13.     }else if(Key.isDown(Key.RIGHT)){
  14.         _x += 6;
  15.     }
  16.    
  17.     if(Key.isDown(Key.SPACE)){
  18.         if(timer == 0){
  19.             _root.attachMovie("bullet", "bullet"+i, _root.getNextHighestDepth());
  20.             _root["bullet"+i]._x = _x;
  21.             _root["bullet"+i]._y = _y-20;
  22.            
  23.             _root["bullet"+i].onEnterFrame = function(){
  24.                 this._y -= 10;
  25.                 if(this._y < -30){
  26.                     this.removeMovieClip();
  27.                 }
  28.                
  29.                 for(k = 0; k < _root.enemies.length; k++){
  30.                     if(this.hitTest(_root[_root.enemies[k]])){
  31.                         _root.score += 10;
  32.                         this.removeMovieClip();
  33.                         _root[_root.enemies[k]].removeMovieClip();
  34.                         _root.enemies.splice(k, 1);
  35.                     }
  36.                 }
  37.             }
  38.            
  39.             i++;
  40.             timer = 20;
  41.         }
  42.     }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement