home *** CD-ROM | disk | FTP | other *** search
- class Barrel extends Position
- {
- var accel_y;
- var side_x;
- var target_clip;
- var onEnterFrame;
- var speed_x = 0;
- var speed_y = -10;
- var speed_z = 0;
- var air_resistance_factor = 0.05;
- var range = 70;
- var missile = true;
- function Barrel()
- {
- super();
- this.accel_y = Math.random();
- this.speed_y = -15 + Math.random() * 10;
- this.side_x = Math.random() - 0.5;
- }
- function launch(p_launcher, p_x_diff)
- {
- this.posX = p_launcher.posX + p_x_diff;
- this.posY = p_launcher.posY - 100;
- this.posZ = p_launcher.posZ;
- var _loc4_ = p_launcher._x - 275;
- this.speed_x = (- _loc4_) / 8 + this.side_x * p_x_diff / 10;
- this.target_clip = this._parent.player;
- this.onEnterFrame = function()
- {
- if(!_global.game_paused)
- {
- this.accelerateY(0.5 + this.accel_y);
- this.moveX();
- this.moveY();
- this.moveZ();
- if(this.checkTarget())
- {
- this.target_clip.getBarreled();
- }
- if(this.render_z < -150)
- {
- this.removeMovieClip();
- }
- }
- };
- this.drawToScreen();
- return this;
- }
- function checkTarget()
- {
- return this.distance3D(this.target_clip) < this.range;
- }
- function moveX()
- {
- this.pos_x += this.speed_x;
- }
- function moveY()
- {
- this.pos_y += this.speed_y;
- }
- function moveZ()
- {
- this.pos_z += this.speed_z;
- }
- function accelerateX(p_a)
- {
- this.speed_x += p_a;
- this.speed_x -= this.speed_x * this.air_resistance_factor;
- }
- function accelerateY(p_a)
- {
- this.speed_y += p_a;
- this.speed_y -= this.speed_y * this.air_resistance_factor;
- }
- function accelerateZ(p_a)
- {
- this.speed_z += p_a;
- }
- }
-