home *** CD-ROM | disk | FTP | other *** search
/ 600 Games / 600games.iso / Nave / rocket_rush.swf / scripts / __Packages / Barrel.as < prev    next >
Encoding:
Text File  |  2007-03-20  |  1.9 KB  |  80 lines

  1. class Barrel extends Position
  2. {
  3.    var accel_y;
  4.    var side_x;
  5.    var target_clip;
  6.    var onEnterFrame;
  7.    var speed_x = 0;
  8.    var speed_y = -10;
  9.    var speed_z = 0;
  10.    var air_resistance_factor = 0.05;
  11.    var range = 70;
  12.    var missile = true;
  13.    function Barrel()
  14.    {
  15.       super();
  16.       this.accel_y = Math.random();
  17.       this.speed_y = -15 + Math.random() * 10;
  18.       this.side_x = Math.random() - 0.5;
  19.    }
  20.    function launch(p_launcher, p_x_diff)
  21.    {
  22.       this.posX = p_launcher.posX + p_x_diff;
  23.       this.posY = p_launcher.posY - 100;
  24.       this.posZ = p_launcher.posZ;
  25.       var _loc4_ = p_launcher._x - 275;
  26.       this.speed_x = (- _loc4_) / 8 + this.side_x * p_x_diff / 10;
  27.       this.target_clip = this._parent.player;
  28.       this.onEnterFrame = function()
  29.       {
  30.          if(!_global.game_paused)
  31.          {
  32.             this.accelerateY(0.5 + this.accel_y);
  33.             this.moveX();
  34.             this.moveY();
  35.             this.moveZ();
  36.             if(this.checkTarget())
  37.             {
  38.                this.target_clip.getBarreled();
  39.             }
  40.             if(this.render_z < -150)
  41.             {
  42.                this.removeMovieClip();
  43.             }
  44.          }
  45.       };
  46.       this.drawToScreen();
  47.       return this;
  48.    }
  49.    function checkTarget()
  50.    {
  51.       return this.distance3D(this.target_clip) < this.range;
  52.    }
  53.    function moveX()
  54.    {
  55.       this.pos_x += this.speed_x;
  56.    }
  57.    function moveY()
  58.    {
  59.       this.pos_y += this.speed_y;
  60.    }
  61.    function moveZ()
  62.    {
  63.       this.pos_z += this.speed_z;
  64.    }
  65.    function accelerateX(p_a)
  66.    {
  67.       this.speed_x += p_a;
  68.       this.speed_x -= this.speed_x * this.air_resistance_factor;
  69.    }
  70.    function accelerateY(p_a)
  71.    {
  72.       this.speed_y += p_a;
  73.       this.speed_y -= this.speed_y * this.air_resistance_factor;
  74.    }
  75.    function accelerateZ(p_a)
  76.    {
  77.       this.speed_z += p_a;
  78.    }
  79. }
  80.