"Optimal" game loop for 2D side-scroller
- by MrDatabase
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.