Performance Considerations

Frame Rate

The GameEngine defaults to a framerate of 30FPS; it is suggested that you do not change this default value.

Notes on Performance

The performance of a game created with the GdiGaming API will be highly dictated by the number of sprites being drawn to the screen, the number of objects serving as colliders, the number of objects handling collision (an object can cause collison with another object, but have no capacity to respond to that collision itself), and the complexity of the code in the game logic methods.

The GameEngine can support thousands of simple GameObjects, but the more of them which require advanced rendering (such as rotation, scaling, multiple sprites, etc) or use full collision, the lower the total becomes. The total can also be impacted by the complexity of the logic being executed by each game object's game logic methods. If an object's OnUpdate or OnCollision methods take too long to execute, the game's performance will suffer.

The GameEngine reveals a FrameRate and IsRunningSlow property which can be used to montior performance and limit the number of new objects added to the game at one time. IsRunningSlow will return true whenever the current framerate has dropped below 80% of the target framerate. This allows the game logic to tune itself before the drop in performance becomes noticeable to the player.

In my testing on a powerful computer, the API can handle ~2400 objects, all of which are colliders and 10-20 of which handle their collision. A framerate of 27-29 FPS is maintained without exceeding 50% the processor core used. If the total number of objects is reduced to ~1000, then over 100 objects with full collision can be supported at 28-29 FPS. So every game will have to balance its total number of visible game objects with collision, based on overall needs.

Also, note that each simultaneous sound requires a new instance of the MediaPlayer class, so care should be taken to not play too many sound effects too rapidly. The framework will limit simultaneous playing sounds to 20 by default.

Last edited Dec 29, 2011 at 7:58 PM by ReedKimble, version 3


No comments yet.