home *** CD-ROM | disk | FTP | other *** search
- function Enemy()
- {
- this.init();
- }
- delete er;
- var er = Enemy.prototype = new MovieClip();
- er.init = function()
- {
- this.pow = Math.pow;
- this.sqrt = Math.sqrt;
- this.sin = Math.sin;
- this.asin = Math.asin;
- this.cos = Math.cos;
- this.abs = Math.abs;
- this.pi = 3.141592653589793;
- if(this.dest == undefined)
- {
- this.setCourse();
- }
- this.attack();
- };
- er.setCourse = function()
- {
- var rot = this._rot = random(360);
- var rad = this.pi / 180 * rot;
- var xram = 330 * this.cos(rad) + $middle.x;
- var yram = 330 * this.sin(rad) + $middle.y;
- this.dest = {x:xram,y:yram};
- };
- er.attack = function()
- {
- if(this.t != 2)
- {
- this._rotation = this._rot + 90;
- }
- else
- {
- this._rotation = 180;
- }
- this.onEnterFrame = this.fly;
- this.onAir = true;
- };
- er.fly = function()
- {
- var x = (this._gx - this.dest.x - 15) * this.spd;
- var y = (this._gy - this.dest.y - 15) * this.spd;
- with(this)
- {
- _x -= x;
- _y -= y;
- _yscale = _xscale -= (_xscale - 100) * this.spd;
- if(out.hitTest(_x,_y,1) == true)
- {
- wait();
- return undefined;
- }
- }
- };
- er.wait = function()
- {
- this.onAir = false;
- delete this.onEnterFrame;
- var rx = random(30) - 15;
- var ry = random(30) - 15;
- var x = $middle.x + rx;
- var y = $middle.y + ry;
- with(this)
- {
- _x = x;
- _y = y;
- _xscale = _yscale = 20;
- }
- this.sx = this._x;
- this.sy = this._y;
- this.bStep = 0;
- return undefined;
- };
- er.kill = function()
- {
- this.removeMovieClip();
- };
- er.bounce = function()
- {
- this.bStep += 2;
- var rad = this.pi / 180 * this.bStep;
- this._x = this.sx + this.sin(rad) * 10;
- this._y = this.sy + this.cos(rad) * 10;
- };
- Object.registerClass("Enemy_t1",this.Enemy);
- Object.registerClass("Enemy_t2",this.Enemy);
- Object.registerClass("Enemy_t3",this.Enemy);
-