Mouse hunter. Don’t get hit by the missles. I was going to add some improvements but I ran out of lines:
gun = _root.createEmptyMovieClip("gun", _root.getNextHighestDepth());
bullet = _root.createEmptyMovieClip("bullet", _root.getNextHighestDepth());
bullet.lineStyle(5, 0x000000, 100);
gun._y = 400;
points = new Array(new Array(-5, 0), new Array(-5, -50), new Array(5, -50), new Array(5, 0), new Array(0, 5, true));
gun.lineStyle(0, 0x000000, 100);
for (var i = 0; i<points.length-1; i++) {
gun.moveTo(points*[0], points*[1]);
(points[i+1][2]) ? bullet.lineTo(points[i+1][0], points[i+1][1]) : gun.lineTo(points[i+1][0], points[i+1][1]);
}
gun.count = gun.age=0;
gun.onEnterFrame = function() {
this._x += (_root._xmouse-this._x)/12;
this._rotation = (Math.atan2(-1*(_root._ymouse-this._y), (_root._xmouse-this._x))/Math.PI*-180)+90;
(this.count>1000/this.age) ? genBullet((gun.count=0)) : this.count++;
(this.age<1000) ? this.age++ : null;
};
function genBullet(num) {
temp = bullet.duplicateMovieClip("bullet"+_root.getNextHighestDepth(), _root.getNextHighestDepth(), {_x:_root.gun._x, _y:_root.gun._y-50, _rotation:_root.gun._rotation, age:0});
temp.onEnterFrame = function() {
this.age++;
(this.hitTest(_root._xmouse, _root._ymouse, true) || (this.age>60 && Math.random()*100 > 98)) ? explode(this) : this._rotation=(Math.atan2(-1*(_root._ymouse-this._y), (_root._xmouse-this._x))/Math.PI*-180)+90;
(this._x>550 || this._x<0) ? this.removeMovieClip() : this._x += Math.cos((this._rotation-90)*Math.PI/180)*5;
(this._y<0) ? this.removeMovieClip() : this._y += Math.sin((this._rotation-90)*Math.PI/180)*5;
};
}
function explode(clip) {
for (var i = 0; i<25; i++) {
temp = bullet.duplicateMovieClip("particle"+_root.getNextHighestDepth(), _root.getNextHighestDepth(), {_x:clip._x, _y:clip._y, vx:Math.random()*20-5, vy:-(Math.random()*10+10)});
temp.onEnterFrame = function() {
(this._x>550 || this._x<0) ? this.removeMovieClip() : this._x += this.vx;
(this._y>400) ? this.removeMovieClip() : this._y += (this.vy += 3);
(this._alpha<0) ? this.removeMovieClip() : this._alpha -= 3;
};
}
clip.removeMovieClip();
}