diff --git a/examples/index.html b/examples/index.html index 112b2db..f0cb052 100644 --- a/examples/index.html +++ b/examples/index.html @@ -46,12 +46,10 @@ }); function input() { - if(mouseDown){ - velocity *= 1.0005; - direction = 1; + if (mouseDown) { + loop.setSlow(3); } else { - velocity /= 1.0005; - direction = -1; + loop.setSlow(1); } } diff --git a/examples/main.js b/examples/main.js index fcce11b..acfc9ae 100644 --- a/examples/main.js +++ b/examples/main.js @@ -25,11 +25,9 @@ requirejs(['../src/gameLoop'], function (createLoop) { function input() { if (mouseDown) { - velocity *= 1.0005; - direction = 1; + loop.setSlow(3); } else { - velocity /= 1.0005; - direction = -1; + loop.setSlow(1); } } diff --git a/src/gameLoop.js b/src/gameLoop.js index a29132f..2a9afa6 100644 --- a/src/gameLoop.js +++ b/src/gameLoop.js @@ -37,7 +37,7 @@ input(); while (lag >= slowStep) { lag -= slowStep; - update(step); + update(step/slowStep); } frameTime += (delta - frameTime) / fpsFilterStrength; render();