JSFiddle - React, Tailwind, and code Playground

by kmendes

JavaScript

Game = function(){
    this.fps = 3;
}
    
Game.prototype.update = function(){
    console.log("update")   
}
    
Game.prototype.render= function(){
    console.log("render")   
}

    Game.prototype.run = function() {
        var currentGame = this;
        window.setInterval(function() {
            function runCommand(){
                var thisLoop = new Date().getTime();
                this.update();
                this.render();
                lastLoop = thisLoop;    
            }
            runCommand.call(currentGame);
          
        }, 1000 / this.fps);
    };

myGame = new Game();

myGame.run();