home *** CD-ROM | disk | FTP | other *** search
- noBgScroll = false;
- CCam = function(mc)
- {
- this.mc = mc;
- this.offset = new com.neodelight.std.Vector(30,200);
- this.optimum = new com.neodelight.std.Vector(0,0);
- this.a = new com.neodelight.std.Vector(2,2);
- this.f = new com.neodelight.std.Vector(0.5,0.5);
- this.t = new com.neodelight.std.Vector(0,0);
- this.shaking = 0;
- this.init();
- };
- CCam.prototype.init = function()
- {
- this.v = new com.neodelight.std.Vector(0,0);
- this.duckCount = 0;
- this.move(true);
- this.minY = this.mc._y;
- this.noScroll = false;
- };
- CCam.prototype.shake = function(power)
- {
- this.shaking = Math.max(this.shaking,10);
- };
- CCam.prototype.move = function(init)
- {
- _root.player = _global.game.player.sprite;
- this.optimum.y = this.offset.y - _root.player.mc._y;
- if(_root.player.ducked)
- {
- this.optimum.y += _global.plSprite.duckOffY;
- }
- if(_root.player.ducked && Math.abs(_root.player.v.x) <= 0.01 && !com.neodelight.std.Inputs.isPressed("shoot"))
- {
- this.duckCount = Math.min(this.duckCount + 5,230);
- }
- else
- {
- this.duckCount = Math.max(0,this.duckCount - 10);
- if(this.duckCount < 120)
- {
- this.duckCount = 0;
- }
- }
- this.optimum.y -= Math.max(0,this.duckCount - 120);
- this.optimum.x = this.offset.x - _root.player.mc._x;
- var _loc11_ = _root.player.mc._x + this.mc._x;
- if(init)
- {
- this.mc._y = this.optimum.y;
- this.mc._x = this.optimum.x;
- }
- var _loc4_ = this.mc._y - this.optimum.y;
- var _loc5_ = this.mc._x + _root.player.mc._x;
- this.t.y = this.mc._y;
- var _loc7_ = 20;
- var _loc10_ = 0.2;
- var _loc8_ = 90;
- var _loc9_ = 0.2;
- if(_loc4_ < -1 * _loc8_)
- {
- if(_loc4_ < _loc8_ * -2)
- {
- _loc9_ *= 2;
- }
- _loc4_ += _loc8_;
- this.t.y -= _loc4_ * _loc9_;
- }
- else if(_loc4_ > _loc7_)
- {
- _loc10_ *= _loc4_ / _loc7_;
- _loc4_ -= _loc7_;
- this.t.y -= _loc4_ * _loc10_;
- }
- if(!init)
- {
- this.t.x = this.mc._x;
- this.spaceL = 250;
- this.spaceR = 300;
- if(_loc5_ < this.spaceL)
- {
- this.t.x += this.spaceL - _loc5_;
- }
- else if(_loc5_ > this.spaceR)
- {
- this.t.x -= _loc5_ - this.spaceR;
- }
- if(!this.noScroll || init)
- {
- this.mc._x = this.t.x;
- }
- }
- if(Math.abs(this.t.y - this.mc._y) > 1 || init)
- {
- if(!this.noScroll || init)
- {
- this.mc._y = this.t.y;
- }
- if(_root.noBgScroll)
- {
- if(init)
- {
- _root.bg0._y = 172.5;
- }
- }
- else
- {
- _root.bg0._y = 1000 + this.mc._y * 1.2;
- }
- }
- if(this.shaking > 0)
- {
- this.mc._x += (Math.random() - 0.5) * this.shaking * 1;
- this.mc._y += (Math.random() - 0.5) * this.shaking * 1;
- this.shaking = this.shaking - 1;
- }
- };
-