"Optimal" game loop for 2D side-scroller

Posted by MrDatabase on Game Development See other posts from Game Development or by MrDatabase
Published on 2011-02-06T04:19:39Z Indexed on 2011/02/06 7:33 UTC
Read the original article Hit count: 417

Is it possible to describe an "optimal" (in terms of performance) layout for a 2D side-scroller's game loop? In this context the "game loop" takes user input, updates the states of game objects and draws the game objects.

For example having a GameObject base class with a deep inheritance hierarchy could be good for maintenance... you can do something like the following:

foreach(GameObject g in gameObjects) g.update();

However I think this approach can create performance issues.

On the other hand all game objects' data and functions could be global. Which would be a maintenance headache but might be closer to an optimally performing game loop.

Any thoughts? I'm interested in practical applications of near optimal game loop structure... even if I get a maintenance headache in exchange for great performance.

© Game Development or respective owner

Related posts about optimization

Related posts about Performance