Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Run(){
- if(this._timerID > -1){
- return;
- }
- let scope = this;
- let thisTimerId = -1;
- let time = 1000 / (this._fps);
- this._gameClock.Start();
- let step = (timestamp)=>{
- if(thisTimerId !== scope._timerID){
- return;
- }
- let ms = this._gameClock.ElapsedMilliseconds;
- if(ms >= time){
- this.Update();
- this.Draw();
- this._gameClock.Restart();
- let newEs = (ms % time);
- this._gameClock._elapsedTime = newEs;
- }
- window.requestAnimationFrame(step);
- };
- this._timerID = window.requestAnimationFrame(step);
- thisTimerId = this._timerID;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement