home *** CD-ROM | disk | FTP | other *** search
- Vaisseau = function()
- {
- this._xscale = 80;
- this._yscale = this._xscale;
- this._x = 275;
- this._y = 200;
- this.vitesse = 20;
- this.AnimPlayHaut = false;
- this.AnimPlayBas = false;
- this.vie = 1000;
- this.power = 100;
- this.maxTirdebase = 10;
- this.tempsDernierTirdebase = 0;
- this.delaiEntreDeuxTirdebase = 100;
- this.nbrBombe = 10;
- this.tempsDerniereBombe = 0;
- this.delaiEntreDeuxBombe = 500;
- this.mort = false;
- this.touche = -1;
- };
- Vaisseau.prototype = new MovieClip();
- Object.registerClass("VaisseauClip",Vaisseau);
- Vaisseau.prototype.blesse = function()
- {
- if(this.touche != -1)
- {
- if(_global.fotemps < this.touche + 10)
- {
- this._x += 5 * Math.cos(random(360) * 2 * 3.141592653589793 / 360);
- this._y -= 5 * Math.cos(random(360) * 2 * 3.141592653589793 / 360);
- this._alpha = random(100);
- }
- else
- {
- this.touche = -1;
- this._alpha = 100;
- }
- }
- };
- Vaisseau.prototype.onEnterFrame = function()
- {
- if(this.vie > 0)
- {
- this.move();
- this.afficheTrainee();
- this.protect();
- this.tirnormal();
- this.blesse();
- this.lachebombe();
- this.testTirEnnemi();
- }
- else if(this.mort == false)
- {
- this.gotoAndPlay("Mort");
- this.mort = true;
- }
- if(_global.level == 1)
- {
- this.afficheTraineeEau();
- }
- if(_global.level == 3)
- {
- this.afficheTraineeFumee();
- }
- };
- Vaisseau.prototype.testTirEnnemi = function()
- {
- var len = _global.tabTirEnnemi.length;
- var j = 0;
- while(j < len)
- {
- var i = _global.tabTirEnnemi[j];
- var clip = this._parent.tirEnnemiClip["tirEnnemi" + i];
- if(clip._currentframe < 3)
- {
- if(this.hitTest(clip))
- {
- if(!this.bouclier)
- {
- this._parent.score -= 100;
- this.vie -= clip.degats;
- this.touche = _global.fotemps;
- }
- clip.angle = 3.141592653589793;
- clip.play();
- }
- }
- j++;
- }
- };
- Vaisseau.prototype.move = function()
- {
- if(Key.isDown(37))
- {
- if(this._x > 40)
- {
- this._x -= this.vitesse;
- }
- }
- if(Key.isDown(39))
- {
- if(this._x < 550)
- {
- this._x += this.vitesse;
- }
- }
- if(Key.isDown(38))
- {
- if(this._y > 20)
- {
- this._y -= this.vitesse;
- }
- if(this.AnimPlayHaut == false)
- {
- this.gotoAndPlay("NormalHaut");
- }
- this.AnimPlayHaut = true;
- }
- else if(this.AnimPlayHaut == true)
- {
- this.gotoAndPlay("HautNormal");
- this.AnimPlayHaut = false;
- }
- if(Key.isDown(40))
- {
- if(this._y < 330)
- {
- this._y += this.vitesse;
- }
- if(this.AnimPlayBas == false)
- {
- this.gotoAndPlay("NormalBas");
- }
- this.AnimPlayBas = true;
- }
- else if(this.AnimPlayBas == true)
- {
- this.gotoAndPlay("HautNormal");
- this.AnimPlayBas = false;
- }
- };
- Vaisseau.prototype.afficheTrainee = function()
- {
- if(!this._parent.trainee)
- {
- this._parent.attachMovie("TraineeClip","trainee",_global.traineeDepth);
- }
- this._parent.trainee._x = this._x;
- this._parent.trainee._y = this._y;
- };
- Vaisseau.prototype.afficheTraineeEau = function()
- {
- if(this._y > 300)
- {
- if(!this._parent.traineeEau)
- {
- this._parent.attachMovie("TraineeEauClip","traineeEau",_global.traineeEauDepth);
- this._parent.traineeEau._y = 380;
- this._parent.traineeEau._alpha = 60;
- }
- this._parent.traineeEau._x = this._x;
- this._parent.traineeEau._height = this._y - 300;
- this._parent.traineeEau._width = 150;
- this._y -= random((this._y - 300) / 5);
- }
- else
- {
- this._parent.traineeEau.removeMovieClip();
- }
- };
- Vaisseau.prototype.afficheTraineeFumee = function()
- {
- if(this._y > 300)
- {
- if(!this._parent.traineeFumee)
- {
- this._parent.attachMovie("TraineeFumeeClip","traineeFumee",_global.traineeEauDepth);
- this._parent.traineeFumee._y = 380;
- this._parent.traineeFumee._alpha = 60;
- }
- this._parent.traineeFumee._x = this._x;
- this._parent.traineeFumee._height = this._y - 300;
- this._parent.traineeFumee._width = 150;
- this._y -= random((this._y - 300) / 5);
- }
- else
- {
- this._parent.traineeFumee.removeMovieClip();
- }
- };
- Vaisseau.prototype.protect = function()
- {
- if(Key.isDown(66) && this.power > 0)
- {
- if(!this.bouclier)
- {
- this.attachMovie("BouclierClip","bouclier",_global.bouclierDepth);
- this.bouclier._x = -20;
- this.bouclier._y = -10;
- }
- this.power--;
- }
- else
- {
- this.bouclier.removeMovieClip();
- }
- };
- Vaisseau.prototype.tirnormal = function()
- {
- if(Key.isDown(32))
- {
- if(getTimer() > this.tempsDuDernierTirdebase + this.delaiEntreDeuxTirdebase)
- {
- this.tempsDuDernierTirdebase = getTimer();
- var i = 0;
- while(this._parent.tirVaisseauClip["tirVaisseau" + i])
- {
- i++;
- if(i == _global.maxTirVaisseau)
- {
- return 0;
- }
- }
- this._parent.tirVaisseauClip.attachMovie("TirdebaseRClip","tirVaisseau" + i,_global.tirVaisseauDepth + i);
- var clip = this._parent.tirVaisseauClip["tirVaisseau" + i];
- clip.angle = 0;
- clip._x = this._x + 5;
- clip._y = this._y;
- }
- }
- };
- Vaisseau.prototype.lachebombe = function()
- {
- if(Key.isDown(86))
- {
- if(getTimer() > this.tempsDerniereBombe + this.delaiEntreDeuxBombe && this.nbrBombe > 0)
- {
- this.tempsDerniereBombe = getTimer();
- var i = 0;
- while(this._parent.tirVaisseauClip["tirVaisseau" + i])
- {
- i++;
- if(i == _global.maxTirVaisseau)
- {
- return 0;
- }
- }
- this._parent.tirVaisseauClip.attachMovie("BombeClip","tirVaisseau" + i,_global.tirVaisseauDepth + i);
- var clip = this._parent.tirVaisseauClip["tirVaisseau" + i];
- clip._x = this._x - 5;
- clip._y = this._y;
- clip.num = i;
- this.nbrBombe--;
- }
- }
- };
-