home *** CD-ROM | disk | FTP | other *** search
/ 600 Games / 600games.iso / Nave / AitchuTheAbduction.swf / scripts / frame_9 / DoAction.as
Encoding:
Text File  |  2005-11-10  |  1.3 KB  |  54 lines

  1. Sprite = function()
  2. {
  3.    this.vitesse = 0;
  4.    this.trajectoire = "nothing";
  5. };
  6. Sprite.prototype = new MovieClip();
  7. Sprite.prototype.onEnterFrame = function()
  8. {
  9.    this.move();
  10. };
  11. Sprite.prototype.move = function()
  12. {
  13.    switch(this.trajectoire)
  14.    {
  15.       case "sinus":
  16.          this.moveSinus();
  17.          break;
  18.       case "cercle":
  19.          this.moveCercle();
  20.          break;
  21.       case "droite":
  22.          this.moveDroite();
  23.          break;
  24.       case "atan":
  25.          this.moveATan();
  26.    }
  27.    if(this._x < -50)
  28.    {
  29.       this.removeMovieClip();
  30.    }
  31. };
  32. Sprite.prototype.moveDroite = function()
  33. {
  34.    this._x += this.vitesse * Math.cos(this.angle);
  35.    this._y += this.vitesse * Math.sin(this.angle);
  36. };
  37. Sprite.prototype.moveCercle = function()
  38. {
  39.    this.savex += this.vitesse * -1;
  40.    this.savey += this.vitesse * 1.2246063538223773e-16;
  41.    this._x = this.savex + this.rayonx * Math.cos(this.angle += 0.1);
  42.    this._y = this.savey + this.rayony * Math.sin(this.angle);
  43. };
  44. Sprite.prototype.moveSinus = function()
  45. {
  46.    this._x += this.vitesse * Math.cos(this.angle);
  47.    this._y = this.savey + Math.sin(this._x * 3.141592653589793 / 180) * 50;
  48. };
  49. Sprite.prototype.moveATan = function()
  50. {
  51.    this._x += this.vitesse * Math.cos(this.angle);
  52.    this._y = this.savey + Math.atan((this._x - 580) / this.largeur) * this.hauteur;
  53. };
  54.