Browse Source

minor text fixes

master
mortie 6 years ago
parent
commit
f86469cc25
1 changed files with 10 additions and 6 deletions
  1. 10
    6
      js/Level.js

+ 10
- 6
js/Level.js View File

@@ -6,7 +6,7 @@ export default class Level {
this.ctx = canvas.getContext("2d");
this.lastTime = null;
this.raf = null;
this.minPhysFPS = 30;
this.minPhysFPS = 20;
this.minFPS = 5;
this.backgroundColor = "#87CEFA";

@@ -87,17 +87,21 @@ export default class Level {
// We accept really low FPSes,
// but if the FPS gets too low, we want to run multiple
// physics steps in the frame.
let physdt = dt;
let nSteps = 1;
while (1 / dt < this.minPhysFPS) {
dt /= 2;
while (1 / physdt < this.minPhysFPS) {
physdt /= 2;
nSteps *= 2;
}

if (nSteps != 1)
console.log(nSteps);
if (nSteps > 1) {
console.log(
"Too long between frames for physics ("+dt.toFixed(2)+"s). "+
"Running "+nSteps+" simulations in one frame.");
}

for (let i = 0; i < nSteps; ++i)
this.physics(dt);
this.physics(physdt);
}

this.draw();

Loading…
Cancel
Save