home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Champak 108
/
jogo-disk-108.iso
/
Games
/
Rabbit_Rivalry.swf
/
scripts
/
__Packages
/
smashing
/
IntervalEngine.as
next >
Wrap
Text File
|
2010-05-15
|
2KB
|
66 lines
class smashing.IntervalEngine
{
var _MAX_TIMEDIFF = 0.005;
var _MIN_FPS = 5;
var _MAX_FRAMETIME = 1 / smashing.IntervalEngine.prototype._MIN_FPS;
var _lel = 0.2;
var _FPS = 0;
function IntervalEngine(update_object, update_function)
{
this._uo = update_object;
this._uf = update_function;
}
function startFlat(FPS)
{
this._FPS = FPS;
this._update_interval = 1 / FPS;
this._last_update = getTimer() * 0.001;
this._i = setInterval(this,"_flat_step",0);
}
function startFlex()
{
this._last_update = getTimer() * 0.001;
this._i = setInterval(this,"_flex_step",0);
}
function startFast()
{
this._last_update = getTimer();
this._i = setInterval(this,"_fast_step",10);
}
function reset(Void)
{
if(this._i != undefined)
{
clearInterval(this._i);
}
this._ft = 0;
this._last_update = getTimer() * 0.001;
this._lel = this._MAX_FRAMETIME / 2;
}
function _flex_step(Void)
{
this._el = Math.min(this._MAX_FRAMETIME,- this._last_update + (this._last_update = getTimer() * 0.001));
this._lel -= Math.max(- this._MAX_TIMEDIFF,Math.min(this._MAX_TIMEDIFF,this._lel - this._el));
this._uo[this._uf](this._lel);
}
function _flat_step(Void)
{
this._ft += - this._last_update + (this._last_update = getTimer() * 0.001);
if(this._ft < this._update_interval)
{
return undefined;
}
this._uo[this._uf](this._ft);
this._ft = 0;
}
function _fast_step(Void)
{
this._el = - this._last_update + (this._last_update = getTimer());
this._uo[this._uf](this._el * 0.001);
}
function clear()
{
clearInterval(this._i);
}
}