Hello,
What is the best method for frame based animations/games to get accurate FPS?
The two methods I've tried are:
setInterval(tick, 1000 / 30);
This works well but if the tick() function ever takes longer than the interval time they can begin to stack up on one another.
The second method I've tried is setTimeout from within the tick() function. The only problem I have here is the FPS drop a lot as each frame is tick() excuse time + frame timeout.
function tick() {
setTimeout(tick, 1000 / 30);
}
tick();
Are there any other methods I can look at, like using the system time to decide when to next call tick()?
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Hello,
What is the best method for frame based animations/games to get accurate FPS?
The two methods I've tried are:
This works well but if the tick() function ever takes longer than the interval time they can begin to stack up on one another.
The second method I've tried is setTimeout from within the tick() function. The only problem I have here is the FPS drop a lot as each frame is tick() excuse time + frame timeout.
Are there any other methods I can look at, like using the system time to decide when to next call tick()?