home *** CD-ROM | disk | FTP | other *** search
- function PlayerClass()
- {
- this.init();
- }
- delete pr;
- var pr = PlayerClass.prototype;
- pr.init = function()
- {
- this.min = Math.min;
- this.linkage = "PlayerBox";
- this.mc = "player_mc";
- this.bulletLinkage = "Player_bullet";
- this.shieldLN = "Player_shield";
- this.wingmanLN = "Player_wingman";
- this.conf = {bulletID:0,spd:0.06,eCurr:100,eMax:100};
- $root.energy = this.conf.eCurr;
- this.bullets = [];
- this.bullets.push({ln:"Player_nBullet",spd:0.09,pwr:10});
- this.bullets.push({ln:"Player_dblBullet",spd:0.07,pwr:15});
- this.bullets[900] = {ln:"Player_wmbullet",spd:0.08,pwr:2};
- this.abs = Math.abs;
- this.pow = Math.pow;
- this.sqrt = Math.sqrt;
- this.sin = Math.sin;
- this.asin = Math.asin;
- this.cos = Math.cos;
- this.pi = 3.141592653589793;
- this.temp = 0;
- };
- pr.place = function()
- {
- this.tgt = $root.attachMovie(this.linkage,this.mc,$root.hd(),{_x:$middle.x,_y:$middle.y});
- this.tgt.path = this;
- var o = this.keyObj = {path:this};
- o.fire = true;
- o.onKeyDown = function()
- {
- if($root.Director.currEmsQty < 1)
- {
- return undefined;
- }
- if(Key.isDown(32) && this.fire === true)
- {
- this.path.shoot();
- this.fire = false;
- }
- };
- o.onKeyUp = function()
- {
- if(Key.getCode() == 32)
- {
- this.fire = true;
- }
- };
- Key.addListener(o);
- this.tgt.onEnterFrame = function()
- {
- this.path.updPosition();
- };
- };
- pr.remove = function()
- {
- this.tgt.removeMovieClip();
- };
- pr.updPosition = function()
- {
- var ecr = $root.Director.enemiesCon;
- if(this.tgt.h1.hitTest(ecr) == true || this.tgt.h2.hitTest(ecr) == true || this.tgt.h3.hitTest(ecr) == true || this.tgt.h4.hitTest(ecr) == true || this.tgt.h5.hitTest(ecr) == true)
- {
- for(var e in ecr)
- {
- if(this.tgt.obj.hitTest(ecr[e]) == true)
- {
- this.hitMe(ecr[e].power);
- $root.Director.destroyEnemy(ecr[e]);
- ecr[e].removeMovieClip();
- }
- }
- }
- if(Key.isDown(37))
- {
- this.plrAngle += 6;
- }
- if(Key.isDown(39))
- {
- this.plrAngle -= 6;
- }
- this.plrAngle2 -= (this.plrAngle2 - this.plrAngle) * 0.1;
- this.tgt._rotation = this.plrAngle2 % 360;
- };
- pr.shoot = function(coor)
- {
- var hd = $root.hd();
- var o = this.bullets[this.conf.bulletID];
- var ln = o.ln;
- o._x = this.tgt.obj._gx + coor.x;
- o._y = this.tgt.obj._gy + coor.y;
- o._rotation = this.tgt._rotation;
- var br = $root.attachMovie(ln,hd + "bullet",hd,o);
- br.onEnterFrame = this.shootOEF;
- };
- pr.shootOEF = function()
- {
- var ecr = $root.Director.enemiesCon;
- if(this.hitTest(ecr) == true)
- {
- for(var e in ecr)
- {
- if(this.hitTest(ecr[e]) == true)
- {
- if(ecr[e]._xscale > 25)
- {
- $root.Director.hitEnemy(ecr[e],this.pwr);
- this.removeMovieClip();
- }
- }
- }
- }
- var xDis = this._gx - $middle.x;
- var yDis = this._gy - $middle.y;
- if(Math.abs(xDis) < 1 && Math.abs(yDis) < 1)
- {
- this.removeMovieClip();
- }
- this._x -= xDis * this.spd;
- this._y -= yDis * this.spd;
- this._xscale -= 20 * this.spd;
- this._yscale -= 20 * this.spd;
- this._alpha -= 20 * this.spd;
- updateAfterEvent();
- };
- pr.hitMe = function(p)
- {
- this.conf.eCurr -= p;
- this.conf.eCurr = this.min(this.conf.eCurr,this.conf.eMax);
- if(this.conf.eCurr <= 0)
- {
- this.killMe();
- $root.energy = 0;
- return undefined;
- }
- if(this.conf.eCurr < 65)
- {
- $root.Bonus.addToBG(0);
- }
- if(p > 0 && this.bonusWingman != undefined)
- {
- this.kill_wingman();
- }
- if(p > 0 && this.conf.bulletID > 0)
- {
- this.conf.bulletID--;
- }
- $root.energy = this.conf.eCurr;
- };
- pr.killMe = function()
- {
- if(this.bonusWingman != undefined)
- {
- this.kill_wingman();
- }
- var hd = $root.hD();
- var exr = $root.attachMovie("plr_explosion","plr_explosion" + hd,hd,{_xscale:70,_yscale:70});
- exr._gx = this.tgt.obj._gx;
- exr._gy = this.tgt.obj._gy;
- Key.removeListener(this.keyObj);
- delete this.keyObj;
- _root.scr = $root.score;
- $root.Director.enemiesCon.removeMovieClip();
- $root.Director.bonusesCon.removeMovieClip();
- this.tgt.removeMovieClip();
- gotoAndStop(95);
- };
- pr.extendEnergy = function(v)
- {
- this.conf.eMax += v;
- };
- pr.switchAmmo = function(t)
- {
- var cb = this.conf.bulletID;
- if(this.bullets[++cb] == undefined)
- {
- return undefined;
- }
- this.conf.bulletID = this.conf.bulletID + 1;
- };
- pr.generateShield = function()
- {
- this.tgt.obj[this.shieldLN].removeMovieClip();
- this.bonusShield = this.tgt.obj.attachMovie(this.shieldLN,this.shieldLN,this.tgt.obj.hD(),{init:getTimer(),dur:20000,hits:3,path:this});
- this.bonusShield.onEnterFrame = this.shieldOEF;
- };
- pr.destroyShield = function()
- {
- this.bonusShield.removeMovieClip();
- };
- pr.shieldOEF = function()
- {
- var ecr = $root.Director.enemiesCon;
- if(this.hitTest(ecr) == true)
- {
- for(var e in ecr)
- {
- if(this.hitTest(ecr[e]) == true)
- {
- $root.Director.destroyEnemy(ecr[e]);
- this.hits--;
- }
- }
- }
- if(this.hits <= 0)
- {
- this.path.destroyShield();
- }
- if(getTimer() - this.init > this.dur)
- {
- this.path.destroyShield();
- }
- };
- pr.generateWingmans = function()
- {
- this.extendEnergy(20);
- this.hitMe(-20);
- this.bonusWingman = this.tgt.attachMovie(this.wingmanLN,this.wingmanLN,this.tgt.hd(),{_y:230,path:this,hits:3});
- this.conf.bulletID = 900;
- };
- pr.kill_wingman = function()
- {
- this.conf.bulletID = 0;
- this.bonusWingman.removeMovieClip();
- };
-