Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class AimedMissile extends MovieClip {
- var speed;
- var angle;
- var xVel;
- var yVel;
- function onLoad() {
- speed = -5;
- var xDiff = _root.ship._x - _x;
- var yDiff = _root.ship._y - _y;
- angle = Math.atan2(yDiff, xDiff);
- _rotation = angle * 180/Math.PI
- xVel = speed * Math.cos(angle);
- yVel = speed * Math.sin(angle);
- }
- function onEnterFrame() {
- _x -= xVel;
- _y -= yVel;
- _rotation += 100;
- if (this.hitTest(_root.ship)) {
- this.removeMovieClip();
- _root.ship.updateHealth(-3);
- var explosion = _root.attachMovie("Explosion", "Explosion"+_root.getNextHighestDepth(), _root.getNextHighestDepth());
- explosion._x = _root.ship._x;
- explosion._y = _root.ship._y;
- }
- if (this.hitTest(_root.nuke)) {
- this.removeMovieClip();
- }
- if (this.hitTest(_root.beam)) {
- this.removeMovieClip();
- }
- if (_x<-1) {
- this.removeMovieClip();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement