home *** CD-ROM | disk | FTP | other *** search
/ Champak 48 / cdrom_image.iso / Games / alex_trax.swf / scripts / __Packages / com / neodelight / std / Timer.as < prev    next >
Encoding:
Text File  |  2007-10-01  |  632 b   |  22 lines

  1. class com.neodelight.std.Timer
  2. {
  3.    var config;
  4.    var t;
  5.    var msPerFrame;
  6.    var smoothing;
  7.    function Timer(config)
  8.    {
  9.       _global.dt = 1;
  10.       this.config = config;
  11.       this.t = getTimer();
  12.       this.msPerFrame = !this.config.timerFps ? 33.33333333333333 : 1000 / this.config.timerFps;
  13.       this.smoothing = Math.min(1,Math.max(0,com.neodelight.std.XMath.toNumber(this.config.timerSmoothing)));
  14.    }
  15.    function update()
  16.    {
  17.       var _loc3_ = getTimer();
  18.       _global.dt = this.smoothing * _global.dt + (1 - this.smoothing) * (_loc3_ - this.t) / this.msPerFrame;
  19.       this.t = _loc3_;
  20.    }
  21. }
  22.