4
\$\begingroup\$

I'm making a JavaScript game engine for fun and one thing I noticed was that my laptop runs super hot with the simplest game mechanics and that my game is doing about 600 updates per second.

The graphics is already capped at 60 fps, but I'm wondering if I should limit the update cycles so my processor doesn't get owned on the simplest games.

I think the answer is yes, it is just that I've never heard of anyone doing this before, so I wanted others opinions.

\$\endgroup\$

2 Answers 2

4
\$\begingroup\$

You may want to look at some of the common javascript game loop patterns that exist. Most folks use a timer to schedule the game loop. This resource is excellent: http://codeofrob.com/archive/2011/03/17/a-javascript-game-loop-for-multiplayer-webgl.aspx

If your game isn't multiplayer you can likely use what the author calls "another naive game loop".

\$\endgroup\$
3
\$\begingroup\$

600 updates per second is far too much for any game I can think of. Some games require a very intensive update rate, but most of the games can do all they need to be done, with a 25-30 update rate per second. (We speak about the game state updates, not about the display updates)

There is different methods to limit the number of game state update per second... and as Koen Witters wrote a very interesting, clear and simple paper on this question I recommend you the following article ( http://www.koonsolo.com/news/dewitters-gameloop/ ) instead of trying to explain myself the same ideas with my approximative English ;)

This paper will present you four approaches of game loops, and for each one it will expose the pros, the cons and explain how it can be done.

\$\endgroup\$
1
  • \$\begingroup\$ This is a great resourceful answer and I appreciate it, but I can only mark a single answer, and the other one is more directly relative to JS. They are both correct though. Again thanks. \$\endgroup\$ Commented May 15, 2011 at 14:37

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .