home *** CD-ROM | disk | FTP | other *** search
- Ennemi = function()
- {
- super();
- this.touche = false;
- this.saveToucheTime = -1000;
- this.vie = 100;
- };
- Ennemi.prototype = new Sprite();
- Ennemi.prototype.onEnterFrame = function()
- {
- super.onEnterFrame();
- if(this.vie > 0)
- {
- this.tirnormal();
- this.testTirVaisseau();
- this.clignote();
- }
- };
- Ennemi.prototype.testTirVaisseau = function()
- {
- var len = _global.tabTirVaisseau.length;
- var j = 0;
- while(j < len)
- {
- var i = _global.tabTirVaisseau[j];
- clip = this._parent.tirVaisseauClip["tirVaisseau" + i];
- if(clip.touche != true)
- {
- if(this.hitTest(clip._x,clip._y,false))
- {
- clip.touche = true;
- this.vie -= clip.degats;
- this._parent.score += 300;
- if(this.vie < 1)
- {
- this.vitesse = 30;
- this.trajectoire = "droite";
- this.angle = 3.141592653589793;
- this._alpha = 100;
- this.saveToucheTime = -5000;
- this.play();
- }
- else
- {
- this.touche = true;
- }
- clip.angle = 3.141592653589793;
- clip.play();
- }
- }
- j++;
- }
- };
- Ennemi.prototype.clignote = function()
- {
- if(this.touche == true)
- {
- this.saveToucheTime = getTimer();
- }
- if(getTimer() < this.saveToucheTime + 500)
- {
- this._alpha = 50 + 50 * Math.cos(this.tmp++);
- this.touche = false;
- }
- else
- {
- this._alpha = 100;
- }
- };
- Ennemi.prototype.chercheTirLibre = function()
- {
- var i = 0;
- while(this._parent.tirEnnemiClip["tirEnnemi" + i])
- {
- i++;
- if(i == _global.maxTirEnnemi)
- {
- return -1;
- }
- }
- return i;
- };
-