daily pastebin goal
28%
SHARE
TWEET

Untitled

a guest Jun 19th, 2017 46 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class AimedMissile extends MovieClip {
  2.     var speed;
  3.     var angle;
  4.     var xVel;
  5.     var yVel;
  6.    
  7.     function onLoad() {
  8.         speed = -5;
  9.         var xDiff = _root.ship._x - _x;
  10.         var yDiff = _root.ship._y - _y;
  11.         angle = Math.atan2(yDiff, xDiff);
  12.         _rotation = angle * 180/Math.PI
  13.         xVel = speed * Math.cos(angle);
  14.         yVel = speed * Math.sin(angle);
  15.  
  16.     }
  17.  
  18.     function onEnterFrame() {
  19.         _x -= xVel;
  20.         _y -= yVel;
  21.         _rotation += 100;
  22.  
  23.         if (this.hitTest(_root.ship)) {
  24.             this.removeMovieClip();
  25.             _root.ship.updateHealth(-3);
  26.             var explosion = _root.attachMovie("Explosion", "Explosion"+_root.getNextHighestDepth(), _root.getNextHighestDepth());
  27.             explosion._x = _root.ship._x;
  28.             explosion._y = _root.ship._y;
  29.         }
  30.  
  31.         if (this.hitTest(_root.nuke)) {
  32.             this.removeMovieClip();
  33.         }
  34.  
  35.         if (this.hitTest(_root.beam)) {
  36.             this.removeMovieClip();
  37.            
  38.         }
  39.  
  40.         if (_x<-1) {
  41.             this.removeMovieClip();
  42.         }
  43.     }
  44. }
RAW Paste Data
Top