home *** CD-ROM | disk | FTP | other *** search
- class Position extends MovieClip
- {
- var depth_count;
- var offscreen;
- var pos_x;
- var pos_y;
- var radius;
- var nx;
- var ny;
- var environment;
- var z;
- var zs;
- function Position()
- {
- super();
- this.depth_count = 0;
- this.offscreen = false;
- this.pos_x = 0;
- this.pos_y = 0;
- this.radius = 20;
- this.nx = 0;
- this.ny = 0;
- }
- function distanceTo(p_x, p_y)
- {
- var _loc3_ = this.pos_x - p_x;
- var _loc2_ = this.pos_y - p_y;
- return Math.sqrt(_loc3_ * _loc3_ + _loc2_ * _loc2_);
- }
- function angleTo(p_x, p_y)
- {
- var _loc3_ = p_x - this.pos_x;
- var _loc4_ = this.pos_y - p_y;
- var _loc2_ = Math.atan2(_loc3_,_loc4_);
- return _loc2_;
- }
- function positive(p_n)
- {
- var _loc1_ = p_n;
- if(_loc1_ < 0)
- {
- _loc1_ *= -1;
- }
- return _loc1_;
- }
- function blur(p_y)
- {
- var _loc2_ = 3 - (p_y - 160) / 15;
- var _loc3_ = new flash.filters.BlurFilter(_loc2_,_loc2_,1);
- this.filters = [_loc3_];
- }
- function fade()
- {
- if(this._y > 280)
- {
- this._alpha = 100 - (this.ny - 300) * 5;
- }
- else
- {
- this._alpha = 100;
- }
- }
- function posit(p_env)
- {
- this.environment = p_env;
- this.z = -300 - this.pos_y + p_env.pos_y;
- this.zs = p_env.camera_depth / (this.z + p_env.camera_depth);
- this.nx = 275 + (- p_env.pos_x + this.pos_x) * this.zs;
- this.ny = 100 + p_env.camera_offset * this.zs;
- }
- function depth()
- {
- this.swapDepths(this.environment.level_list[this._name]);
- }
- function render(p_env)
- {
- this.posit(p_env);
- if(this.nx < 650 && this.nx > -100 && this.z > -350)
- {
- this.offscreen = false;
- this._x = this.nx;
- this._y = this.ny;
- this._xscale = this._yscale = 40 * this.zs;
- this.depth();
- this.blur(this.ny);
- this.fade();
- }
- else if(this.offscreen == false)
- {
- this.offscreen = true;
- this._x = -200;
- this._y = -200;
- }
- }
- function collide(p_new_x, p_new_y)
- {
- var _loc3_ = p_new_x;
- var _loc2_ = p_new_y;
- if(this.radius > 0)
- {
- if(this.distanceTo(_loc3_,_loc2_) < this.radius)
- {
- var _loc4_ = this.angleTo(_loc3_,_loc2_);
- _loc3_ = this.pos_x + Math.sin(_loc4_) * this.radius;
- _loc2_ = this.pos_y - Math.cos(_loc4_) * this.radius;
- }
- }
- return [_loc3_,_loc2_];
- }
- }
-