Advertisement
Guest User

Untitled

a guest
Apr 24th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. if(!Engine){
  2.     throw new Error("Engine is not loaded");
  3. }
  4.  
  5. Engine.DebugEngine = (()=>{
  6.    
  7.     class DebugEngine extends Engine{
  8.         constructor(){
  9.             super();
  10.             this._frames = 0;
  11.             this._fpsClock = new Engine.StopWatch();
  12.         }
  13.         Update(){
  14.             let ms = this._fpsClock.ElapsedMilliseconds;
  15.             let s = ms/1000;
  16.             if(this._fpsClock.ElapsedMilliseconds >= 1000){
  17.                 console.log("DebugEngine:::FPS = ", this._frames/s);
  18.                 this._frames = 0;
  19.                 this._fpsClock.Restart();
  20.             }
  21.             this._frames++;
  22.             super.Update();
  23.         }
  24.         Run(){
  25.             super.Run();
  26.             this._fpsClock.Start();
  27.         }
  28.         Stop(){
  29.             super.Stop();
  30.             this._fpsClock.Stop();
  31.             this._fpsClock.Reset();
  32.         }
  33.     }
  34.    
  35.    
  36.     return DebugEngine;
  37.    
  38. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement