Advertisement
Guest User

Untitled

a guest
Apr 24th, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.         Run(){
  2.             if(this._timerID > -1){
  3.                 return;
  4.             }
  5.             let scope = this;
  6.             let thisTimerId = -1;
  7.             let time = 1000 / (this._fps);
  8.             this._gameClock.Start();
  9.             let step = (timestamp)=>{
  10.                 if(thisTimerId !== scope._timerID){
  11.                     return;
  12.                 }
  13.                 let ms = this._gameClock.ElapsedMilliseconds;
  14.                 if(ms >= time){
  15.                     this.Update();
  16.                     this.Draw();
  17.                     this._gameClock.Restart();
  18.                     let newEs = (ms % time);
  19.                     this._gameClock._elapsedTime = newEs;
  20.                 }
  21.                 window.requestAnimationFrame(step);
  22.             };
  23.             this._timerID = window.requestAnimationFrame(step);
  24.             thisTimerId = this._timerID;
  25.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement