Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update _GameMaker.js #391

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 14 additions & 19 deletions scripts/_GameMaker.js
Original file line number Diff line number Diff line change
Expand Up @@ -2292,33 +2292,28 @@ function GameMaker_Tick()
lastfpstime = g_CurrentTime;
}
newfps++;

// schedule next frame:
// this might be best done after if(!Run_Paused) block,
// but then an exception would halt the game loop.
var nextFrameAt = g_FrameStartTime + 1000 / TargetSpeed;
var now = Date.now();
var delay = g_FrameStartTime + 1000 / TargetSpeed - now;
if (delay < 0) delay = 0;
g_FrameStartTime = now + delay;
if (delay > 4) {
// 4ms is the general minimum timeout time as per spec,
// https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#timers
setTimeout(function() {
if (window.yyRequestAnimationFrame) {
window.yyRequestAnimationFrame(animate);
} else {
// Don't re-enter, that would be bad.
//animate();
}
}, delay);
} else {
var now = g_CurrentTime;
var delay = nextFrameAt - now;
if (delay < 0) {
delay = 0;
}

if (delay <= 4) {
g_FrameStartTime +=delay;
if (window.yyRequestAnimationFrame) {
window.yyRequestAnimationFrame(animate);
} else {
window.postMessage("yyRequestAnimationFrame", "*");
} else{

}
} else{
g_FrameStartTime -=delay;
window.postMessage("yyRequestAnimationFrame", "*");
}


if (!Run_Paused)
{
Expand Down