home *** CD-ROM | disk | FTP | other *** search
/ 600 Games / 600games.iso / Acao / midnightstrike1.swf / scripts / frame_6 / DoAction_3.as < prev    next >
Encoding:
Text File  |  2007-04-02  |  2.9 KB  |  118 lines

  1. noBgScroll = false;
  2. CCam = function(mc)
  3. {
  4.    this.mc = mc;
  5.    this.offset = new com.neodelight.std.Vector(30,200);
  6.    this.optimum = new com.neodelight.std.Vector(0,0);
  7.    this.a = new com.neodelight.std.Vector(2,2);
  8.    this.f = new com.neodelight.std.Vector(0.5,0.5);
  9.    this.t = new com.neodelight.std.Vector(0,0);
  10.    this.shaking = 0;
  11.    this.init();
  12. };
  13. CCam.prototype.init = function()
  14. {
  15.    this.v = new com.neodelight.std.Vector(0,0);
  16.    this.duckCount = 0;
  17.    this.move(true);
  18.    this.minY = this.mc._y;
  19.    this.noScroll = false;
  20. };
  21. CCam.prototype.shake = function(power)
  22. {
  23.    this.shaking = Math.max(this.shaking,10);
  24. };
  25. CCam.prototype.move = function(init)
  26. {
  27.    _root.player = _global.game.player.sprite;
  28.    this.optimum.y = this.offset.y - _root.player.mc._y;
  29.    if(_root.player.ducked)
  30.    {
  31.       this.optimum.y += _global.plSprite.duckOffY;
  32.    }
  33.    if(_root.player.ducked && Math.abs(_root.player.v.x) <= 0.01 && !com.neodelight.std.Inputs.isPressed("shoot"))
  34.    {
  35.       this.duckCount = Math.min(this.duckCount + 5,230);
  36.    }
  37.    else
  38.    {
  39.       this.duckCount = Math.max(0,this.duckCount - 10);
  40.       if(this.duckCount < 120)
  41.       {
  42.          this.duckCount = 0;
  43.       }
  44.    }
  45.    this.optimum.y -= Math.max(0,this.duckCount - 120);
  46.    this.optimum.x = this.offset.x - _root.player.mc._x;
  47.    var _loc11_ = _root.player.mc._x + this.mc._x;
  48.    if(init)
  49.    {
  50.       this.mc._y = this.optimum.y;
  51.       this.mc._x = this.optimum.x;
  52.    }
  53.    var _loc4_ = this.mc._y - this.optimum.y;
  54.    var _loc5_ = this.mc._x + _root.player.mc._x;
  55.    this.t.y = this.mc._y;
  56.    var _loc7_ = 20;
  57.    var _loc10_ = 0.2;
  58.    var _loc8_ = 90;
  59.    var _loc9_ = 0.2;
  60.    if(_loc4_ < -1 * _loc8_)
  61.    {
  62.       if(_loc4_ < _loc8_ * -2)
  63.       {
  64.          _loc9_ *= 2;
  65.       }
  66.       _loc4_ += _loc8_;
  67.       this.t.y -= _loc4_ * _loc9_;
  68.    }
  69.    else if(_loc4_ > _loc7_)
  70.    {
  71.       _loc10_ *= _loc4_ / _loc7_;
  72.       _loc4_ -= _loc7_;
  73.       this.t.y -= _loc4_ * _loc10_;
  74.    }
  75.    if(!init)
  76.    {
  77.       this.t.x = this.mc._x;
  78.       this.spaceL = 250;
  79.       this.spaceR = 300;
  80.       if(_loc5_ < this.spaceL)
  81.       {
  82.          this.t.x += this.spaceL - _loc5_;
  83.       }
  84.       else if(_loc5_ > this.spaceR)
  85.       {
  86.          this.t.x -= _loc5_ - this.spaceR;
  87.       }
  88.       if(!this.noScroll || init)
  89.       {
  90.          this.mc._x = this.t.x;
  91.       }
  92.    }
  93.    if(Math.abs(this.t.y - this.mc._y) > 1 || init)
  94.    {
  95.       if(!this.noScroll || init)
  96.       {
  97.          this.mc._y = this.t.y;
  98.       }
  99.       if(_root.noBgScroll)
  100.       {
  101.          if(init)
  102.          {
  103.             _root.bg0._y = 172.5;
  104.          }
  105.       }
  106.       else
  107.       {
  108.          _root.bg0._y = 1000 + this.mc._y * 1.2;
  109.       }
  110.    }
  111.    if(this.shaking > 0)
  112.    {
  113.       this.mc._x += (Math.random() - 0.5) * this.shaking * 1;
  114.       this.mc._y += (Math.random() - 0.5) * this.shaking * 1;
  115.       this.shaking = this.shaking - 1;
  116.    }
  117. };
  118.