home *** CD-ROM | disk | FTP | other *** search
- class Position extends MovieClip
- {
- var pos_x = 0;
- var pos_y = 0;
- var pos_z = 0;
- var render_x = 0;
- var render_y = 0;
- var render_z = 0;
- var render_scale = 0;
- var render_depth = 0;
- var started = false;
- var missile = false;
- var boss = false;
- static var camera_x = 0;
- static var camera_y = 0;
- static var camera_z = 0;
- static var camera_depth = 300;
- static var center_x = 275;
- static var center_y = 200;
- static var center_y_offset = 100;
- static var draw_distance = 1500;
- function Position()
- {
- super();
- }
- function screenPosition()
- {
- this.render_z = this.pos_z - Position.camera_z;
- this.render_scale = Position.camera_depth / (this.render_z + Position.camera_depth);
- this.render_x = Position.center_x + (this.pos_x - Position.camera_x) * this.render_scale;
- this.render_y = Position.center_y + (this.pos_y - Position.camera_y + Position.center_y_offset) * this.render_scale;
- this.render_depth = Math.round(this.render_scale * 1000);
- if(this.pos_x == NaN || this.pos_y == NaN || this.pos_z == NaN)
- {
- this.removeMovieClip();
- }
- }
- function render()
- {
- this._x = this.render_x;
- this._y = this.render_y;
- this._xscale = this._yscale = 100 * this.render_scale;
- this.swapDepths(this.render_depth);
- this.blur(this.render_z);
- }
- function blur(p_y)
- {
- var _loc2_ = (p_y - 200) / 500;
- var _loc3_ = new flash.filters.BlurFilter(_loc2_,_loc2_,1);
- this.filters = [_loc3_];
- }
- function offScreen()
- {
- this._x = -200;
- this._y = -200;
- this._xscale = this._yscale = 5;
- }
- function drawToScreen()
- {
- this.screenPosition();
- 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;
- }
- else
- {
- this._alpha = 100;
- }
- this.render();
- }
- }
- else
- {
- this.offScreen();
- }
- }
- function cameraFollow(p_position)
- {
- var _loc1_ = undefined;
- if(p_position.boss)
- {
- _loc1_ = true;
- }
- else if(p_position.posZ > 25000)
- {
- _loc1_ = false;
- }
- else
- {
- _loc1_ = true;
- }
- if(_loc1_)
- {
- Position.camera_x += (p_position.posX - Position.camera_x) / 5;
- Position.camera_y += (p_position.posY - Position.camera_y) / 5;
- Position.camera_z = p_position.posZ;
- }
- }
- function distance2D(p_position)
- {
- var _loc3_ = this.posX - p_position.posX;
- var _loc2_ = this.posY - p_position.posY;
- return Math.sqrt(_loc3_ * _loc3_ + _loc2_ * _loc2_);
- }
- function distance3D(p_position)
- {
- var _loc4_ = this.posX - p_position.posX;
- var _loc3_ = this.posY - p_position.posY;
- var _loc2_ = this.posZ - p_position.posZ;
- return Math.sqrt(_loc4_ * _loc4_ + _loc3_ * _loc3_ + _loc2_ * _loc2_);
- }
- function angle2D(p_position)
- {
- var _loc3_ = p_position.posX - this.pos_x;
- var _loc2_ = this.pos_y - p_position.posY;
- return Math.atan2(_loc3_,_loc2_);
- }
- function angleToCamera()
- {
- var _loc3_ = Position.camera_x - this.pos_x;
- var _loc2_ = this.pos_y - Position.camera_y;
- return Math.atan2(_loc3_,_loc2_);
- }
- static function get cameraDepth()
- {
- return Position.camera_depth;
- }
- static function set cameraDepth(p_depth)
- {
- Position.camera_depth = p_depth;
- }
- function get posX()
- {
- return this.pos_x;
- }
- function set posX(p_x)
- {
- this.pos_x = p_x;
- }
- function get posY()
- {
- return this.pos_y;
- }
- function set posY(p_y)
- {
- this.pos_y = p_y;
- }
- function get posZ()
- {
- return this.pos_z;
- }
- function set posZ(p_z)
- {
- this.pos_z = p_z;
- }
- function get renderX()
- {
- return this.render_x;
- }
- function get renderY()
- {
- return this.render_y;
- }
- function get renderZ()
- {
- return this.render_y;
- }
- function get renderScale()
- {
- return this.render_scale;
- }
- function get renderDepth()
- {
- return this.render_depth;
- }
- function getShot()
- {
- }
- }
-