Permalink
Browse files

Made the loop less dependant on the previous frames execution by chan…

…ging from timout to interval. This should improve the perceived performance.
  • Loading branch information...
erkie committed Oct 12, 2010
1 parent ff3bed9 commit be46090487323e626db2fb75afdd54427df449c1
Showing with 11 additions and 6 deletions.
  1. +8 −4 asteroids.js
  2. +3 −2 asteroids.min.js
View
@@ -1063,15 +1063,19 @@ function Asteroids() {
}
}
this.lastPos = this.pos;
-
- setTimeout(updateFunc, 1000 / FPS);
}
// Start timer
var updateFunc = function() {
- that.update.call(that);
+ try {
+ that.update.call(that);
+ }
+ catch (e) {
+ clearInterval(interval);
+ throw e;
+ }
};
- setTimeout(updateFunc, 1000 / FPS);
+ var interval = setInterval(updateFunc, 1000 / FPS);
function destroy() {
removeEvent(document, 'keydown', eventKeydown);
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

0 comments on commit be46090

Please sign in to comment.