Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fine tune framerate balancing behavior to avoid exposing game code to…

… extremely long frame delays.
  • Loading branch information...
commit f2d55669cce320c621d48c7db673be2b90d2d086 1 parent 1fdb4b6
@kg kg authored
Showing with 8 additions and 5 deletions.
  1. +8 −5 Libraries/JSIL.XNACore.js
View
13 Libraries/JSIL.XNACore.js
@@ -2601,8 +2601,10 @@ JSIL.ImplementExternals("Microsoft.Xna.Framework.Game", function ($) {
$.RawMethod(false, "_Step", function () {
var now = this._GetNow();
+ var frameDelay = this.targetElapsedTime.get_TotalMilliseconds();
+
if (this._lastFrame === 0) {
- var elapsed = 0;
+ var elapsed = frameDelay;
var total = 0;
this._started = now;
this._lastSecond = now;
@@ -2630,14 +2632,12 @@ JSIL.ImplementExternals("Microsoft.Xna.Framework.Game", function ($) {
elapsed = 0;
}
- var frameDelay = this.targetElapsedTime.get_TotalMilliseconds();
-
this._lastFrame = now;
this._nextFrame = now + frameDelay;
var millisecondInTicks = 10000;
- var maxElapsedTimeMs = 500;
- var longFrame = frameDelay * 2;
+ var maxElapsedTimeMs = 150;
+ var longFrame = frameDelay * 3;
var failed = true;
try {
@@ -2679,6 +2679,9 @@ JSIL.ImplementExternals("Microsoft.Xna.Framework.Game", function ($) {
this._extraTime = 0;
this.suppressFrameskip = false;
+ if (elapsed > maxElapsedTimeMs)
+ elapsed = maxElapsedTimeMs;
+
this._gameTime.elapsedGameTime._ticks = (elapsed * millisecondInTicks);
this._gameTime.totalGameTime._ticks += (elapsed * millisecondInTicks);
Please sign in to comment.
Something went wrong with that request. Please try again.