home *** CD-ROM | disk | FTP | other *** search
- class Rock extends Position
- {
- var speed_x;
- var speed_y;
- var target_clip;
- var onEnterFrame;
- var speed_z = -5;
- var air_resistance_factor = 0.05;
- var range = 80;
- var health = 100;
- function Rock()
- {
- super();
- this.gotoAndStop(Math.ceil(Math.random() * 6));
- this.speed_x = 4 + Math.random() * 15;
- this.speed_y = -8 + Math.random() * 15;
- }
- function launch(p_launcher)
- {
- this.posX = p_launcher.posX - 400;
- this.posY = p_launcher.posY + Math.random() * 50 - 25;
- this.posZ = p_launcher.posZ;
- var _loc4_ = p_launcher._y - 230;
- this.speed_y -= _loc4_ / 5;
- var _loc5_ = p_launcher._x - 275;
- this.speed_x -= _loc5_ / 5;
- this.target_clip = this._parent.player;
- this.onEnterFrame = function()
- {
- if(!_global.game_paused)
- {
- this._rotation += 5;
- this.moveX();
- this.moveY();
- this.moveZ();
- if(this.checkTarget())
- {
- this.target_clip.getRocked();
- }
- if(this.render_z < -150 || this._y < -50 || this._y > 450 || this._x < -50 || this._x > 600)
- {
- this.removeMovieClip();
- }
- }
- };
- this.drawToScreen();
- return this;
- }
- function checkTarget()
- {
- return this.distance3D(this.target_clip) < this.range;
- }
- function drawToScreen(p_player)
- {
- this.screenPosition(p_player);
- if(this.render_z >= -300 && this.render_x > -50 - this._width && this.render_x < 600 + this._width && this.render_y > -50 - this._height && this.render_y < 450 + this._height)
- {
- if(this.render_z > Position.draw_distance)
- {
- this.offScreen();
- }
- else
- {
- if(this.render_z > Position.draw_distance - 200)
- {
- this._alpha = 100 - (this.render_z - Position.draw_distance + 200) / 2;
- }
- this.render();
- }
- }
- else
- {
- this.offScreen();
- }
- }
- 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;
- }
- }
-