Sagot :
Réponse :
je sais pas si il marche complétement mais j'ai fais ça:
var game = new Game(),
render = new Render(game);
function run() {
var now, last = timestamp(), dt = 0, gdt = 0, rdt = 0;
function frame() {
now = timestamp();
dt = Math.min(1, (now - last) / 1000);
gdt = gdt + dt;
while (gdt > game.step) {
gdt = gdt - game.step;
game.update();
}
rdt = rdt + dt;
if (rdt > render.step) {
rdt = rdt - render.step;
render.update();
}
stats.update();
last = now;
requestAnimationFrame(frame, render.canvas);
}
load(function(sprites) {
render.reset(sprites); // reset the canvas renderer with the loaded sprites <IMG>
game.reset(); // reset the game
frame(); // ... and start the first frame !
});
};